/**
 * Offerings Management System (OMS)
 * Custom Styles
 *
 * Theme Colors:
 * - Primary: #395498 (Blue)
 * - Secondary: #FBC908 (Gold/Yellow)
 * - White: #FFFFFF
 * - Dark (sidebar): #1a1a2e
 */

/* ============================================
   CSS Variables (Theme Colors)
   ============================================ */
:root {
    /* Primary Colors */
    --primary: #395498;
    --primary-hover: #284796;
    --primary-light: rgba(167, 24, 28, 0.1);
    --primary-rgb: 167, 24, 28;

    /* Secondary Colors */
    --secondary: #FBC908;
    --secondary-hover: #e0b507;
    --secondary-light: rgba(251, 201, 8, 0.1);

    /* Dark Theme (Sidebar) */
    --dark: #1a1a2e;
    --dark-secondary: #16213e;
    --dark-text: #e2e2e2;
    --dark-muted: #8a8a9a;

    /* Standard Colors */
    --white: #FFFFFF;
    --light: #f8f9fa;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;

    /* Spacing */
    --sidebar-width: 260px;
    --mobile-nav-height: 70px;
    --mobile-header-height: 56px;

    /* Typography */
    --font-family: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);

    /* Border Radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ============================================
   Base Styles
   ============================================ */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: var(--light);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   App Layout
   ============================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: 0;
    padding-bottom: var(--mobile-nav-height);
}

.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(90deg, #ffc107 0%, #ff9800 100%);
    color: #1a1a2e;
    font-size: 0.9rem;
    font-weight: 500;
}

.impersonation-banner .btn-light {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
}

.impersonation-banner .btn-light:hover {
    background: #fff;
}

@media (min-width: 992px) {
    .main-content {
        margin-left: var(--sidebar-width);
        padding-bottom: 0;
    }
}

.page-content {
    flex: 1;
    padding: 1rem;
}

@media (min-width: 768px) {
    .page-content {
        padding: 1.5rem 2rem;
    }
}

/* ============================================
   Sidebar (Desktop)
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-secondary) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.sidebar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--white);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.brand-logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: var(--dark-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-weight: 500;
}

.sidebar-nav .nav-link:hover {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-nav .nav-link.active {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
}

.sidebar-nav .nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    color: var(--white);
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--dark-muted);
    font-size: 0.75rem;
    text-transform: capitalize;
}

.btn-logout {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius);
    color: var(--dark-muted);
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: var(--danger);
    color: var(--white);
}

/* ============================================
   Mobile Header
   ============================================ */
.mobile-header {
    position: sticky;
    top: 0;
    height: var(--mobile-header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 100;
}

.mobile-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hamburger-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--dark);
    font-size: 1.5rem;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color 0.2s ease;
}

.hamburger-btn:hover {
    background-color: var(--gray-light);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.125rem;
}

.mobile-brand i,
.mobile-brand .mobile-brand-icon {
    font-size: 1.25rem;
}

.mobile-brand .mobile-brand-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.mobile-user-btn {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.user-initial {
    color: var(--white);
    font-weight: 600;
    font-size: 0.875rem;
}

/* ============================================
   Mobile Bottom Navigation
   ============================================ */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--white);
    border-top: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--gray);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 500;
    transition: color 0.2s ease;
    flex: 1;
}

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

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

.mobile-nav-add {
    width: 52px;
    height: 52px;
    background: var(--primary);
    border-radius: 50%;
    color: var(--white) !important;
    margin-top: -20px;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
    flex: none;
}

.mobile-nav-add i {
    font-size: 1.5rem;
}

.mobile-nav-whatsapp {
    background: #25D366 !important;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4) !important;
}


/* ============================================
   Mobile Offcanvas Menu
   ============================================ */
.offcanvas-header-dark {
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-secondary) 100%);
    padding: 1rem 1.25rem;
}

.offcanvas-body-nav {
    display: flex;
    flex-direction: column;
}

.offcanvas-nav {
    flex: 1;
    padding: 0.5rem 0;
}

