/* Enhanced CSS styles for Network Tools Application - FIXED VERSION */

/* SIDEBAR SCROLLBAR FIX */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden; /* FIXED: Prevent horizontal scrollbar */
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    overflow-y: hidden; /* FIXED: Hide scrollbar when collapsed */
}

/* Enhanced sidebar hover for collapsed state */
.sidebar.collapsed.hover-expanded {
    width: var(--sidebar-width);
    box-shadow: 4px 0 12px rgba(0,0,0,0.15);
    z-index: 1001;
    overflow-y: auto; /* Re-enable scrollbar when expanded on hover */
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0; /* FIXED: Prevent header from shrinking */
    min-height: 60px; /* Ensure consistent header height */
}

.nav-menu {
    padding: 0;
    list-style: none;
    flex: 1; /* FIXED: Allow menu to take remaining space */
    overflow-y: auto; /* Allow scrolling within nav menu only */
    overflow-x: hidden;
}

.sidebar.collapsed .nav-menu {
    overflow-y: hidden; /* Hide scrolling when collapsed */
}

.sidebar.collapsed.hover-expanded .nav-menu {
    overflow-y: auto; /* Re-enable scrolling on hover */
}

.nav-item {
    display: block;
    padding: 16px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.3s ease;
    font-size: 14px;
    position: relative;
    white-space: nowrap; /* FIXED: Prevent text wrapping */
    flex-shrink: 0; /* Prevent nav items from shrinking */
}

.nav-item .icon {
    display: inline-block;
    width: 20px;
    margin-right: 12px;
    text-align: center;
    flex-shrink: 0; /* FIXED: Prevent icon from shrinking */
}

.nav-item .text {
    transition: opacity 0.3s ease;
    display: inline-block;
}

.sidebar.collapsed .nav-item .text {
    opacity: 0;
    pointer-events: none; /* FIXED: Prevent interaction with hidden text */
    width: 0; /* Collapse text width */
    overflow: hidden;
}

.sidebar.collapsed.hover-expanded .nav-item .text {
    opacity: 1;
    pointer-events: auto;
    width: auto;
}

/* Enhanced form styling */
.form-input:invalid {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-input:valid {
    border-color: var(--success-color);
}

/* Enhanced button animations */
.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Enhanced table styles for results */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 16px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    word-wrap: break-word;
    max-width: 300px;
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
    user-select: none;
}

.data-table th[onclick] {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.data-table th[onclick]:hover {
    background: var(--border-color);
}

.data-table td {
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.data-table td:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.02);
}

.data-table td.copyable-cell:hover::after {
    content: '📋';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    font-size: 12px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Search filter highlight */
.highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

/* Status legend */
.status-legend {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.status-legend h4 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 16px;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 8px;
}

.legend-item {
    padding: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Loading states for share button */
#shareLoading {
    display: none;
}

#shareLoading.show {
    display: inline;
    animation: spin 1s linear infinite;
}

#shareBtn {
    display: inline;
}

#shareBtn.hide {
    display: none;
}

