/* assets/css/style.css - Mobile-First Clean Minimalist Theme for Surya Silk & Handlooms */

:root {
    --primary: #4f46e5;         /* Royal Silk Indigo */
    --primary-dark: #3730a3;
    --primary-light: #e0e7ff;
    --accent: #d97706;          /* Zari Gold */
    --accent-light: #fef3c7;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #ea580c;
    --warning-light: #ffedd5;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;    /* Unified Box Border */
    --border-dark: #cbd5e1;
    --nav-height: 64px;
    --bottom-bar-height: 68px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-card: 0 4px 12px rgba(15, 23, 42, 0.04);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    padding-bottom: calc(var(--bottom-bar-height) + 24px);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
    50% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); }
}

.animate-fade-in {
    animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pulse-badge {
    animation: pulseGlow 2s infinite;
}

/* ========================================================
   UNIFIED BOX BORDER SYSTEM FOR ALL PAGES & TABLES
   ======================================================== */

/* 1. Main Outer Box Wrapper */
.box-table-wrapper {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1.25rem;
}

.box-table-header {
    padding: 0.85rem 1.15rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* 2. Structured Box Grid Table (Cell Borders) */
.table-box-grid {
    width: 100% !important;
    margin-bottom: 0 !important;
    border-collapse: collapse !important;
    border: 1px solid var(--border-color) !important;
    background-color: #ffffff;
}

.table-box-grid thead th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    font-weight: 700 !important;
    border: 1px solid var(--border-color) !important;
    border-bottom: 2px solid var(--border-dark) !important;
    padding: 11px 14px !important;
    white-space: nowrap;
}

.table-box-grid tbody td {
    padding: 11px 14px !important;
    border: 1px solid var(--border-color) !important;
    vertical-align: middle !important;
    font-size: 0.88rem !important;
    color: var(--text-primary);
}

.table-box-grid tbody tr:hover td {
    background-color: #f8fafc !important;
}

.table-box-grid tfoot th,
.table-box-grid tfoot td {
    background-color: #f8fafc !important;
    border: 1px solid var(--border-color) !important;
    padding: 11px 14px !important;
}

/* Header & Top Bar */
.app-header {
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
    transition: all 0.2s ease;
}

.brand-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.25rem;
    box-shadow: 0 3px 8px rgba(79, 70, 229, 0.25);
    flex-shrink: 0;
}

.brand-logo-img {
    height: 38px;
    max-width: 130px;
    object-fit: contain;
    border-radius: 6px;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-bar-height);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

@media (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0 8px;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    flex: 1;
    padding: 6px 0;
    transition: all 0.2s ease;
    position: relative;
}

.bottom-nav-item i {
    font-size: 1.35rem;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
}

.bottom-nav-item.active {
    color: var(--primary);
    font-weight: 700;
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

/* Clean Cards */
.card-clean {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s ease;
}

.card-clean:hover {
    border-color: var(--border-dark);
}

/* Stat Cards with Box Borders */
.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-dark);
}

.stat-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Mobile Data Table Cards */
.mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.table-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.95rem 1.15rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: all 0.2s ease;
    position: relative;
}

.table-card:hover {
    border-color: var(--border-dark);
}

.table-card.is-overdue {
    border-left: 4px solid #dc2626 !important;
    background: linear-gradient(to right, #fff5f5 0%, #ffffff 40px);
}

.table-card.is-due-today {
    border-left: 4px solid #ea580c !important;
    background: linear-gradient(to right, #fffaf0 0%, #ffffff 40px);
}

.table-card.is-due-soon {
    border-left: 4px solid #f59e0b !important;
    background: linear-gradient(to right, #fffdf0 0%, #ffffff 30px);
}

.table-card.is-paid {
    border-left: 4px solid #10b981 !important;
}

/* Enhanced Invoice List Card for sales/index.php */
.invoice-matrix-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0;
}

.invoice-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 8px;
}

.invoice-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.table-card-col.table-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: calc(var(--bs-gutter-x) * 0.5) !important;
}

/* Saree Catalog Card for sarees/index.php */
.saree-catalog-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.15rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    position: relative;
}

.saree-catalog-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 20px -4px rgba(0,0,0,0.07);
    transform: translateY(-2px);
}

.saree-price-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 10px 0;
}

.color-dot-indicator {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.18);
    vertical-align: middle;
    margin-right: 5px;
}