.offcanvas-nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.offcanvas-nav-link:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.offcanvas-nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}

.offcanvas-nav-link.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.offcanvas-nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.offcanvas-nav-divider {
    height: 1px;
    background-color: var(--gray-light);
    margin: 0.5rem 1.25rem;
}

.offcanvas-user-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-light);
    background-color: var(--light);
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 576px) {
    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

/* ============================================
   Cards
   ============================================ */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--white);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gray-light);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary);
    opacity: 0.8;
}

/* Stat icon color variants */
.stat-card .stat-icon.bg-primary-subtle {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.stat-card .stat-icon.bg-success-subtle {
    background: rgba(40, 167, 69, 0.15) !important;
    color: var(--success) !important;
}

.stat-card .stat-icon.bg-warning-subtle {
    background: rgba(255, 193, 7, 0.2) !important;
    color: #b58a00 !important;
}

.stat-card .stat-icon.bg-info-subtle {
    background: rgba(23, 162, 184, 0.15) !important;
    color: var(--info) !important;
}

.stat-card .stat-icon.bg-secondary-subtle {
    background: rgba(108, 117, 125, 0.15) !important;
    color: var(--gray) !important;
}

.stat-card .stat-icon.bg-danger-subtle {
    background: rgba(220, 53, 69, 0.15) !important;
    color: var(--danger) !important;
}

.stat-card .stat-sublabel {
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.stat-card.stat-card-primary .stat-value { color: var(--primary); font-size: 1.15rem; }
.stat-card.stat-card-success .stat-value { color: var(--success); font-size: 1.15rem; }
.stat-card.stat-card-info .stat-value { color: var(--info); font-size: 1.15rem; }
.stat-card.stat-card-warning .stat-value { color: var(--warning); font-size: 1.15rem; }
.stat-card.stat-card-danger .stat-value { color: var(--danger); font-size: 1.15rem; }

.stat-card .stat-value {
    font-size: 1.10rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    color: var(--gray);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ============================================
   Settings Cards
   ============================================ */
.settings-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.settings-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.settings-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    font-size: 1.5rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

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

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: var(--dark);
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: var(--secondary-hover);
    border-color: var(--secondary-hover);
    color: var(--dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ============================================
   Forms
   ============================================ */
.form-label {
    font-weight: 500;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-light);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* Password Toggle */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.password-toggle:hover {
    color: var(--primary);
}

/* Form Check */
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   Tables
   ============================================ */
.table-responsive {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: var(--light);
    border-bottom: 2px solid var(--gray-light);
    font-weight: 600;
    color: var(--dark);
    padding: 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-light);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: var(--primary-light);
}

/* Table Actions */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-actions .btn {
    padding: 0.375rem 0.5rem;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    border: none;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: #155724;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #721c24;
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    color: #0c5460;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
}

.badge-primary {
    background-color: var(--primary);
}

.badge-success {
    background-color: var(--success);
}

.badge-danger {
    background-color: var(--danger);
}

.badge-warning {
    background-color: var(--warning);
    color: var(--dark);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-secondary) 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.login-header {
    background: var(--primary);
    padding: 2rem;
    text-align: center;
}

.login-logo {
    width: 60px;
    height: 60px;
    background: var(--white);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: var(--primary);
}

.login-logo-img {
    max-width: 180px;
    height: auto;
    max-height: 48px;
    margin: 0 auto 1rem;
    display: block;
    object-fit: contain;
}

.login-title {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    margin: 0;
}

.login-body {
    padding: 2rem;
}

.login-footer {
    padding: 0 2rem 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--gray);
}

/* ============================================
   Registration Page (Enhanced)
   ============================================ */
.register-page .login-card {
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.register-page .login-body {
    padding: 2rem 2.5rem;
}

/* Step indicator - modern progress bar */
.register-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.register-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.register-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 1rem;
    left: calc(50% + 1.125rem);
    right: 0;
    height: 2px;
    background: var(--gray-light);
    z-index: 0;
}

.register-step.completed:not(:last-child)::after,
.register-step.active:not(:last-child)::after {
    background: var(--primary);
}

.register-step-circle {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--gray-light);
    color: var(--gray);
    position: relative;
    z-index: 1;
    transition: all 0.25s ease;
}

.register-step-circle i {
    font-size: 0.875rem;
}

.register-step.active .register-step-circle {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 0 0 4px rgba(57, 84, 152, 0.2);
}

.register-step.completed .register-step-circle {
    background: var(--primary);
    color: var(--white);
}

.register-step-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gray);
    margin-top: 0.5rem;
    text-align: center;
}

