body {
    font-family: 'Inter', sans-serif;
}
.tool-content {
    display: none;
}
.tool-content.active {
    display: block;
}
.nav-link {
    transition: all 0.3s ease;
    padding: 0.75rem 1.5rem; /* py-3 px-6, adjusted for better vertical centering */
    display: flex; /* Use flexbox for alignment */
    align-items: center; /* Center items vertically */
    font-size: 0.875rem; /* text-sm, slightly smaller font */
    color: #4b5563; /* Default text color */
    border-left: 4px solid transparent; /* Default transparent border */
    margin-right: 1rem; /* Keep some margin for spacing */
    border-radius: 0.5rem; /* Subtle rounding for all links */
}
.nav-link i { /* Adjust icon size */
    font-size: 1rem; /* Default icon size */
}

.nav-link.active {
    background-color: #e0e7ff; /* Light background for active */
    color: #4f46e5; /* Active text color */
    font-weight: 600;
    border-left-color: #4f46e5; /* Blue left border */
    box-shadow: none; /* Remove shadow for cleaner look */
}
/* Global dark mode for active link */
.dark .nav-link.active {
    background-color: #374151; /* Dark background for active */
    color: #6366f1; /* Dark active text color */
    border-left-color: #6366f1; /* Dark blue left border */
}
/* Global dark mode for hover */
.dark .nav-link:hover:not(.active) {
    background-color: #374151; /* dark:hover:bg-gray-700 */
}
.nav-link:hover:not(.active) {
    background-color: #e0e7ff; /* hover:bg-indigo-100 */
}

.output-box-container {
    position: relative;
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background-color: #f3f4f6;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.dark .output-box-container {
    background-color: #0f172a;
    border-color: #374151;
}
.output-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', Courier, monospace;
    max-height: 20rem;
    overflow-y: auto;
    padding-right: 2.5rem;
    color: #1f2937;
}
.dark .output-content {
    color: #e2e8f0;
}
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    background-color: #e5e7eb;
    color: #4b5563;
    border-radius: 0.375rem;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    line-height: 1;
}
.dark .copy-btn {
    background-color: #374151;
    color: #d1d5db;
}
.copy-btn:hover {
    background-color: #d1d5db;
}
.dark .copy-btn:hover {
    background-color: #4b5563;
}
.copy-feedback {
    position: absolute;
    top: 0.75rem;
    right: 3.5rem;
    color: #10b981;
    font-size: 0.875rem;
    white-space: nowrap;
}
.dark .copy-feedback {
    color: #34d399;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sidebar styles - default for desktop */
#sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out, border-color 0.3s ease-in-out;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-right: 1px solid #e2e8f0;
}

/* Collapsed state for desktop */
#sidebar.sidebar-collapsed {
    width: 4rem; /* ~64px */
    overflow-x: hidden; /* Hide text */
}
#sidebar.sidebar-collapsed .nav-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.1s ease-in-out, width 0.1s ease-in-out;
}
#sidebar.sidebar-collapsed .nav-link i {
    margin-right: 0; /* Remove margin when collapsed */
}
#sidebar.sidebar-collapsed .sidebar-header-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.1s ease-in-out, width 0.1s ease-in-out;
}

/* Expanded state for desktop */
#sidebar.sidebar-expanded {
    width: 16rem; /* ~256px */
}
#sidebar.sidebar-expanded .nav-link span {
    opacity: 1;
    width: auto;
    overflow: visible;
}
#sidebar.sidebar-expanded .nav-link i {
    margin-right: 0.75rem; /* mr-3 */
}
#sidebar.sidebar-expanded .sidebar-header-text {
    opacity: 1;
    width: auto;
    overflow: visible;
}

/* Mobile specific overrides */
@media (max-width: 1023px) {
    #sidebar {
        position: fixed;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 50;
        width: 16rem; /* Full width for mobile open state */
    }
    #sidebar.sidebar-mobile-open {
        transform: translateX(0%);
    }
    #mobile-menu-button {
        display: block;
    }
    #sidebar-overlay {
        display: block;
    }
    /* Ensure mobile sidebar always shows text */
    #sidebar .nav-link span,
    #sidebar .sidebar-header-text {
        opacity: 1;
        width: auto;
        overflow: visible;
    }
    #sidebar .nav-link i {
        margin-right: 0.75rem; /* mr-3 */
    }
    #sidebar.sidebar-collapsed { /* Remove collapsed styles on mobile */
        width: 16rem;
    }
    /* Adjust padding for mobile menu items to ensure they look good when opened */
    #sidebar .nav-link {
        padding: 0.75rem 1rem; /* Smaller horizontal padding for mobile */
        margin-right: 0; /* No right margin on mobile */
        border-radius: 0; /* No border radius for full width on mobile */
        border-left: 4px solid transparent; /* Keep border for active state */
    }
    #sidebar .nav-link.active {
        border-radius: 0; /* No border radius for full width on mobile */
    }
}

