@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --text: #0F172A;
    --text-secondary: #64748B;
    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --border: #E2E8F0;
    --sidebar-bg: #2563EB;
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { text-decoration: none; color: var(--accent); }
a:hover { color: var(--accent-hover); }



/* ─── Layout ─── */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(255,255,255,0.1);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #FFFFFF;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    gap: 0.75rem;
}

.sidebar-brand i { color: #FFFFFF; font-size: 1.5rem; }

.sidebar-close {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    color: rgba(255,255,255,0.75);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
    gap: 0.75rem;
}

.sidebar-nav .nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-nav .nav-item:hover {
    background: rgba(255,255,255,0.12);
    color: #FFFFFF;
}

.sidebar-nav .nav-item.active {
    background: rgba(255,255,255,0.2);
    color: #FFFFFF;
    font-weight: 600;
}

.sidebar-nav .nav-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ─── Top Navbar ─── */
.topbar {
    height: var(--navbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.topbar .profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}

.topbar .profile-btn:hover { background: var(--bg); }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ─── Page Content ─── */
.page-content {
    padding: 1.5rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ─── Cards ─── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header h5 {
    font-size: 0.95rem;
    font-weight: 600;
}

.stat-card {
    padding: 1.25rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
}

/* ─── Tables ─── */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
}

@media (max-width: 768px) {
    .table-container table { min-width: 640px; }
    .table-container table.compact { min-width: auto; }
    table tbody td, table thead th { padding: 0.5rem 0.625rem; font-size: 0.8rem; white-space: nowrap; }
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table tbody tr:hover { background: #FAFBFC; }

/* ─── Status Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.375rem;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-paid { background: #DCFCE7; color: #166534; }
.badge-paid .badge-dot { background: #22C55E; }

.badge-pending { background: #FEF9C3; color: #854D0E; }
.badge-pending .badge-dot { background: #EAB308; }

.badge-overdue { background: #FEE2E2; color: #991B1B; }
.badge-overdue .badge-dot { background: #EF4444; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    justify-content: center;
}

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

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

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

.btn-danger { background: #DC2626; color: white; border-color: #DC2626; }
.btn-danger:hover { background: #B91C1C; }

.btn-success { background: #16A34A; color: white; border-color: #16A34A; }
.btn-success:hover { background: #15803D; }
.btn-warning { background: #D97706; color: white; border-color: #D97706; }
.btn-warning:hover { background: #B45309; }

/* ─── Forms ─── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

textarea.form-control { resize: vertical; min-height: 80px; }

/* ─── Modals ─── */
/* ─── Bootstrap Modal Overrides ─── */
.modal-dialog { max-width: 480px; }
.modal-content { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
.modal-header { border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; }
.modal-header .modal-title { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 0.75rem 1.25rem; gap: 0.5rem; }
.btn-close { background-size: 0.6em; }

/* ─── Auth Pages ─── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-card .auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .auth-brand h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.auth-card .auth-brand p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

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

.empty-state i {
    font-size: 3rem;
    color: #CBD5E1;
    margin-bottom: 1rem;
}

.empty-state h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Alert / Toast ─── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-success { background: #DCFCE7; border-color: #BBF7D0; color: #166534; }
.alert-danger { background: #FEE2E2; border-color: #FECACA; color: #991B1B; }
.alert-info { background: #DBEAFE; border-color: #BFDBFE; color: #1E40AF; }

/* ─── Invoice Split Layout ─── */
.invoice-form-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.invoice-form-layout .invoice-items-section {
    grid-column: 1 / -1;
}

.invoice-totals {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

.invoice-totals .total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.invoice-totals .total-row.grand-total {
    border-top: 2px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .max-w-100vh{
        max-width: 100vw;
    }
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle { display: block; }
    .sidebar-close { display: block; }

    .main-content {
        margin-left: 0;
    }

    .page-content { padding: 1rem; }

    .invoice-form-layout {
        grid-template-columns: 1fr;
    }

    .stat-card .stat-value { font-size: 1.35rem; }
}

/* Sidebar overlay (kept separate from Bootstrap modals) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(100%, 1fr)); gap: 1rem; }
/* .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; } */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
/* .grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; } */
.w-full { width: 100%; }

/* Pagination */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}
.pagination {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s;
}
.page-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-dots { display: inline-flex; align-items: center; padding: 0 0.25rem; color: var(--text-secondary); font-size: 0.8rem; }
.page-info { font-size: 0.8rem; color: var(--text-secondary); }