.register-step.active .register-step-label,
.register-step.completed .register-step-label {
    color: var(--primary);
}

/* Form inputs with icons */
.register-form .form-floating,
.register-form .input-group-wrap {
    margin-bottom: 1.25rem;
}

.register-form .form-control,
.register-form .form-select {
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    padding-inline-start: 2.75rem;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.register-form .form-control:focus,
.register-form .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(57, 84, 152, 0.15);
    outline: none;
}

.register-form .form-control::placeholder {
    color: #adb5bd;
}

.register-form .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    font-size: 1.1rem;
    z-index: 2;
    pointer-events: none;
    transition: color 0.2s ease;
}

.register-form .position-relative:focus-within .input-icon {
    color: var(--primary);
}

.register-form .form-label {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}

.register-form .btn-primary {
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.register-form .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(57, 84, 152, 0.35);
}

.register-form .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.register-form .form-check-label {
    font-weight: 500;
    color: #374151;
}

.register-footer-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.register-footer-link:hover {
    color: var(--primary-hover);
}

/* ============================================
   Data Table Advanced Controls
   ============================================ */
.data-table-controls {
    padding: 0.75rem 1rem !important;
}
.data-table-controls .dropdown-menu {
    max-height: 300px;
    overflow-y: auto;
}
.data-table-controls .col-toggle {
    flex-shrink: 0;
}
.cursor-pointer {
    cursor: pointer;
}

/* ============================================
   Autocomplete
   ============================================ */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-light);
    transition: background-color 0.2s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: var(--primary-light);
}

.autocomplete-item-name {
    font-weight: 500;
    color: var(--dark);
}

.autocomplete-item-phone {
    font-size: 0.875rem;
    color: var(--gray);
}

.autocomplete-add-new {
    background-color: var(--light);
    color: var(--primary);
    font-weight: 500;
}

.autocomplete-add-new:hover {
    background-color: var(--primary);
    color: var(--white);
}

/* ============================================
   Loading & Spinners
   ============================================ */
.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--gray-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--gray-light);
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--gray);
    margin-bottom: 1.5rem;
}

/* ============================================
   Utilities
   ============================================ */
.text-primary {
    color: var(--primary) !important;
}

.text-secondary {
    color: var(--secondary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.bg-secondary {
    background-color: var(--secondary) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.fw-500 {
    font-weight: 500 !important;
}

.fw-600 {
    font-weight: 600 !important;
}

.fs-sm {
    font-size: 0.875rem !important;
}

.fs-xs {
    font-size: 0.75rem !important;
}

/* ============================================
   Mobile Card List (replaces tables on small screens)
   ============================================ */

/* Hide table on mobile, show cards */
.table-desktop {
    display: block;
}
.mobile-card-list {
    display: none;
}

@media (max-width: 767.98px) {
    .table-desktop {
        display: none !important;
    }
    .mobile-card-list {
        display: block !important;
    }
}

.mobile-card-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-light);
    transition: background-color 0.15s ease;
}

.mobile-card-item:last-child {
    border-bottom: none;
}

.mobile-card-item:active {
    background-color: var(--primary-light);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.mobile-card-title {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.95rem;
}

.mobile-card-title a {
    color: var(--dark);
    text-decoration: none;
}

.mobile-card-title a:hover {
    color: var(--primary);
}

.mobile-card-amount {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
    white-space: nowrap;
    margin-left: 0.75rem;
}

.mobile-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--gray);
}

