/* ========================================================================
   VINP Billing — Professional UI Theme
   ======================================================================== */

/* ─── CSS Variables ───────────────────────────────────────────────────── */
:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1a1d23;
    --sidebar-hover: #252830;
    --sidebar-active: #2d313a;
    --accent: #4f6ef7;
    --accent-light: #6b85f9;
    --accent-glow: rgba(79, 110, 247, 0.15);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bg-body: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.35s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ─── Global ──────────────────────────────────────────────────────────── */
body {
    background: var(--bg-body);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ─── Fixed Sidebar ───────────────────────────────────────────────────── */
.sidebar-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform var(--transition-slow);
    border-right: 1px solid rgba(255,255,255,0.05);
}

/* Custom scrollbar for sidebar */
.sidebar-fixed::-webkit-scrollbar {
    width: 4px;
}
.sidebar-fixed::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-fixed::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
.sidebar-fixed::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* Sidebar brand */
.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand h5 {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-brand h5 i {
    color: var(--accent);
    font-size: 1.2rem;
}

.sidebar-brand small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Sidebar nav */
.sidebar-fixed .nav-header {
    color: rgba(255,255,255,0.35);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 1.1rem 1rem 0.35rem;
}

.sidebar-fixed .nav-header[data-bs-toggle="collapse"] {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color var(--transition-fast);
}

.sidebar-fixed .nav-header[data-bs-toggle="collapse"]:hover {
    color: rgba(255,255,255,0.55);
}

.sidebar-fixed .nav-header[data-bs-toggle="collapse"]::after {
    content: "\F282";
    font-family: "bootstrap-icons";
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.sidebar-fixed .nav-header[data-bs-toggle="collapse"][aria-expanded="true"]::after,
.sidebar-fixed .nav-header[data-bs-toggle="collapse"]:not(.collapsed)::after {
    transform: rotate(180deg);
}

.sidebar-fixed .collapse .nav-link,
.sidebar-fixed .collapsing .nav-link {
    padding-left: 1.5rem;
    font-size: 0.8rem;
}

.sidebar-fixed .nav-link {
    color: rgba(255,255,255,0.6);
    padding: 0.45rem 1rem;
    font-size: 0.84rem;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-fixed .nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    transition: color var(--transition-fast);
}

.sidebar-fixed .nav-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: rgba(79, 110, 247, 0.4);
}

.sidebar-fixed .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-fixed .nav-link.active i {
    color: var(--accent);
}

.sidebar-fixed hr {
    border-color: rgba(255,255,255,0.06);
    margin: 0.5rem 0;
}

/* ─── Content Area ────────────────────────────────────────────────────── */
.content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-body);
    padding: 1.5rem 2rem;
    animation: fadeIn 0.3s ease-out;
}

/* ─── Mobile Header ───────────────────────────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--sidebar-bg);
    z-index: 1035;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.mobile-header .brand-text {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
}

.hamburger-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.hamburger-btn:hover {
    color: var(--accent);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    animation: fadeInUp 0.4s ease-out both;
    overflow: hidden;
}

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

.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    padding: 0.85rem 1.15rem;
}

.card-footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

/* Staggered card animation */
.card-stagger:nth-child(1) { animation-delay: 0s; }
.card-stagger:nth-child(2) { animation-delay: 0.08s; }
.card-stagger:nth-child(3) { animation-delay: 0.16s; }
.card-stagger:nth-child(4) { animation-delay: 0.24s; }

