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

/* ============================================
   CSS Variables (Theme Colors)
   ============================================ */
:root {
    /* Primary Colors */
    --primary: #A7181C;
    --primary-hover: #8a1417;
    --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;
    min-width: 0;
    max-width: 100%;
    margin-left: 0;
    padding-bottom: var(--mobile-nav-height);
    overflow-x: clip;
}

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

.page-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    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;
}

.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-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-sms-credits {
    margin: 0 0.75rem 0.75rem;
}

.sidebar-sms-credits-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--dark-text);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

a.sidebar-sms-credits-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
    color: var(--white);
}

.sidebar-sms-credits-card.active {
    background: rgba(var(--primary-rgb), 0.18);
    border-color: rgba(var(--primary-rgb), 0.35);
}

.sidebar-sms-credits.is-low .sidebar-sms-credits-card {
    background: rgba(255, 193, 7, 0.12);
    border-color: rgba(255, 193, 7, 0.28);
}

.sidebar-sms-credits.is-low .sidebar-sms-credits-value {
    color: #ffc107;
}

.sidebar-sms-credits-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(var(--primary-rgb), 0.2);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-sms-credits-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-sms-credits-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--dark-muted);
}

.sidebar-sms-credits-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--white);
}

.sidebar-sms-credits-action {
    color: var(--dark-muted);
    font-size: 1.125rem;
}

a.sidebar-sms-credits-card:hover .sidebar-sms-credits-action {
    color: var(--white);
}

.sidebar-sms-credits-hint {
    margin-top: 0.35rem;
    padding: 0 0.25rem;
    font-size: 0.6875rem;
    color: #ffc107;
}

.offcanvas-sms-credits {
    padding: 0.5rem 0.75rem 0.25rem;
}

.offcanvas-sms-credits-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    background: rgba(var(--primary-rgb), 0.08);
    color: inherit;
    text-decoration: none;
}

.offcanvas-sms-credits.is-low .offcanvas-sms-credits-link {
    background: rgba(255, 193, 7, 0.12);
}

.offcanvas-sms-credits-badge {
    margin-left: auto;
    font-weight: 700;
    font-size: 0.9375rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
}

.offcanvas-sms-credits.is-low .offcanvas-sms-credits-badge {
    background: #ffc107;
    color: #212529;
}

.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 {
    font-size: 1.25rem;
}

.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 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-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);
    overflow: hidden;
}

.brand-logo-img {
    max-height: 32px;
    max-width: 120px;
    object-fit: contain;
    display: block;
}

.brand-logo-wrap {
    background: transparent !important;
}

.login-logo .brand-logo-img {
    max-height: 48px;
    max-width: 140px;
}

.mobile-brand .brand-logo-img {
    max-height: 28px;
    max-width: 80px;
}

.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);
}