.mobile-card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.mobile-card-meta-item i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.mobile-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.625rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-light);
}

.mobile-card-actions .btn {
    flex: 1;
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
}

.mobile-card-label {
    color: var(--gray);
    font-size: 0.8rem;
    font-weight: 500;
}

.mobile-card-value {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--dark);
    text-align: right;
}

/* Collapsible details toggle */
.mobile-card-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--gray);
    font-size: 0.75rem;
    padding: 0.25rem 0;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    transition: color 0.2s ease;
}

.mobile-card-toggle:hover {
    color: var(--primary);
}

.mobile-card-toggle i {
    transition: transform 0.2s ease;
}

.mobile-card-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.mobile-card-details {
    padding-top: 0.25rem;
}

/* ============================================
   Mobile Filter Improvements
   ============================================ */
@media (max-width: 767.98px) {
    .filter-collapse-btn {
        display: flex !important;
    }
    .filter-body {
        display: none;
    }
    .filter-body.show {
        display: block;
    }
}

@media (min-width: 768px) {
    .filter-collapse-btn {
        display: none !important;
    }
    .filter-body {
        display: block !important;
    }
}

.filter-collapse-btn {
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    background: none;
    border: none;
    color: var(--dark);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

.filter-collapse-btn i {
    transition: transform 0.2s ease;
    color: var(--gray);
}

.filter-collapse-btn[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar,
    .mobile-header,
    .mobile-nav,
    .offcanvas,
    .offcanvas-backdrop,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-bottom: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }
}

/* ============================================
   Chat Quick Add
   ============================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
    max-width: 800px;
    margin: 0 auto;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--light);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

.chat-welcome {
    text-align: center;
    padding: 1.25rem 1rem;
    color: var(--gray);
}

.chat-welcome-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.chat-welcome-icon-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.chat-welcome-title {
    color: var(--dark);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.chat-welcome-examples {
    max-width: 420px;
    margin: 0 auto;
    text-align: left;
}

.chat-example-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
}

.chat-example-row:last-child {
    margin-bottom: 0;
}

.chat-example-label {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chat-example-label-sale {
    background: rgba(40, 167, 69, 0.15);
    color: #1e7e34;
}

.chat-example-label-stock {
    background: rgba(23, 162, 184, 0.15);
    color: #0c5460;
}

.chat-example-text {
    color: var(--gray);
    line-height: 1.4;
}

.chat-message {
    margin-bottom: 1rem;
}

.chat-message-bubble {
    display: inline-block;
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-message-user .chat-message-bubble {
    background: var(--primary);
    color: white;
    margin-left: auto;
    display: block;
}

.chat-message-ai .chat-message-bubble {
    background: white;
    border: 1px solid var(--gray-light);
    color: var(--dark);
}

.chat-message-ai .chat-receipt-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    pointer-events: auto;
}

.chat-message-ai .chat-receipt-link:hover {
    color: var(--primary);
    text-decoration: underline;
    opacity: 0.9;
}

/* Voice message bubble (WhatsApp-style) */
.chat-audio-bubble {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem !important;
    min-width: 140px;
}

.chat-audio-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.chat-audio-play:hover {
    background: rgba(255, 255, 255, 0.4);
}

.chat-audio-play i {
    font-size: 1.1rem;
}

.chat-audio-duration {
    font-size: 0.85rem;
    opacity: 0.95;
}

.chat-confirmation {
    margin-bottom: 1rem;
    animation: chat-confirm-slide 0.3s ease-out;
}

.chat-confirm-actions {
    flex-wrap: wrap;
}

.chat-confirm-actions .btn {
    flex: 1;
    min-width: 0;
}

