/* Tax Management System — main styles */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --bottom-nav-height: 60px;
}

/* ── Base ── */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f2f5;
    -webkit-tap-highlight-color: transparent;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Cards ── */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    border-radius: .5rem;
}
.card-header {
    background-color: var(--light-color);
    border-bottom: 1px solid rgba(0,0,0,.1);
    border-radius: .5rem .5rem 0 0 !important;
}

/* ── Navbar ── */
.navbar {
    flex-shrink: 0;
    z-index: 1030;
}
.navbar-brand { font-weight: 600; }
.navbar-nav .nav-link { font-weight: 500; }

/* ── Tables ── */
.table-hover tbody tr:hover { background-color: rgba(0,123,255,.05); }
/* Allow Bootstrap dropdowns inside table-responsive to render properly */
.table-responsive { overflow-x: auto; }
.table-responsive > .table { margin-bottom: 0; }

/* Fix dropdown menus being clipped by scrollable parents */
.table-responsive .dropdown-menu {
    z-index: 1055;
}
.card-body .dropdown-menu {
    z-index: 1055;
}

/* ── Badges / buttons ── */
.badge { font-weight: 500; }
.btn { border-radius: .375rem; font-weight: 500; }
.btn-xs { padding: .15rem .4rem; font-size: .75rem; }

/* ── Progress ── */
.progress { border-radius: 10px; background-color: #e9ecef; }
.progress-bar { border-radius: 10px; }

/* ── Forms ── */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 .2rem rgba(0,123,255,.25);
}

