/* ===== BKH Sales Reports - Modern Professional Theme ===== */

/* --- CSS Variables --- */
:root {
    --primary: #1a1f36;
    --primary-light: #2d3250;
    --accent: #e74c3c;
    --accent-hover: #c0392b;
    --accent-light: rgba(231, 76, 60, 0.08);
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1a1f36;
    --text-secondary: #5a607f;
    --text-muted: #8c92ab;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --info: #3b82f6;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger-bg: #fef2f2;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* --- Global --- */
* { box-sizing: border-box; }

body {
    background: var(--bg);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent);
    color: #fff;
}

/* --- Navbar --- */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 0.6rem 0;
    border-bottom: 3px solid var(--accent);
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
}

.navbar-brand i {
    font-size: 1.3rem;
    color: var(--accent);
}

.navbar .btn-outline-light {
    border-color: rgba(255,255,255,0.25);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.navbar .btn-outline-light:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

/* --- Cards --- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--card-bg);
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* --- Section Cards (Dashboard) --- */
.section-card {
    border: none;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.section-card:hover {
    transform: none;
    box-shadow: var(--shadow-md);
}

.section-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
    border: none;
    padding: 0.65rem 1rem;
    transition: opacity 0.2s;
}

.section-card .card-header:hover {
    opacity: 0.95;
}

.section-card .card-header h6 {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #fff;
}

.section-card .card-body {
    background: var(--border-light);
}

/* --- Report Cards --- */
.report-card {
    cursor: pointer;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm) !important;
    background: #fff;
    transition: all 0.2s ease;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--accent-hover);
}

.report-card .report-number {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

.report-card .card-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.3;
}

.report-card .card-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 2px 0 4px;
    line-height: 1.4;
}

.report-card .badge {
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* --- Filter Bar --- */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.filter-bar label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.filter-bar select,
.filter-bar .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-bar select:focus,
.filter-bar .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.12);
}

/* --- Fixed Filter Badges --- */
.fixed-filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eff6ff;
    color: #1e40af;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #bfdbfe;
}

/* --- Stat Badges --- */
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.82rem;
}

.stat-badge.total {
    background: var(--success-bg);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* --- Tables --- */
table.dataTable,
.table {
    font-size: 0.88rem;
}

table.dataTable thead th,
.table thead th {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    border: none;
    white-space: nowrap;
    padding: 0.65rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-striped > tbody > tr:nth-of-type(odd) > td {
    background: #fafbfd;
}

.table-hover > tbody > tr:hover > td {
    background: var(--accent-light);
}

.total-row {
    font-weight: 700;
    background: linear-gradient(90deg, #f0fdf4, #ecfdf5) !important;
    font-size: 0.95rem;
    border-top: 2px solid var(--success);
}

.total-row td {
    background: inherit !important;
    padding: 0.7rem 0.75rem;
}

/* --- Buttons --- */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-size: 0.85rem;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-danger,
.btn-danger:hover {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    color: #fff;
}

.btn-warning:hover { color: #fff; }

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    background: linear-gradient(135deg, #fafbfc 0%, #f5f6fa 100%);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: linear-gradient(135deg, #fff5f5 0%, #fef2f2 100%);
    transform: scale(1.01);
}

.upload-zone .icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    transition: color 0.3s;
}

.upload-zone:hover .icon {
    color: var(--accent);
}

.upload-zone h5 {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

/* --- Import Progress --- */
.import-progress {
    display: none;
}

.import-progress.active {
    display: block;
}

/* --- Upload History --- */
.upload-list .list-group-item {
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    transition: all 0.2s;
    padding: 0.75rem 1rem;
}

.upload-list .list-group-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* --- Breadcrumb --- */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* --- Form Controls --- */
.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    padding: 0.5rem 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

/* --- Alerts --- */
.alert {
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    border: none;
}

.alert-success { background: #ecfdf5; color: #065f46; border-left: 4px solid #10b981; }
.alert-danger { background: #fef2f2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }
.alert-info { background: #eff6ff; color: #1e40af; border-left: 4px solid #3b82f6; }

/* --- Modals --- */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    border-bottom: none;
    padding: 0.85rem 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 1.25rem;
}

/* Report Modal */
#reportModal .modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
}

#reportModal .modal-header .btn-close { filter: invert(1); }

#reportModal .modal-header .btn-outline-secondary {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
}

#reportModal .modal-header .btn-outline-secondary:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.5);
}

#reportModal .modal-header .btn-outline-secondary:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

#reportModal .modal-body {
    padding: 1.5rem;
    max-height: 80vh;
}

#reportModal .filter-bar {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
}

#reportModal .table-responsive {
    max-height: 55vh;
    overflow-y: auto;
}

