/* Wabadak - Premium WhatsApp Style Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0b141a;
    --bg-secondary: #111b21;
    --bg-card: #202c33;
    --border-color: #2a3942;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --accent-color: #00a884;
    --accent-hover: #008f72;
    --accent-light: #25d366;
    --nav-bg: #202c33;
    --btn-secondary: #2a3942;
    --input-bg: #2a3942;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    --border-radius: 12px;
}

body.light-mode {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e1e9eb;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --accent-color: #008069;
    --accent-hover: #005e4d;
    --accent-light: #25d366;
    --nav-bg: #ffffff;
    --btn-secondary: #eaebeb;
    --input-bg: #f0f2f5;
    --shadow: 0 8px 30px rgba(11, 20, 26, 0.08);
}

/* Light mode specific visibility overrides to solve invisible white text inside cards/tables */
body.light-mode .w-card .text-white,
body.light-mode table .text-white,
body.light-mode .w-card h2.text-white,
body.light-mode .w-card h4.text-white,
body.light-mode .w-card h5.text-white,
body.light-mode .w-card h6.text-white,
body.light-mode .w-card span.text-white,
body.light-mode .w-card a.text-white,
body.light-mode .w-card td.text-white {
    color: var(--text-primary) !important;
}

* {
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Custom Utilities & Premium Cards */
.w-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.w-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-light));
    opacity: 0.8;
}

.w-card.no-top-border::before {
    display: none;
}

/* Inputs & Form Styling */
.form-control, .form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary) !important;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-weight: 400;
}

.form-control:focus, .form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 168, 132, 0.2);
}

.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-color)) !important;
    box-shadow: 0 6px 20px rgba(0, 168, 132, 0.3) !important;
}

.btn-secondary {
    background-color: var(--btn-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
}

.btn-secondary:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

/* Setup Wizard Custom Styles */
.setup-sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    min-height: 100vh;
    padding: 3rem 2rem;
}

.setup-step-item {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
}

.setup-step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 1rem;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    z-index: 2;
}

.setup-step-item.active .setup-step-number {
    border-color: var(--accent-color);
    color: #ffffff;
    background-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 168, 132, 0.15);
}

.setup-step-item.completed .setup-step-number {
    border-color: var(--accent-light);
    color: #ffffff;
    background-color: var(--accent-light);
}

.setup-step-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.setup-step-item.active .setup-step-label {
    color: var(--text-primary);
    font-weight: 600;
}

.setup-step-item.completed .setup-step-label {
    color: var(--accent-light);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Theme Switcher Button */
.theme-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.theme-toggle-btn:hover {
    background-color: var(--border-color);
}

/* Glassmorphism Navigation */
.header-nav {
    background-color: rgba(32, 44, 51, 0.8) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 999;
}

body.light-mode .header-nav {
    background-color: rgba(255, 255, 255, 0.8) !important;
    border-bottom: 1px solid var(--border-color);
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: none;
    justify-content: space-around;
    align-items: center;
    z-index: 998;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.15);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    flex: 1;
    height: 100%;
}

.bottom-nav-item i {
    font-size: 1.35rem;
    margin-bottom: 2px;
}

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

/* Desktop Sidebar Dashboard */
.sidebar-nav {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.sidebar-nav-item:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background-color: var(--accent-color);
    color: #ffffff;
}

.sidebar-nav-item i {
    margin-right: 1rem;
    font-size: 1.2rem;
}

/* Custom QR Scan Visual */
.qr-container {
    width: 250px;
    height: 250px;
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #ffffff;
    margin: 0 auto;
}

.qr-container.active {
    border-color: var(--accent-light);
}

.qr-scanner-line {
    position: absolute;
    width: 100%;
    height: 4px;
    background-color: var(--accent-light);
    box-shadow: 0 0 10px var(--accent-light);
    top: 0;
    left: 0;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }
    .setup-sidebar {
        display: none;
    }
    body {
        padding-bottom: 70px;
    }
}

/* Premium Tables & Contrast Correction */
.table {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table th, .table td {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table-responsive {
    background-color: transparent !important;
    border: none !important;
}

/* Ensure headings & specific dark text in tables stay highly visible */
.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
    color: var(--text-secondary) !important;
    border-bottom: 2px solid var(--border-color) !important;
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color) !important;
}

/* Select Delay dropdown and custom inputs inside tables */
.table select.form-select, .table input.form-control {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

body.light-mode .table select.form-select, 
body.light-mode .table input.form-control {
    background-color: #ffffff !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Override all classes that might force text-white inside tables in light mode */
body.light-mode .table .text-white,
body.light-mode .table td.text-white,
body.light-mode .table td {
    color: var(--text-primary) !important;
}

/* Modal text visibility corrections */
.modal-content label {
    color: var(--text-primary) !important;
}
.modal-content input, .modal-content select, .modal-content textarea {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
body.light-mode .modal-content input, 
body.light-mode .modal-content select, 
body.light-mode .modal-content textarea {
    background-color: #ffffff !important;
    color: var(--text-primary) !important;
}

/* Mobile Sidebar Toggle Button */
.mobile-toggle-btn {
    display: none;
}

.sidebar-close-btn {
    display: none;
}

@media (max-width: 991px) {
    .mobile-toggle-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background-color: var(--btn-secondary) !important;
        border: 1px solid var(--border-color) !important;
        color: var(--text-primary) !important;
        border-radius: 8px;
        font-size: 1.25rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .mobile-toggle-btn:hover {
        background-color: var(--border-color) !important;
    }

    /* Transform existing sidebar to a premium sliding off-canvas drawer on mobile */
    .sidebar-nav {
        position: fixed !important;
        top: 0;
        left: -280px; /* Hide offscreen */
        width: 280px;
        height: 100vh;
        background-color: var(--bg-secondary) !important;
        border-right: 1px solid var(--border-color) !important;
        z-index: 1060 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.5) !important;
        padding: 6rem 1.5rem 2rem 1.5rem !important;
    }
    
    .sidebar-nav.show {
        left: 0 !important; /* Slide in */
    }
    
    /* Close Button inside mobile sidebar */
    .sidebar-close-btn {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        background: transparent;
        border: none;
        color: var(--text-secondary) !important;
        font-size: 1.5rem;
        cursor: pointer;
        display: block !important;
        transition: color 0.2s ease;
    }
    
    .sidebar-close-btn:hover {
        color: var(--text-primary) !important;
    }
    
    /* Dynamic backdrop overlay */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(4px) !important;
        z-index: 1050 !important;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-backdrop.show {
        display: block !important;
        opacity: 1 !important;
    }
}

/* Mobile Phone Specific Premium Optimizations (Mobile First Viewports) */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    .w-card {
        padding: 1.15rem 1rem !important;
        margin-bottom: 1rem !important;
        border-radius: 8px !important;
    }
    .row {
        margin-left: -4px !important;
        margin-right: -4px !important;
    }
    .row > [class*="col-"] {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
    h1, .h1 {
        font-size: 1.5rem !important;
    }
    h2, .h2 {
        font-size: 1.35rem !important;
    }
    h3, .h3 {
        font-size: 1.2rem !important;
    }
    .nav-pills .nav-link {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        font-size: 0.85rem !important;
    }
    .btn {
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
    }
}
