:root {
    color-scheme: dark;
    /* Default - Emerald */
    --primary: #0a6924;
    --primary-rgb: 10, 105, 36;
    --primary-hover: #08531d;
    --secondary: #128C7E;
    --primary-hover-solid: #128C7E;

    --bg-dark: #060E17;
    --bg-card: rgba(var(--palette-tint-rgb, 0, 210, 211), 0.05);
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --border-color: rgba(var(--primary-rgb), 0.2);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(var(--primary-rgb), 0.25);
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --font-main: 'Outfit', 'Inter', system-ui, sans-serif;

    --input-bg: rgba(6, 14, 23, 0.8);
    --input-border: rgba(var(--primary-rgb), 0.2);
    --input-text: #F1F5F9;
}

/* Theme Palettes */
body.theme-emerald {
    --primary: #10b981;
    /* Brighter Emerald */
    --primary-rgb: 16, 185, 129;
    --primary-hover: #059669;
    --secondary: #34d399;
    --palette-tint-rgb: 16, 185, 129;
}

body.theme-purple {
    --primary: #8b5cf6;
    --primary-rgb: 139, 92, 246;
    --primary-hover: #7c3aed;
    --secondary: #a78bfa;
    --palette-tint-rgb: 139, 92, 246;
}

body.theme-ocean {
    --primary: #0ea5e9;
    --primary-rgb: 14, 165, 233;
    --primary-hover: #0284c7;
    --secondary: #38bdf8;
    --palette-tint-rgb: 14, 165, 233;
}

body.theme-sunset {
    --primary: #f43f5e;
    --primary-rgb: 244, 63, 94;
    --primary-hover: #e11d48;
    --secondary: #fb7185;
    --palette-tint-rgb: 244, 63, 94;
}

/* Base Variable Overwrites to ensure theme reflects on all elements */
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.brand {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
}

.sidebar-palette-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-palette-dot:hover {
    transform: scale(1.2) !important;
}

/* Light Theme Variables */
.light-theme {
    color-scheme: light;
    --bg-dark: #F0F9FF;
    /* Very light cyan-blue */
    --bg-card: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #475569;
    --border-color: rgba(0, 210, 211, 0.2);
    --glass: rgba(0, 210, 211, 0.03);
    --shadow: 0 10px 25px rgba(0, 210, 211, 0.1);

    /* Light Theme Input Variables */
    --input-bg: #FFFFFF;
    --input-border: rgba(0, 210, 211, 0.3);
    --input-text: #0F172A;
}

.light-theme ::placeholder {
    color: #64748B;
    opacity: 1;
}

/* ... existing code ... */

.input-field,
select,
.btn {
    height: 42px;
    /* Base height */
    line-height: normal;
}

.input-field,
select {
    width: 100%;
    padding: 0 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--input-text);
    font-size: 14px;
    transition: all 0.2s ease;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.input-field:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(114, 185, 68, 0.15);
    background-color: var(--input-bg);
}

/* Custom Dropdown Styling */
select {
    cursor: pointer;
    appearance: none;
    background-color: var(--input-bg) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2300D2D3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Light Theme Specifics for Select */
.light-theme select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%230F172A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    color: #0F172A;
}

.light-theme select option {
    background-color: #FFFFFF;
    color: #0F172A;
}

select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Utilities */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-sm,
select.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.btn-xs,
select.btn-xs {
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--text-main);
    background: rgba(10, 105, 36, 0.05);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #EF4444;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Badge */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: var(--glass);
}

.badge.ready,
.badge.authenticated {
    background: rgba(16, 185, 129, 0.2);
    color: #10B981;
}

.badge.initializing {
    background: rgba(245, 158, 11, 0.2);
    color: #F59E0B;
}

.badge.stopped {
    background: rgba(239, 68, 68, 0.2);
    color: #EF4444;
}

/* Custom Dialogs & Toasts */
.dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 17, 32, 0.8);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.custom-dialog {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: dialogEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dialogEnter {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.custom-dialog h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--primary);
}

.custom-dialog p {
    color: var(--text-main);
    line-height: 1.5;
    margin-bottom: 25px;
    font-size: 14px;
}

.dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Dashbord Hero Section */
.hero-dashboard {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.1), rgba(18, 140, 126, 0.05));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    overflow: visible;
    /* Changed to visible for dropdown */
}

.hero-kebab {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-kebab:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.hero-dropdown {
    display: none;
    position: absolute;
    top: 55px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

.hero-dropdown.active {
    display: block;
}

.hero-dropdown-item {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.hero-dropdown-item:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.hero-dropdown-item.danger:hover {
    background: rgba(255, 0, 0, 0.1);
    color: #ff4444;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-dashboard::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-dashboard h1 {
    font-size: 32px;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(to right, var(--text-main), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.hero-dashboard .welcome-text {
    font-size: 18px;
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 5px;
}

.hero-dashboard .positive-message {
    font-size: 15px;
    color: var(--text-muted);
    font-style: italic;
    max-width: 600px;
    line-height: 1.6;
}

/* Toast System */
#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    animation: toastSlide 0.3s ease-out;
    border-left: 4px solid var(--primary);
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.success {
    border-left-color: #10b981;
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

/* Hide scrollbar for sidebar but keep functionality */
.sidebar::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.main-content {
    flex: 1;
    padding: 30px;
    min-width: 0;
    /* Prevents flex children from causing overflow */
}

.brand {
    font-size: 21px;
    font-weight: 800;
    margin-bottom: 40px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item {
    padding: 12px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item:hover,
.nav-item.active {
    background: var(--glass);
    color: var(--primary);
}

.nav-section-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 12px 8px 12px;
    margin-top: 8px;
    opacity: 0.6;
}

.nav-separator {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
    opacity: 0.3;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .main-content {
        padding: 15px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-top: 50px;
        /* Space for hamburger */
    }

    .grid {
        grid-template-columns: 1fr !important;
    }

    /* Mobile Menu Trigger */
    .mobile-nav-trigger {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        padding: 8px;
        border-radius: 8px;
        color: var(--primary);
    }

    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Hero Section Stacking */
    #hero-dashboard {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Table Responsiveness */
    .glass-panel {
        overflow-x: auto;
        padding: 15px;
    }

    table {
        min-width: 600px;
    }

    .btn-sm {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #hero-dashboard {
        grid-template-columns: 1fr !important;
    }
}

/* WhatsApp Message Preview */
.preview-panel {
    background: #0b141a;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-8e1d-9bc50410a08e.png');
    background-repeat: repeat;
    background-size: 400px;
    border-radius: 12px;
    padding: 20px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    margin-bottom: 4px;
}

.bubble-out {
    background: #005c4b;
    color: #e9edef;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

.bubble-out::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #005c4b;
    border-top-color: #005c4b;
    border-radius: 2px;
}

.preview-media-container {
    display: grid;
    gap: 4px;
    margin-bottom: 6px;
    border-radius: 6px;
    overflow: hidden;
}

.preview-media-item {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    position: relative;
}

.preview-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-time {
    font-size: 11px;
    color: rgba(233, 237, 239, 0.6);
    text-align: right;
    margin-top: 4px;
}

/* Media Badges in List */
.media-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.delay-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}