/* ─── KPI Cards ───────────────────────────────────────────────────────── */
.kpi-card {
    border-radius: 12px;
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.kpi-card.green  { background: linear-gradient(135deg, #22c55e, #16a34a); }
.kpi-card.blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.kpi-card.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi-card.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.kpi-card .kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-card .kpi-label {
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 2px;
}

/* Decorative circle */
.kpi-card::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    top: -20px;
    right: -20px;
}

/* ─── Tables ──────────────────────────────────────────────────────────── */
.table {
    margin-bottom: 0;
    font-size: 0.84rem;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    padding: 0.7rem 0.85rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: rgba(79, 110, 247, 0.04) !important;
}

.table td {
    padding: 0.6rem 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table tfoot td, .table tfoot th {
    background: #f8fafc;
    font-weight: 600;
    border-top: 2px solid #e2e8f0;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
    border-radius: 7px;
    font-weight: 500;
    font-size: 0.84rem;
    transition: all var(--transition-fast);
    padding: 0.4rem 0.9rem;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 2px 4px rgba(79, 110, 247, 0.25);
}

.btn-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

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

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

/* ─── Forms ───────────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 7px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

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

/* ─── Alerts ──────────────────────────────────────────────────────────── */
.alert {
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    animation: slideInRight 0.3s ease-out both;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid var(--success);
}

.alert-danger, .alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

/* ─── Page Header ─────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    animation: fadeInUp 0.3s ease-out both;
}

.page-header h4 {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0;
}

.page-header .badge {
    font-size: 0.7rem;
    font-weight: 500;
    vertical-align: middle;
    margin-left: 8px;
}

/* ─── Filter Bar ──────────────────────────────────────────────────────── */
.filter-bar {
    border-radius: 10px;
    margin-bottom: 1rem;
    animation: fadeInUp 0.35s ease-out both;
}

.filter-bar .card-body {
    padding: 0.65rem 1rem;
}

/* ─── Quick Actions ───────────────────────────────────────────────────── */
.quick-actions .btn {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ─── Badges ──────────────────────────────────────────────────────────── */
.badge-payment { background: #dcfce7; color: #166534; }
.badge-receipt { background: #dbeafe; color: #1e40af; }
.badge-journal { background: #fef3c7; color: #92400e; }

/* ─── Charts ──────────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    padding: 1rem;
}

/* ─── Empty State ─────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
    margin: 0;
}

/* ─── Pagination ──────────────────────────────────────────────────────── */
.pagination .page-link {
    border-radius: 6px;
    margin: 0 2px;
    font-size: 0.8rem;
    border: none;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 4px rgba(79, 110, 247, 0.25);
}

.pagination .page-link:hover {
    background: var(--accent-glow);
    color: var(--accent);
}

/* ─── Select2 Refinements ─────────────────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
    border-radius: 7px;
    border-color: #e2e8f0;
    min-height: 36px;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ─── Loading Spinner ─────────────────────────────────────────────────── */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 10px;
    top: 50%;
    margin-top: -8px;
}

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

/* ─── Tooltip Styling ─────────────────────────────────────────────────── */
.tooltip-inner {
    font-size: 0.75rem;
    border-radius: 5px;
}

/* ─── Login Page ──────────────────────────────────────────────────────── */
.login-bg {
    background: linear-gradient(135deg, #1a1d23 0%, #2d1b4e 50%, #1a1d23 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.login-card {
    max-width: 400px;
    width: 100%;
    animation: fadeInUp 0.5s ease-out both;
}

.login-card .card {
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.05);
}

.login-card .brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    margin: 0 auto 1rem;
}

/* ─── Summary Cards (Reports) ─────────────────────────────────────────── */
.summary-card {
    border-left: 4px solid var(--accent);
    border-radius: 8px;
}

.summary-card .value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ─── Print Styles ────────────────────────────────────────────────────── */
@media print {
    .sidebar-fixed,
    .mobile-header,
    .sidebar-overlay,
    .filter-bar,
    .page-header .btn,
    .pagination,
    .btn-print {
        display: none !important;
    }

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

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    body {
        background: #fff;
    }
}

/* ─── Responsive: Mobile ──────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .sidebar-fixed {
        transform: translateX(-100%);
    }

    .sidebar-fixed.show {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .content-wrapper {
        margin-left: 0;
        padding: 1rem;
        padding-top: 70px;
    }

    .kpi-card .kpi-value {
        font-size: 1.3rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ─── Responsive: Tablet ──────────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root {
        --sidebar-width: 200px;
    }

    .content-wrapper {
        padding: 1rem 1.25rem;
    }
}

/* ─── Utility Animations ──────────────────────────────────────────────── */
.animate-fadeInUp { animation: fadeInUp 0.4s ease-out both; }
.animate-delay-1 { animation-delay: 0.08s; }
.animate-delay-2 { animation-delay: 0.16s; }
.animate-delay-3 { animation-delay: 0.24s; }
.animate-delay-4 { animation-delay: 0.32s; }