/* Budget Modal */
#budgetModal .modal-header {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
}

#budgetModal .modal-header .btn-close { filter: invert(1); }

/* Edit Modal (Budget) */
#editModal .modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
}

/* --- Budget Page --- */
.budget-cell {
    cursor: pointer;
    transition: all 0.15s;
}

.budget-cell:hover {
    background: var(--warning-bg) !important;
    box-shadow: inset 0 0 0 2px var(--warning);
}

.month-header {
    writing-mode: horizontal-tb;
    white-space: nowrap;
    font-size: 0.78rem;
}

.budget-total {
    font-weight: 700;
    background: var(--success-bg) !important;
}

/* --- DataTables Overrides --- */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
    outline: none;
}

.dataTables_wrapper .dataTables_filter label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Code Tags (Expected Columns) --- */
code {
    background: #f1f5f9;
    color: #be185d;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

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

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

.empty-state i {
    font-size: 3.5rem;
    color: var(--border);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Page Header --- */
.page-header {
    margin-bottom: 0.25rem;
}

.page-header h4 {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

/* --- Spinner Override --- */
.spinner-border {
    width: 2rem;
    height: 2rem;
}

/* --- Responsive --- */
@media (max-width: 991px) {
    .filter-bar {
        padding: 0.75rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    body { font-size: 0.9rem; }

    .upload-zone { padding: 1.5rem; }

    .filter-bar {
        padding: 0.65rem;
        flex-direction: column;
        align-items: stretch !important;
    }

    .filter-bar .d-flex { flex-wrap: wrap; }

    .section-card .card-header h6 { font-size: 0.82rem; }

    #reportModal .modal-dialog,
    #budgetModal .modal-dialog {
        margin: 0.5rem;
    }

    #reportModal .modal-body,
    #budgetModal .modal-body {
        padding: 1rem;
    }

    .report-card { padding: 0.5rem !important; }
}

@media (max-width: 576px) {
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }
    .stat-badge { font-size: 0.75rem; padding: 4px 10px; }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-card { animation: fadeInUp 0.4s ease both; }
.section-card:nth-child(2) { animation-delay: 0.05s; }
.section-card:nth-child(3) { animation-delay: 0.1s; }
.section-card:nth-child(4) { animation-delay: 0.15s; }
.section-card:nth-child(5) { animation-delay: 0.2s; }

.modal.show .modal-dialog {
    animation: fadeInUp 0.25s ease;
}

/* --- Delivery Comparison Table (Reports 100/101) --- */
.delivery-comparison-table {
    border-collapse: collapse;
    white-space: nowrap;
}

.delivery-comparison-table .delivery-comp-header th {
    background: #F5C518;
    color: #1a1a1a;
    font-weight: 700;
    font-size: 0.78rem;
    text-align: center;
    padding: 8px 10px;
    border: 1px solid #d4a017;
    vertical-align: middle;
}

.delivery-comparison-table .delivery-comp-header th:first-child {
    background: #F5C518;
    text-align: left;
}

.delivery-comparison-table tbody td {
    padding: 7px 10px;
    border: 1px solid #e5e7eb;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
}

.delivery-comparison-table tbody td:first-child {
    background: #fafafa;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
}

.delivery-comparison-table tbody td:nth-child(2) {
    background: #f9fafb;
    font-weight: 700;
}

.delivery-comparison-table tbody tr:hover {
    background: rgba(245, 197, 24, 0.08);
}

.delivery-comparison-table tbody tr.delivery-comp-highlight td {
    background: #FEF9C3;
    font-weight: 600;
}

.delivery-comparison-table tbody tr.delivery-comp-highlight td:first-child {
    background: #FDE68A;
    font-weight: 700;
}

.delivery-comparison-table tbody tr.delivery-comp-highlight:hover td {
    background: #FDE68A;
}