/* Search & Filter Bar */
.search-filter-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    box-shadow: var(--shadow-soft);
}

.pill-filter-scroll {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.pill-filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 9999px;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Urgent Alert Banner */
.alert-banner-urgent {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: var(--radius-md);
    padding: 0.95rem 1.25rem;
    color: #991b1b;
}

/* WhatsApp Reminder Button */
.btn-whatsapp {
    background: #25d366;
    color: #ffffff;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.btn-whatsapp:hover {
    background: #1ebc59;
    color: #ffffff;
}

/* Floating Action Button (FAB) */
.fab-btn {
    position: fixed;
    right: 20px;
    bottom: calc(var(--bottom-bar-height) + 16px);
    width: 52px;
    height: 52px;
    border-radius: 26px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
    z-index: 1010;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.fab-btn:hover {
    transform: scale(1.05);
    color: #ffffff;
}

@media (min-width: 992px) {
    .fab-btn {
        bottom: 28px;
    }
}

/* Payment Term Selector Cards */
.term-selector-card {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    background: #ffffff;
    position: relative;
}

.term-selector-card:hover {
    border-color: #a5b4fc;
}

.term-selector-card.selected {
    border-color: var(--primary);
    background: #f5f3ff;
}

/* Mobile friendly forms */
.form-control-clean {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 0.7rem 0.95rem;
    font-size: 0.92rem;
    transition: border-color 0.15s ease;
}

.form-control-clean:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    outline: none;
}

/* ========================================================
   SELECT2 CUSTOM STYLING (MATCHING BOX BORDER)
   ======================================================== */
.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    min-height: 44px !important;
    padding: 0.4rem 0.85rem !important;
    font-size: 0.92rem !important;
    display: flex !important;
    align-items: center !important;
    background-color: #ffffff !important;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12) !important;
}

.select2-dropdown {
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-card) !important;
    overflow: hidden !important;
    z-index: 1065 !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown {
    padding: 8px 10px !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    border-radius: 6px !important;
    border: 1px solid var(--border-color) !important;
    padding: 6px 10px !important;
    font-size: 0.88rem !important;
}

.select2-container--bootstrap-5 .select2-results__option {
    padding: 8px 12px !important;
    font-size: 0.88rem !important;
    border-bottom: 1px solid #f8fafc !important;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

/* Compact Select2 for small dropdowns & Order By filters */
.form-select-sm + .select2-container--bootstrap-5 .select2-selection,
.sort-order-select + .select2-container--bootstrap-5 .select2-selection {
    min-height: 36px !important;
    height: 36px !important;
    padding: 0.15rem 0.65rem !important;
    font-size: 0.82rem !important;
    border-radius: 8px !important;
}

.sort-order-select + .select2-container--bootstrap-5 {
    min-width: 180px !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary) !important;
    padding-left: 0 !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
    margin-right: 1.5rem !important;
}

/* ========================================================
   DATATABLES BOX BORDER INTEGRATION
   ======================================================== */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_length {
    padding: 10px 14px 0 14px;
}

.dataTables_wrapper .dataTables_filter {
    padding: 10px 14px 0 14px;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.82rem;
    margin: 0 4px;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.85rem;
    margin-left: 8px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    outline: none;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 12px 14px;
}

