/* Strict Amber Slate Palette variables */
:root {
    --bg-dark: #09090b;
    --bg-card: rgba(22, 22, 26, 0.7);
    --bg-sidebar: #101014;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(249, 115, 22, 0.2);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;

    --primary: #f97316;
    --primary-hover: #ea580c;
    --accent-blue: #3b82f6;
    --progress-blue: #38bdf8;
    --glow: rgba(249, 115, 22, 0.12);
    --bg-pill: #516487;
    --gradient-orange: linear-gradient(135deg, rgba(249, 115, 22, 0.08) 0%, rgba(22, 22, 26, 0.8) 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none;
}

/* Remove default focus outlines */
a, button, input, select, textarea, .nav-item, .menu-toggle-btn, .header-action-btn {
    outline: none !important;
}
a:focus, button:focus, input:focus, select:focus, textarea:focus, .nav-item:focus {
    outline: none !important;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    flex-direction: column; /* Stack header, content, bottom-nav */
    height: 100vh;
    overflow: hidden;
}

/* Global Loader */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 9, 11, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(249, 115, 22, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

h1, h2, h3, .brand-title {
    font-family: 'Outfit', sans-serif;
}

/* Topbar Header (Mobile) */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    background: rgba(25, 25, 35, 0.2);
    z-index: 5;
    flex-shrink: 0;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.menu-toggle-btn, .header-action-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 5px;
}

/* Main Workspace Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: radial-gradient(circle at 50% 10%, var(--glow), transparent 75%);
}

.tab-content {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0; /* crucial for nested flex scrolling */
}

/* Mobile Slide-Out Sidebar Drawer (Slides from Right) */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: 280px;
    height: 100%;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    z-index: 100;
    transform: translateX(100%); /* Slides from right side */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 25px 20px;
    gap: 20px;
}

.sidebar.open {
    transform: translateX(0);
}

/* Reusable Glass Overlay */
.glass-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    display: none;
}

.glass-overlay.show {
    display: block;
}

/* Sidebar Elements */
.brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 1.4rem;
    color: var(--primary);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.close-sidebar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Sidebar Navigation */
.desktop-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

/* Sidebar Nav Items (Global, applies to mobile and desktop sidebars) */
.sidebar .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 15px;
    gap: 12px;
    font-size: 0.85rem;
    border-radius: 8px;
    width: 100%;
    flex: none;
}

.sidebar .nav-item i {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.sidebar .nav-item.active {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
}

/* Settings Panel Inside Sidebar */
.settings-container {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.settings-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.85rem;
    color: var(--text-main);
}

/* Switch UI Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.08);
    transition: .3s;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(18px);
    background-color: #ffffff;
}

/* Bottom Navigation Bar (Mobile) */
.bottom-nav {
    height: 55px;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 5;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
    flex: 1;
}

.nav-item i {
    font-size: 1.15rem;
}

.nav-item.active {
    color: var(--primary);
}

/* Tab Panels */
.tab-panel {
    display: none;
    flex-grow: 1;
    flex-direction: column;
    min-height: 0;
}

.tab-panel.active {
    display: flex;
}

/* Settings & Profile Panel Styles */
.settings-container {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.settings-header {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-main);
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background: rgba(255,255,255,0.02);
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: rgba(255,255,255,0.05);
}

.collapsible-header .collapse-icon {
    color: var(--text-muted);
    transition: transform 0.3s;
}

.settings-card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    padding: 0 20px 20px 20px;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    max-height: 500px; /* Arbitrary large height for transition */
    opacity: 1;
    overflow: hidden;
}

.settings-card.collapsed .collapsible-content {
    max-height: 0;
    opacity: 0;
    padding-bottom: 0;
}

.settings-card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    margin: 0;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    padding: 3px;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: all 0.2s;
    border-radius: 6px;
    margin: 0;
}

.segmented-control input[type="radio"]:checked + label {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.icon-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn-primary:hover {
    background: var(--primary-hover);
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.select-wrapper .select-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.8rem;
}

/* Desktop Layout Adaptability */
@media (min-width: 768px) {
    body {
        flex-direction: row; /* Sidebar left, content right */
    }

    .bottom-nav {
        display: none; /* Hide bottom nav */
    }

    header {
        padding: 20px 30px;
    }

    .menu-toggle-btn {
        display: none; /* Hide menu button on desktop */
    }

    .sidebar {
        position: static;
        transform: translateX(0);
        width: 250px;
        height: 100%;
        border-right: 1px solid var(--border);
        border-left: none;
    }

    .close-sidebar-btn {
        display: none; /* Hide close button */
    }

    .glass-overlay {
        display: none !important;
    }

    /* Desktop Navigation inside Sidebar */
    .desktop-nav {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-top: 4px;
    }
    
    /* Nav-item specific styles have been moved to global scope for .sidebar .nav-item */
}

/* Hide first 4 navigation items in sidebar on mobile as they are in bottom-nav */
@media (max-width: 767px) {
    .sidebar .desktop-nav .nav-item[onclick*="insights"],
    .sidebar .desktop-nav .nav-item[onclick*="gmail"],
    .sidebar .desktop-nav .nav-item[onclick*="profile"] {
        display: none !important;
    }
}