/* ── Modal ── */
.modal-backdrop { --bs-backdrop-opacity: .35; }
.modal-backdrop, .modal-backdrop.show { opacity: .35 !important; background-color: #000 !important; }
.modal-content { border: none; border-radius: .5rem; box-shadow: 0 10px 25px rgba(0,0,0,.1); }
.modal-header { border-bottom: 1px solid rgba(0,0,0,.1); background-color: var(--light-color); border-radius: .5rem .5rem 0 0; }
.modal-dialog-scrollable .modal-content { max-height: 100%; }
.modal-dialog-scrollable .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── Alerts ── */
.alert { border: none; border-radius: .5rem; }

/* ── Charts ── */
canvas { max-height: 300px !important; }

/* ── Status colors ── */
.bg-pending    { background-color: var(--warning-color) !important; }
.bg-in_progress{ background-color: var(--info-color) !important; }
.bg-review     { background-color: var(--primary-color) !important; }
.bg-completed  { background-color: var(--success-color) !important; }
.bg-on_hold    { background-color: var(--secondary-color) !important; }

/* ── Stat cards (colored) ── */
.card.bg-primary .card-body,
.card.bg-success .card-body,
.card.bg-warning .card-body,
.card.bg-info    .card-body,
.card.bg-danger  .card-body { padding: 1.25rem; }

/* ── Dashboard ── */
.dashboard-action-strip {
    display: flex;
    align-items: stretch;
    gap: .5rem;
    padding: .5rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.06);
}
.dashboard-action-item {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-height: 38px;
    padding: .35rem .65rem;
    color: #343a40;
    text-decoration: none;
    background: #f8f9fa;
    border-radius: .375rem;
    white-space: nowrap;
}
.dashboard-action-item:hover { color: #0d6efd; background: #eef5ff; }
.dashboard-action-danger {
    color: #842029;
    background: #f8d7da;
}
.dashboard-action-danger:hover { color: #842029; background: #f5c2c7; }
.dashboard-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    color: inherit;
}
.dashboard-action-inbox {
    margin-left: auto;
}
.dashboard-action-button {
    display: inline-flex;
    align-items: center;
}
.dashboard-breadcrumbs {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    font-size: .78rem;
}
.dashboard-breadcrumbs a {
    color: #0d6efd;
    text-decoration: none;
}
.dashboard-breadcrumbs span {
    color: #6c757d;
}
.dashboard-breadcrumbs i {
    color: #adb5bd;
    font-size: .65rem;
}
.dashboard-section-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .75rem;
    color: #6c757d;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.dashboard-section-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #dde1e7;
}
.dashboard-branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: .75rem;
}
.dashboard-branch-card {
    padding: 1rem;
    background: #fff;
    border: 1px solid #dde1e7;
    border-radius: .5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.055);
}
.dashboard-branch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .85rem;
}
.dashboard-branch-status {
    padding: .15rem .45rem;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    white-space: nowrap;
}
.dashboard-branch-status.ok {
    color: #137333;
    background: #e6f4ea;
}
.dashboard-branch-status.warn {
    color: #b45309;
    background: #fff3cd;
}
.dashboard-branch-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .4rem;
}
.dashboard-branch-stat {
    min-width: 0;
    color: #343a40;
    text-align: center;
    text-decoration: none;
}
.dashboard-branch-stat strong {
    display: block;
    font-size: 1.35rem;
    line-height: 1.1;
    font-weight: 700;
}
.dashboard-branch-stat span {
    display: block;
    margin-top: .2rem;
    color: #6c757d;
    font-size: .67rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.dashboard-branch-stat.danger strong { color: #dc3545; }
.dashboard-branch-stat.primary strong { color: #0d6efd; }
.dashboard-branch-stat.warning strong { color: #d97706; }
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
}
.dashboard-kpi-card {
    position: relative;
    min-height: 108px;
    padding: 1rem;
    overflow: hidden;
    color: #212529;
    text-decoration: none;
    background: #fff;
    border: 1px solid #dde1e7;
    border-radius: .5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.055);
}
.dashboard-kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
}
.dashboard-kpi-card span {
    display: block;
    color: #6c757d;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.dashboard-kpi-card strong {
    display: block;
    margin-top: .45rem;
    font-size: 2.15rem;
    line-height: 1;
    font-weight: 800;
}
.dashboard-kpi-card i {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    opacity: .12;
}
.dashboard-kpi-card.total::before { background: #0d6efd; }
.dashboard-kpi-card.pending::before { background: #d97706; }
.dashboard-kpi-card.active::before { background: #0891b2; }
.dashboard-kpi-card.done::before { background: #198754; }
.dashboard-kpi-card.total strong { color: #0d6efd; }
.dashboard-kpi-card.pending strong { color: #d97706; }
.dashboard-kpi-card.active strong { color: #0891b2; }
.dashboard-kpi-card.done strong { color: #198754; }
.dashboard-list-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    color: #212529;
    text-decoration: none;
    border-bottom: 1px solid #e9ecef;
}
.dashboard-list-row:hover {
    background: #f8f9fa;
}
.dashboard-list-row strong,
.dashboard-list-row small {
    display: block;
}
.dashboard-list-row small {
    margin-top: .15rem;
    color: #6c757d;
}
/* ── Animation ── */
.fade-in { animation: fadeIn .3s ease-in; }
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── File upload ── */
.file-upload-area {
    border: 2px dashed #dee2e6; border-radius: .5rem;
    padding: 2rem; text-align: center; transition: all .3s ease;
}
.file-upload-area:hover { border-color: var(--primary-color); background-color: rgba(0,123,255,.05); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }

.smaller { font-size: 0.8em; }

.notransition {
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
}

/* ── Sidebar ── */
#wrapper {
    display: flex !important;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

#sidebar-wrapper {
    flex: 0 0 250px;
    width: 250px;
    background-color: #ffffff;
    transition: all 0.3s ease;
    z-index: 1000;
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid #dee2e6;
}

#sidebar-wrapper.collapsed {
    flex: 0 0 70px;
    width: 70px;
}

/* Apply collapsed geometry before JS initializes sidebar state. */
html.sidebar-pre-collapsed #sidebar-wrapper {
    flex: 0 0 70px;
    width: 70px;
}

#sidebar-wrapper .sidebar-section-label {
    letter-spacing: 0.05em;
    opacity: 0.8;
}

#sidebar-wrapper.collapsed .sidebar-section-label {
    display: none;
}

html.sidebar-pre-collapsed #sidebar-wrapper .sidebar-section-label {
    display: none;
}

#sidebar-wrapper .sidebar-link {
    padding: 10px 24px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

#sidebar-wrapper .sidebar-link:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

#sidebar-wrapper .sidebar-link.active {
    background: #eef5ff;
    color: var(--primary-color);
    font-weight: 600;
    border-right: 3px solid var(--primary-color);
}

#sidebar-wrapper .sidebar-link i {
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    margin-right: 12px;
    font-size: 1.1rem;
}