.dataTables_wrapper .dataTables_paginate {
    padding: 8px 14px 12px 14px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    margin: 0 2px !important;
    border: 1px solid var(--border-color) !important;
    background: #ffffff !important;
    font-size: 0.82rem !important;
    padding: 4px 10px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

/* View Mode Toggler (Cards vs Full Table) */
.view-mode-toggle {
    display: inline-flex;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 2px;
    border-radius: 8px;
}

.view-mode-btn {
    border: none;
    background: transparent;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.view-mode-btn.active {
    background: #ffffff;
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Print/Receipt view */
@media print {
    .app-header,
    .mobile-bottom-nav,
    .no-print,
    .fab-btn {
        display: none !important;
    }
    body {
        padding: 0 !important;
        background: #ffffff !important;
    }
    .print-receipt {
        max-width: 100% !important;
        border: none !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   PROMINENT DUE DATE TYPOGRAPHY & BADGE SYSTEM
   ========================================================================== */

/* High-Contrast Badge Utilities for Due & Status Badges */
.bg-rose-100 { background-color: #fee2e2 !important; }
.text-rose-800 { color: #991b1b !important; font-weight: 700 !important; }
.border-rose-300 { border-color: #fca5a5 !important; }

.bg-amber-100 { background-color: #fef3c7 !important; }
.text-amber-900 { color: #78350f !important; font-weight: 700 !important; }
.text-amber-800 { color: #92400e !important; font-weight: 700 !important; }
.border-amber-400 { border-color: #fbbf24 !important; }
.border-amber-300 { border-color: #fcd34d !important; }
.bg-amber-50 { background-color: #fffbeb !important; }

.bg-blue-50 { background-color: #eff6ff !important; }
.text-blue-700 { color: #1d4ed8 !important; font-weight: 700 !important; }
.border-blue-200 { border-color: #bfdbfe !important; }

.bg-emerald-100 { background-color: #d1fae5 !important; }
.text-emerald-800 { color: #065f46 !important; font-weight: 700 !important; }
.border-emerald-300 { border-color: #6ee7b7 !important; }

.bg-sky-100 { background-color: #e0f2fe !important; }
.text-sky-800 { color: #075985 !important; font-weight: 700 !important; }
.border-sky-300 { border-color: #7dd3fc !important; }

.bg-indigo-100 { background-color: #e0e7ff !important; }
.text-indigo-800 { color: #3730a3 !important; font-weight: 700 !important; }
.border-indigo-300 { border-color: #a5b4fc !important; }

.bg-purple-100 { background-color: #f3e8ff !important; }
.text-purple-800 { color: #6b21a8 !important; font-weight: 700 !important; }
.border-purple-300 { border-color: #d8b4fe !important; }

/* Dedicated Due Date Strip on Mobile Cards */
.due-date-strip {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.due-date-strip .bill-date-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #475569;
}

.due-date-strip .bill-date-box strong {
    color: #1e293b;
    font-weight: 600;
}

.due-date-strip .due-highlight-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
}

.due-date-strip .due-highlight-box .due-label-text {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.due-date-strip .due-highlight-box .due-date-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.01em;
}

/* Overdue State: High-contrast Alert Red */
.due-date-strip.overdue {
    background: #fff5f5;
    border-color: #fca5a5;
}
.due-date-strip.overdue .due-highlight-box {
    background: #fee2e2;
    border-color: #f87171;
}
.due-date-strip.overdue .due-highlight-box .due-label-text {
    color: #991b1b;
}
.due-date-strip.overdue .due-highlight-box .due-date-value {
    color: #b91c1c;
    font-size: 0.95rem;
    font-weight: 800;
}

/* Due Today State: High-contrast Amber Alert */
.due-date-strip.due_today {
    background: #fffbeb;
    border-color: #fcd34d;
}
.due-date-strip.due_today .due-highlight-box {
    background: #fef3c7;
    border-color: #f59e0b;
}
.due-date-strip.due_today .due-highlight-box .due-label-text {
    color: #92400e;
}
.due-date-strip.due_today .due-highlight-box .due-date-value {
    color: #b45309;
    font-size: 0.95rem;
    font-weight: 800;
}

/* Due Soon (within 7 days) State */
.due-date-strip.due_soon {
    background: #fff7ed;
    border-color: #fed7aa;
}
.due-date-strip.due_soon .due-highlight-box {
    background: #ffedd5;
    border-color: #fb923c;
}
.due-date-strip.due_soon .due-highlight-box .due-label-text {
    color: #9a3412;
}
.due-date-strip.due_soon .due-highlight-box .due-date-value {
    color: #ea580c;
    font-weight: 700;
}

/* Paid / Settled State */
.due-date-strip.paid {
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.due-date-strip.paid .due-highlight-box {
    background: #dcfce7;
    border-color: #86efac;
}
.due-date-strip.paid .due-highlight-box .due-label-text {
    color: #166534;
}
.due-date-strip.paid .due-highlight-box .due-date-value {
    color: #15803d;
    font-weight: 700;
}

/* Due Date Display in DataTables Grid */
.due-date-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.due-date-cell .due-date-font {
    font-size: 0.90rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
}

.due-date-cell.overdue {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.due-date-cell.due_today {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.due-date-cell.due_soon {
    background: #ffedd5;
    color: #c2410c;
    border: 1px solid #fdba74;
}

.due-date-cell.upcoming {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

.due-date-cell.paid {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}
