:root {
    --primary-color: #25D366; /* WhatsApp Green */
    --primary-dark: #128C7E;
    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --text-main: #111b21;
}

body {
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
}

/* Sidebar Styles */
.sidebar {
    min-height: 100vh;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    background-color: var(--sidebar-bg);
}

.brand-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.brand-title {
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.nav-link {
    color: #54656f;
    border-radius: 8px;
    padding: 10px 15px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: #f0f2f5;
    color: var(--text-main);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(0, 119, 254, 0.08), rgba(0, 229, 255, 0.14));
    color: #0077fe;
    font-weight: 600;
    border-left: 3px solid #0077fe;
}

/* Main Content Styles */
.main-content {
    background-color: var(--bg-color);
    min-height: 100vh;
}

.stat-card {
    border-radius: 12px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.max-w-600 {
    max-width: 600px;
}

.form-control {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #d1d7db;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(37, 211, 102, 0.25);
}

.btn-primary {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-primary:hover {
    background-color: #0c6b5e;
    border-color: #0c6b5e;
}

.btn-success {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-success:hover {
    background-color: #1ebe57;
    border-color: #1ebe57;
}

.table th {
    font-weight: 600;
    color: #54656f;
    border-bottom-width: 1px;
}

/* Glassmorphism attempt for modern look */
.premium-glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* User Profile Widget in Sidebar */
.user-profile-box {
    transition: all 0.2s ease-in-out;
}
.user-profile-box:hover {
    border-color: rgba(18, 140, 126, 0.35) !important;
    background: rgba(18, 140, 126, 0.12) !important;
}

/* Status Badges */
.badge-status-new {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    font-weight: 600;
}
.badge-status-contacted {
    background-color: #cff4fc;
    color: #055160;
    border: 1px solid #b6effb;
    font-weight: 600;
}
.badge-status-completed {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
    font-weight: 600;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Terminal Console View */
#bot-logs-pre::-webkit-scrollbar-track {
    background: #111b21;
}
#bot-logs-pre::-webkit-scrollbar-thumb {
    background: #25D366;
    border-radius: 3px;
}

/* ========================================================
   Mobile-First & Responsive Layout Enhancements
   ======================================================== */

/* Prevent accidental horizontal overflow on mobile devices */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Mobile Sticky Topbar */
.mobile-topbar {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 1025;
    height: 56px;
}

/* Mobile Offcanvas Drawer */
.mobile-offcanvas {
    max-width: 82vw;
    width: 310px !important;
    background: #ffffff;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
}

.mobile-offcanvas .nav-link {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.92rem;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1030;
    padding: 0 4px calc(env(safe-area-inset-bottom, 0px) + 2px) 4px;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.05);
}

.mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    outline: none;
    padding: 6px 0;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    touch-action: manipulation;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn i {
    font-size: 1.15rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.mobile-nav-btn.active {
    color: #0077fe;
    font-weight: 700;
}

.mobile-nav-btn.active i {
    transform: scale(1.15);
    color: #0077fe;
}

/* Media Queries for Phone Screens (< 768px) */
@media (max-width: 767.98px) {
    /* Safe padding at the bottom so mobile nav bar never overlaps buttons/inputs */
    .main-content {
        padding-bottom: 96px !important;
        padding-top: 1rem !important;
        min-height: auto;
    }

    /* Prevent iOS Safari auto-zoom on input focus */
    input.form-control,
    textarea.form-control,
    select.form-select {
        font-size: 16px !important;
    }

    /* Compact stat cards on mobile */
    .stat-card .card-body {
        padding: 0.9rem !important;
    }
    .stat-card h2 {
        font-size: 1.6rem !important;
    }
    .stat-card h6 {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
    }

    /* Fast, smooth touch scrolling for tables */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
        border-radius: 8px;
    }

    /* Responsive tables */
    .table td, .table th {
        white-space: nowrap;
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Touch target comfort */
    .btn {
        touch-action: manipulation;
        min-height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* QR Code Container Mobile Fit */
    #wa-live-qr-img {
        max-width: 250px !important;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1/1;
    }

    /* Conversation Bubble Width on Small Screens */
    .bubble {
        max-width: 88% !important;
    }

    /* Modal Fullscreen Adaptation on Mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: 100%;
    }

    /* Log terminal responsiveness */
    #bot-logs-pre {
        max-height: 350px !important;
        font-size: 0.75rem !important;
        padding: 0.75rem !important;
    }

    /* Quick Links list on mobile */
    .quick-link-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    .quick-link-row input {
        width: 100% !important;
    }
}

/* Extra small devices (< 576px) */
@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .card {
        border-radius: 12px !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* Full width buttons on mobile forms */
    .mobile-w-100 {
        width: 100% !important;
    }

    .d-flex.gap-2.justify-content-end {
        flex-direction: column !important;
    }
    .d-flex.gap-2.justify-content-end .btn {
        width: 100% !important;
    }

    /* Responsive Input groups: prevent overflow */
    .input-group:not(.input-group-nowrap) {
        flex-wrap: wrap;
    }
    .input-group:not(.input-group-nowrap) > .form-control {
        flex: 1 1 100%;
        border-radius: 8px !important;
        margin-bottom: 6px;
    }
    .input-group:not(.input-group-nowrap) > .btn {
        flex: 1 1 auto;
        border-radius: 8px !important;
    }
}