/* Desktop specific adjustments (hide mobile elements) */
@media (min-width: 1024px) {
    #mobile-menu-button {
        display: none;
    }
    #sidebar-overlay {
        display: none;
    }
    /* Apply collapsed state by default on desktop */
    #sidebar {
        width: 4rem; /* Start collapsed on desktop */
    }
}

/* Speed Test Specific Styling */
.speed-value {
    font-size: 3rem;
    font-weight: 700;
    color: #4f46e5;
    margin-top: 0.5rem;
    line-height: 1;
}
.speed-unit {
    font-size: 1rem;
    color: #6b7280;
}
.speed-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-radius: 0.5rem;
    background-color: #f3f4f6;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out;
}
.dark .speed-card {
    background-color: #374151;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.speed-card:hover {
    transform: translateY(-5px);
}

/* Chat Widget Specific Styles */
#ai-chat-widget {
    bottom: 1rem;
    right: 1rem;
    display: flex; /* Default for desktop (bubble always visible) */
    flex-direction: column;
    align-items: flex-end;
    /* Default hidden on mobile */
    @media (max-width: 767px) {
        display: none; /* Hidden by default on mobile */
    }
}

#ai-chat-widget.active-overlay {
    /* Styles for when chat is open on mobile */
    @media (max-width: 767px) { /* Tailwind's 'md' breakpoint is 768px */
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0,0,0,0.5); /* Overlay */
        justify-content: center;
        align-items: center;
        display: flex; /* Override display: none when active */
    }
}

#chat-open-btn {
    z-index: 51; /* Above chat window when closed */
    /* Hide open button when widget is full screen on mobile */
    @media (max-width: 767px) {
        display: none;
    }
}

#chat-window {
    position: absolute;
    bottom: 0; /* Aligns with the bottom of the widget container */
    right: 0;
    z-index: 50;
    width: 350px;
    height: 500px;
    transform: translateY(100%); /* Start hidden below */
    transition: transform 0.3s ease-in-out;
    /* No absolute positioning on mobile */
    @media (max-width: 767px) {
        width: 95vw;
        height: 95vh;
        position: static; /* No longer absolute within widget container */
        transform: translateY(0); /* Always visible when widget is open */
    }
}
#chat-window.open {
    transform: translateY(0);
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
#chat-messages .message-bubble {
    padding: 0.75rem;
    border-radius: 0.75rem;
    max-width: 80%;
    word-wrap: break-word;
}
#chat-messages .user-message {
    background-color: #e0e7ff; /* indigo-100 */
    align-self: flex-end;
    color: #1f2937;
}
.dark #chat-messages .user-message {
    background-color: #4f46e5; /* indigo-600 */
    color: white;
}
#chat-messages .ai-message {
    background-color: #f3f4f6; /* gray-100 */
    align-self: flex-start;
    color: #1f2937;
}
.dark #chat-messages .ai-message {
    background-color: #374151; /* gray-700 */
    color: #e2e8f0;
}
#chat-messages .loader-message {
    align-self: flex-start;
}


/* Settings Modal Specific Styles */
#settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex !important; /* Force display flex for centering, will be overridden by hidden class */
    justify-content: center;
    align-items: center;
    z-index: 100;
    /* This is the critical line to ensure it's hidden by default */
    display: none !important;
}
#settings-modal-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    color: #1f2937;
}
.dark #settings-modal-content {
    background-color: #1f2937;
    color: #e2e8f0;
}
#settings-modal-content .theme-option {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s ease;
}
#settings-modal-content .theme-option:hover {
    background-color: #e0e7ff; /* indigo-100 */
}
.dark #settings-modal-content .theme-option:hover {
    background-color: #374151; /* gray-700 */
}
#settings-modal-content .theme-option.selected {
    background-color: #4f46e5; /* indigo-600 */
    color: white;
    font-weight: 600;
}
.dark #settings-modal-content .theme-option.selected {
    background-color: #6366f1; /* indigo-500 */
    color: white;
}
#settings-modal-content .theme-option i {
    margin-right: 0.75rem;
    width: 1.25rem; /* Ensure consistent icon width */
    text-align: center;
}