/* Results panel styling */
.results-panel {
    margin-top: 32px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-panel.show {
    display: block;
}

.results-header {
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.results-actions {
    display: flex;
    gap: 8px;
}

.results-content {
    padding: 0;
}

/* No results message */
.no-results {
    padding: 40px 24px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Status indicators */
.status-success {
    color: var(--success-color);
    font-weight: 600;
}

.status-danger {
    color: var(--danger-color);
    font-weight: 600;
}

.status-warning {
    color: var(--warning-color);
    font-weight: 600;
}

.status-info {
    color: var(--info-color);
    font-weight: 600;
}

/* Enhanced IP card styling */
/* NEW: Compact IP card styling */
.ip-card {
    text-align: center;
    padding: 48px 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    color: white;
    border-radius: 16px;
    margin: 32px auto;
    max-width: 800px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,123,255,0.3);
    display: block;
}

.ip-card:hover {
    transform: translateY(-2px);
}

.ip-number {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.ip-number:hover {
    transform: scale(1.05);
    text-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.ip-subtitle {
    font-size: 18px;
    opacity: 0.9;
}

/* Password display styling */
.password-display {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px dashed var(--border-color);
}

.password-display:hover {
    background: var(--border-color);
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.password-display::after {
    content: ' 📋';
    opacity: 0;
    transition: opacity 0.2s ease;
}

.password-display:hover::after {
    opacity: 1;
}

/* Image converter results styling */
.image-result {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
}

.image-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.image-result-title {
    font-weight: 600;
    color: var(--text-primary);
}

.download-btn {
    background: var(--success-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.download-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.image-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 16px;
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

/* Loading state enhancements */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-text {
    margin-left: 10px;
    color: var(--text-secondary);
}

.loading-spinner {
    display: none;
}

.loading-spinner.show {
    display: inline;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Result panel enhancements */
.results-panel .copy-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--success-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.results-panel .copy-indicator.show {
    opacity: 1;
}

/* Pre-content styling for legacy fallbacks */
.pre-content {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pre-content:hover {
    background: var(--border-color);
}

/* NOTIFICATION FIX - Ensure notifications are completely hidden by default */
#copyNotification,
#shareNotification,
#pwaNotification {
    display: none !important;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
}

/* Show notifications only when explicitly shown */
#copyNotification.show,
#shareNotification.show,
#pwaNotification.show {
    display: block !important;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Enhanced mobile styles */
@media (max-width: 480px) {
    .content-wrapper {
        padding: 16px;
    }
    
    .tool-section {
        padding: 20px;
    }
    
    .section-title {
        font-size: 24px;
    }
    
    .form-input {
        padding: 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn {
        padding: 14px 20px;
        font-size: 16px;
    }
    
    .data-table {
        font-size: 14px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }
    
    .results-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .results-actions {
        justify-content: center;
    }
    
    .ip-number {
        font-size: 36px;
    }
    
    .password-display {
        font-size: 16px;
        padding: 16px;
    }
    
    /* Mobile notification positioning */
    #copyNotification,
    #shareNotification,
    #pwaNotification {
        left: 10px;
        right: 10px;
        transform: translateY(-100%);
    }
    
    #copyNotification.show,
    #shareNotification.show,
    #pwaNotification.show {
        transform: translateY(0);
    }
    
    /* Mobile sidebar fixes */
    .sidebar {
        overflow-y: auto; /* Always allow scrolling on mobile */
    }
    
    .sidebar.collapsed {
        overflow-y: auto; /* Keep scrolling enabled on mobile even when collapsed */
    }
}

/* Enhanced mobile responsiveness for tables */
@media (max-width: 768px) {
    .data-table {
        font-size: 14px;
    }
    
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }
    
    .data-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .data-table tr {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 12px;
        background: var(--bg-primary);
    }
    
    .data-table td {
        border: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        padding-left: 50% !important;
        white-space: normal;
        text-align: left;
        max-width: none;
    }
    
    .data-table td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .data-table td:last-child {
        border-bottom: none;
    }
    
    /* Mobile image info grid */
    .image-info {
        grid-template-columns: 1fr;
    }
    
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .info-value {
        text-align: left;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .top-bar,
    .pwa-banner,
    .notification,
    .mobile-overlay,
    .results-actions,
    #copyNotification,
    #shareNotification,
    #pwaNotification {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .results-panel {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .pre-content,
    .password-display {
        background: #f8f9fa;
        border: 1px solid #dee2e6;
    }
    
    .data-table {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --success-color: #008000;
        --danger-color: #ff0000;
        --warning-color: #ff8c00;
        --info-color: #4169e1;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-input {
        border-width: 3px;
    }
    
    .data-table td:hover {
        background-color: #ffff00;
        color: #000000;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
    }
    
    .data-table td:hover {
        transform: none;
    }
    
    .ip-number:hover {
        transform: none;
    }
    
    .password-display:hover {
        transform: none;
    }
    
    .ip-card:hover {
        transform: none;
    }
    
    #copyNotification,
    #shareNotification,
    #pwaNotification {
        transition: none;
    }
}

/* Focus indicators for keyboard navigation */
.nav-item:focus,
.btn:focus,
.form-input:focus,
.toggle-btn:focus,
.data-table td:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Enhanced error states */
.error-message {
    background: var(--danger-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message::before {
    content: '⚠️';
    font-size: 16px;
}

/* Success states */
.success-message {
    background: var(--success-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.success-message::before {
    content: '✅';
    font-size: 16px;
}

/* Tooltip styles */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Status indicators with icons */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.online {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.status-indicator.offline {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.status-indicator.warning {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

/* Progress bars */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Card layouts for results */
.result-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s ease;
}

.result-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.result-card-title {
    font-weight: 600;
    color: var(--text-primary);
}

.result-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Responsive grid for cards */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

/* Additional notification styling enhancements */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 2000;
    max-width: 300px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.notification.copy {
    background: var(--success-color);
    color: white;
}

.notification.share {
    background: var(--info-color);
    color: white;
}

/* Ensure proper stacking and positioning */
#copyNotification {
    z-index: 2001;
}

#shareNotification {
    z-index: 2002;
}

#pwaNotification {
    z-index: 2003;
}

@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    /* Mobile-specific table improvements */
    .data-table td:before {
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .data-table td {
        padding-top: 12px;
        padding-bottom: 12px;
    }
    
    .data-table tr:last-child td:last-child {
        border-bottom: none;
    }
}

/* Custom scrollbar styling for webkit browsers */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

.sidebar.collapsed::-webkit-scrollbar {
    width: 0px; /* Hide scrollbar when collapsed */
}

.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* Firefox scrollbar styling */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) rgba(255,255,255,0.1);
}

.sidebar.collapsed {
    scrollbar-width: none; /* Hide scrollbar when collapsed */
}

/* Ensure nav menu scrolling works properly */
.nav-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}