#sidebar-wrapper.collapsed .sidebar-link span {
    display: none;
}

html.sidebar-pre-collapsed #sidebar-wrapper .sidebar-link span {
    display: none;
}

#sidebar-wrapper.collapsed .sidebar-link i {
    margin-right: 0;
    width: 100%;
}

html.sidebar-pre-collapsed #sidebar-wrapper .sidebar-link i {
    margin-right: 0;
    width: 100%;
}

#page-content-wrapper {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.25rem;
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: #fff;
}

.app-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 15px 25px;
    margin-top: auto;
}

/* ══════════════════════════════════════════
   MOBILE BOTTOM NAV
══════════════════════════════════════════ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    z-index: 1030;
}
.bottom-nav a {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: #6c757d;
    text-decoration: none;
    font-size: .65rem;
    gap: 2px;
    padding: 4px 0;
    transition: color .15s;
}
.bottom-nav a i { font-size: 1.25rem; }
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--primary-color); }
.bottom-nav a.active i { color: var(--primary-color); }

/* ══════════════════════════════════════════
   MOBILE CASE CARDS (replaces table on small screens)
══════════════════════════════════════════ */
.case-row-desktop {
    display: table-row;
}

/* ══════════════════════════════════════════
   RESPONSIVE OVERRIDES
══════════════════════════════════════════ */
@media (max-width: 767.98px) {
    /* Give room for bottom nav */
    body { padding-bottom: calc(var(--bottom-nav-height) + 8px); }

    /* Hide desktop top navbar links, show bottom nav */
    .bottom-nav { display: flex; }

    /* Tighter page chrome */
    .container-fluid { padding-left: 12px; padding-right: 12px; }
    main.container-fluid { padding-left: 10px; padding-right: 10px; }

    /* Page title row: stack on very narrow */
    .page-title-row { flex-direction: column; align-items: flex-start !important; gap: .5rem; }
    .page-title-row .btn { align-self: stretch; text-align: center; }

    /* Cards */
    .card-body { padding: .875rem; }
    .card-header { padding: .65rem .875rem; }

    /* Stat cards: 2-col grid on mobile */
    .stat-cards-row > [class*="col-"] { padding: 4px; }
    .stat-cards-row .card-body { padding: .75rem .5rem !important; }
    .stat-cards-row .h3 { font-size: 1.5rem; }
    .dashboard-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dashboard-kpi-card {
        min-height: 92px;
        padding: .85rem;
    }
    .dashboard-kpi-card strong {
        font-size: 1.65rem;
    }
    .dashboard-branch-grid {
        grid-template-columns: 1fr;
    }

    /* Tables: shrink font, allow horizontal scroll */
    .table-responsive { font-size: .8rem; }
    .table td, .table th { padding: .35rem .4rem; }

    /* Buttons: bigger touch targets */
    .btn-sm { padding: .35rem .6rem; font-size: .8rem; }
    .btn { min-height: 38px; }

    /* Filter form: stack inputs */
    .filter-form .col-md-4,
    .filter-form .col-md-3,
    .filter-form .col-md-2 { flex: 0 0 100%; max-width: 100%; }

    /* Modal: full-screen on mobile */
    .modal-dialog { margin: .5rem; }
    .modal-dialog:not(.modal-sm) { max-width: 100%; }

    /* Subtask inline actions: wrap */
    .subtask-actions { flex-wrap: wrap; }

    /* Hide chart section on mobile to save space */
    .charts-col { display: none; }

    .dashboard-action-strip {
        display: grid;
        gap: .5rem;
    }
    .dashboard-action-item,
    .dashboard-action-button {
        width: 100%;
        justify-content: flex-start;
    }
    .dashboard-action-inbox {
        margin-left: 0;
    }

    /* Audit trail in sidebar: move inline on mobile */
    .sidebar-col { width: 100% !important; }
}

/* ── Print ── */
@media print {
    .navbar, .bottom-nav, .btn, .modal, .alert, .pagination { display: none !important; }
    .card { border: 1px solid #000 !important; box-shadow: none !important; }
    body { padding-bottom: 0; }
}