.chat-confirm-actions .btn-icon-only {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-confirm-actions .btn-icon-only i {
    font-size: 1rem;
}

@media (max-width: 576px) {
    .chat-confirmation .card-body {
        padding: 0.75rem;
    }
    .chat-confirmation .table {
        font-size: 0.85rem;
    }
    .chat-confirmation .table th,
    .chat-confirmation .table td {
        padding: 0.35rem 0.5rem;
    }
}

@keyframes chat-confirm-slide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-input-area {
    flex-shrink: 0;
}

/* Toast notifications */
.chat-toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.chat-toast {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    max-width: 90vw;
}

.chat-toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-toast-success {
    background: var(--success);
    color: white;
}

.chat-toast-error {
    background: var(--danger);
    color: white;
}

.chat-toast-info {
    background: var(--info);
    color: white;
}

/* AI thinking indicator */
.chat-message-thinking .chat-message-bubble {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-thinking-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.chat-thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gray);
    animation: chat-thinking-bounce 1.4s ease-in-out infinite both;
}

.chat-thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.chat-thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.chat-thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes chat-thinking-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-thinking-text {
    color: var(--gray);
    font-size: 0.9rem;
}

.chat-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: #f0f2f5;
    border: none;
    border-radius: var(--radius-lg);
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    position: relative;
    background: white;
    border-radius: 24px;
    padding: 0.4rem 0.5rem 0.4rem 1rem;
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-input-row .chat-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    padding: 0.5rem 0;
}

.chat-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 1.25rem;
    font-size: 0.75rem;
    padding: 0 0.25rem;
}

.chat-retry-btn {
    font-size: 0.8rem;
}

.chat-product-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 0.25rem;
    max-height: 240px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.chat-product-suggestions .suggestion-header {
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray);
    background: var(--light);
    border-bottom: 1px solid var(--gray-light);
    position: sticky;
    top: 0;
    z-index: 1;
}

.chat-product-suggestions .suggestion-empty {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--gray);
    display: flex;
    align-items: center;
}

.chat-product-suggestions .suggestion-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-light);
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.chat-product-suggestions .suggestion-item:last-child {
    border-bottom: none;
}

.chat-product-suggestions .suggestion-item:hover,
.chat-product-suggestions .suggestion-item.suggestion-active {
    background: var(--primary-light);
    color: var(--primary);
}

.chat-product-suggestions .suggestion-item .suggestion-name {
    flex: 1;
    min-width: 0;
}

.chat-product-suggestions .suggestion-item .suggestion-price,
.chat-product-suggestions .suggestion-item .suggestion-meta {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.chat-product-suggestions .suggestion-item .suggestion-meta {
    font-weight: 400;
    color: var(--gray);
}

.chat-product-suggestions .suggestion-item:hover .suggestion-price,
.chat-product-suggestions .suggestion-item:hover .suggestion-meta,
.chat-product-suggestions .suggestion-item.suggestion-active .suggestion-price,
.chat-product-suggestions .suggestion-item.suggestion-active .suggestion-meta {
    color: inherit;
}

.chat-product-suggestions .suggestion-highlight {
    background: var(--secondary);
    color: var(--dark);
    padding: 0.05em 0.15em;
    border-radius: 2px;
    font-weight: 700;
}

.chat-product-suggestions .suggestion-item:hover .suggestion-highlight,
.chat-product-suggestions .suggestion-item.suggestion-active .suggestion-highlight {
    background: rgba(255, 255, 255, 0.5);
}

/* Sale form product autocomplete */
.product-autocomplete .product-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.15rem;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.product-autocomplete .product-suggestions .suggestion-empty {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--gray);
    display: flex;
    align-items: center;
}

.product-autocomplete .product-suggestions .suggestion-item {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-light);
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.product-autocomplete .product-suggestions .suggestion-item:last-child {
    border-bottom: none;
}

.product-autocomplete .product-suggestions .suggestion-item:hover,
.product-autocomplete .product-suggestions .suggestion-item.suggestion-active {
    background: var(--primary-light);
    color: var(--primary);
}

.product-autocomplete .product-suggestions .suggestion-item .suggestion-name {
    flex: 1;
    min-width: 0;
}