/* ============================================
   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-page-header {
    align-items: center;
}

.chat-shell {
    max-width: 960px;
    margin: 0 auto;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 168px);
    min-height: 560px;
    overflow: hidden;
    background:
        linear-gradient(rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.82)),
        radial-gradient(circle at 20% 20%, rgba(var(--primary-rgb), 0.07) 0 2px, transparent 2px 18px),
        #efeae2;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.chat-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: var(--white);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.chat-profile-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    font-size: 1.15rem;
}

.chat-profile-title {
    color: var(--dark);
    font-weight: 700;
    line-height: 1.15;
}

.chat-profile-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--gray);
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(58vw, 520px);
}

.chat-profile-status.busy .status-dot {
    background: var(--warning);
}

.chat-profile-status.error .status-dot {
    background: var(--danger);
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    flex: 0 0 0.5rem;
    border-radius: 50%;
    background: var(--success);
}

.chat-toolbar-action {
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.chat-welcome {
    max-width: 680px;
    margin: 1.25rem auto;
    text-align: center;
    padding: 1.4rem;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-lg);
    color: var(--gray);
}

.chat-welcome-icon {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    margin-bottom: 0.8rem;
    border-radius: 50%;
    background: rgba(40, 167, 69, 0.12);
    font-size: 1.7rem;
}

.chat-welcome h5 {
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.chat-example-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chat-example-chip {
    max-width: 100%;
    border: 1px solid rgba(var(--primary-rgb), 0.18);
    background: var(--white);
    color: var(--dark);
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    font-size: 0.84rem;
    line-height: 1.25;
    transition: all 0.2s ease;
}

.chat-example-chip:hover,
.chat-example-chip:focus {
    background: var(--primary-light);
    border-color: rgba(var(--primary-rgb), 0.38);
    color: var(--primary);
}

.chat-message {
    display: flex;
    margin-bottom: 0.75rem;
}

.chat-message-user {
    justify-content: flex-end;
}

.chat-message-ai {
    justify-content: flex-start;
}

.chat-message-bubble {
    position: relative;
    max-width: min(86%, 620px);
    padding: 0.7rem 0.8rem 1.35rem;
    border-radius: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.chat-message-user .chat-message-bubble {
    background: #d9fdd3;
    color: var(--dark);
    border-top-right-radius: 4px;
}

.chat-message-ai .chat-message-bubble {
    background: white;
    color: var(--dark);
    border-top-left-radius: 4px;
}

.chat-message-time {
    position: absolute;
    right: 0.65rem;
    bottom: 0.35rem;
    color: rgba(0, 0, 0, 0.46);
    font-size: 0.72rem;
    line-height: 1;
}

.chat-result-card {
    min-width: min(460px, 74vw);
}

.chat-result-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.65rem;
}

.chat-result-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    margin: 0;
}

.chat-result-card dl div {
    min-width: 0;
    padding: 0.55rem;
    background: var(--light);
    border-radius: var(--radius);
}

.chat-result-card dt {
    color: var(--gray);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.chat-result-card dd {
    margin: 0.1rem 0 0;
    color: var(--dark);
    font-weight: 700;
}

.chat-result-note {
    color: var(--gray);
    font-size: 0.85rem;
    margin-top: 0.65rem;
}

.chat-confirmation {
    flex-shrink: 0;
    margin: 0 1rem 0.85rem;
    overflow: hidden;
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.chat-confirmation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.08), rgba(251, 201, 8, 0.12));
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.confirmation-kicker {
    display: block;
    color: var(--gray);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-confirmation-header h2 {
    margin: 0.1rem 0 0;
    color: var(--dark);
    font-size: 1.15rem;
    font-weight: 800;
}

.confidence-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    border-radius: 999px;
    padding: 0.38rem 0.65rem;
    background: var(--light);
    color: var(--gray);
    font-size: 0.82rem;
    font-weight: 700;
}

.confidence-pill.good {
    background: rgba(40, 167, 69, 0.12);
    color: #137333;
}

.confidence-pill.warn {
    background: rgba(255, 193, 7, 0.18);
    color: #8a6500;
}

.confidence-pill.bad {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.chat-confirmation-body {
    padding: 1rem;
}

.chat-missing-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    background: rgba(255, 193, 7, 0.12);
    color: #7a5800;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-missing-list.is-info {
    background: rgba(23, 162, 184, 0.1);
    color: #0c6674;
}

.chat-save-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.chat-save-options .form-check {
    margin: 0;
}

.chat-confirmation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chat-input-area {
    position: relative;
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    background: #f0f2f5;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.8rem 1.1rem;
    background: white;
    border-radius: 22px;
    border: 1px solid transparent;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(var(--primary-rgb), 0.25);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

.chat-input {
    border: none;
    resize: none;
    min-height: 34px;
    max-height: 120px;
    padding: 0.2rem 0;
    line-height: 1.45;
    overflow-y: auto;
}

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

.chat-input-meta {
    position: absolute;
    left: 0.8rem;
    right: 0.8rem;
    bottom: 0.18rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--gray);
    font-size: 0.7rem;
    line-height: 1;
    pointer-events: none;
}

.chat-input-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--gray-light);
    background: white;
    color: var(--gray);
    transition: all 0.2s ease;
}

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

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

.recording-banner {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 5.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: var(--danger);
    color: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 700;
    z-index: 2;
}

.recording-pulse {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--white);
    animation: pulse-recording 1.1s ease-in-out infinite;
}

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

.btn-send {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

@media (max-width: 767.98px) {
    .chat-page-header {
        gap: 0.75rem;
    }

    .chat-page-header .btn {
        padding-inline: 0.6rem;
    }

    .chat-container {
        height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - 106px);
        min-height: 520px;
        border-radius: 0;
        margin-inline: -1rem;
        border-left: 0;
        border-right: 0;
    }

    .chat-toolbar {
        padding: 0.65rem 0.8rem;
    }

    .chat-profile-avatar {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .chat-profile-title {
        font-size: 0.95rem;
    }

    .chat-profile-status {
        max-width: 52vw;
        font-size: 0.75rem;
    }

    .chat-toolbar-action {
        width: 38px;
        height: 38px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .chat-toolbar-action .me-1,
    .chat-toolbar-action {
        font-size: 0;
    }

    .chat-toolbar-action i {
        margin: 0 !important;
        font-size: 1rem;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .chat-welcome {
        padding: 1rem;
    }

    .chat-message-bubble {
        max-width: 92%;
    }

    .chat-result-card {
        min-width: 0;
    }

    .chat-result-card dl {
        grid-template-columns: 1fr;
    }

    .chat-confirmation {
        max-height: 50vh;
        overflow-y: auto;
        margin: 0 0.75rem 0.65rem;
    }

    .chat-confirmation-header,
    .chat-confirmation-body {
        padding: 0.85rem;
    }

    .chat-confirmation-actions .btn {
        flex: 1 1 100%;
    }

    .chat-input-area {
        padding: 0.55rem;
    }

    .chat-input-meta #chatHint {
        display: none;
    }
}