.product-autocomplete .product-suggestions .suggestion-item .suggestion-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.product-autocomplete .product-suggestions .suggestion-item:hover .suggestion-price,
.product-autocomplete .product-suggestions .suggestion-item.suggestion-active .suggestion-price {
    color: inherit;
}

.chat-input {
    flex: 1;
    border: none;
    resize: none;
    min-height: 1.5em;
    max-height: 6em;
    overflow-y: auto;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
}

.chat-input:focus {
    box-shadow: none;
    outline: none;
}

.btn-chat-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-chat-action:hover:not(:disabled) {
    background: #2d4263;
    color: white;
    transform: scale(1.02);
}

.btn-chat-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-chat-action i {
    font-size: 1.2rem;
}

.btn-chat-action.recording {
    background: var(--danger);
    color: white;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Chat Conversations (Admin view) */
.chat-conv-card .card-header {
    cursor: pointer;
}
.chat-conv-card .card-header:hover {
    background: var(--light);
}
.chat-conv-msg {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: var(--light);
}
.chat-conv-msg-user {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}
.chat-conv-msg-ai {
    background: white;
    border: 1px solid var(--gray-light);
    border-left: 3px solid var(--info);
}
.chat-conv-msg-role {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray);
    display: block;
    margin-bottom: 0.25rem;
}
.chat-conv-msg-content {
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-conv-msg-time {
    font-size: 0.75rem;
    display: block;
    margin-top: 0.25rem;
}
.chat-conv-messages {
    max-height: 400px;
    overflow-y: auto;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

/* POS Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.product-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    background: white;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.product-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.product-name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.product-price {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
}

.cart-items {
    max-height: 300px;
    overflow-y: auto;
}

.cart-item {
    font-size: 0.9rem;
}

/* ============================================
   Page Navigation Progress Bar
   ============================================ */
#pageNavLoader {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    z-index: 99999;
    background: linear-gradient(to right, var(--primary), var(--secondary), var(--primary));
    background-size: 200% 100%;
    transform: scaleX(0);
    transform-origin: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#pageNavLoader.nav-loading {
    opacity: 1;
    animation: navLoaderProgress 1.8s ease-out forwards,
               navLoaderShimmer 1.2s linear infinite;
}

@keyframes navLoaderProgress {
    0%   { transform: scaleX(0); }
    20%  { transform: scaleX(0.4); }
    60%  { transform: scaleX(0.7); }
    100% { transform: scaleX(0.92); }
}

@keyframes navLoaderShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Chat Container — Mobile Height Fix
   Accounts for mobile header (56px) + bottom nav (70px)
   ============================================ */
@media (max-width: 991.98px) {
    .chat-container {
        height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - 100px);
        min-height: 280px;
    }
}

/* ============================================
   Dashboard — Mobile Improvements
   ============================================ */

/* Period filter: single-row horizontal scroll instead of wrapping */
.period-filter-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
    flex-wrap: nowrap;
}
.period-filter-scroll::-webkit-scrollbar { display: none; }
.period-filter-scroll .btn { white-space: nowrap; flex-shrink: 0; }

/* Stat cards: tighter on phones so the icon doesn't overlap the value */
@media (max-width: 575.98px) {
    .stat-card .card-body { padding: 0.85rem 0.9rem; }
    .stat-card .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.05rem;
        right: 0.5rem;
    }
    .stat-card .stat-value,
    .stat-card .stat-label,
    .stat-card .stat-sublabel {
        padding-right: 50px;   /* keep text clear of the icon */
    }
    .stat-card .stat-value  { font-size: 0.9rem !important; }
    .stat-card .stat-label  { font-size: 0.75rem; }
    .stat-card .stat-sublabel { font-size: 0.68rem; }
}

/* Dashboard page-header action buttons: compact on phones */
@media (max-width: 575.98px) {
    .dashboard-header-actions { flex-wrap: wrap; gap: 0.35rem !important; }
    .dashboard-header-actions .btn { font-size: 0.78rem; padding: 0.3rem 0.55rem; }
    .dashboard-header-actions .btn .btn-text { display: none; }
}
