/* ============================================
   JKhata - Professional UI
   ============================================ */

/* ---------- CSS Variables (Theme) ---------- */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.06), 0 4px 10px rgba(0,0,0,0.04);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; }

/* ---------- Sidebar (Desktop) ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand .brand-sub {
    color: var(--text-muted);
    font-size: 0.7rem;
    display: block;
    margin-top: -2px;
}

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

.sidebar-nav .nav-section {
    padding: 0.75rem 1.5rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: #cbd5e1;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    opacity: 0.7;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link:hover i {
    opacity: 1;
}

.sidebar-nav .nav-link.active {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border-left-color: var(--sidebar-active);
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
    color: #60a5fa;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 1rem 1.5rem;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-footer .user-name {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
}

.sidebar-footer .user-role {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ---------- Top Bar (Mobile) ---------- */
.topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    z-index: 1035;
    align-items: center;
    padding: 0 1rem;
    box-shadow: var(--shadow-sm);
}

.topbar .topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.topbar .topbar-brand i {
    color: var(--info);
}

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

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

.content-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

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

.content-header .header-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.content-body {
    padding: 1.5rem 1.75rem;
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
    border: none;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .card-body {
    padding: 1.25rem;
    position: relative;
    z-index: 1;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-value {
    font-size: 1rem;
    margin: 0;
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0.15rem 0 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Gradient Stat Cards */
.stat-card-gradient {
    color: #fff;
    border: none;
}

.stat-card-gradient .stat-label { color: rgba(255,255,255,0.8); }
.stat-card-gradient .stat-value { color: #fff; }
.stat-card-gradient .stat-icon { background: rgba(255,255,255,0.2); color: #fff; }

.stat-card-gradient.bg-gradient-success { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card-gradient.bg-gradient-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card-gradient.bg-gradient-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card-gradient.bg-gradient-info { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card-gradient.bg-gradient-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-card-gradient.bg-gradient-dark { background: linear-gradient(135deg, #1e293b, #0f172a); }

/* ---------- Tables ---------- */
.table {
    margin-bottom: 0;
}

.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: var(--border-color);
    font-size: 0.85rem;
}

.table tbody tr {
    transition: background 0.1s;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* ---------- Badges ---------- */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    padding: 0.35em 0.7em;
    border-radius: 6px;
}

.badge-cash {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.badge-credit {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.badge-sent {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-received {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

/* ---------- Buttons ---------- */
.btn {
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1rem;
    transition: var(--transition);
    letter-spacing: 0.01em;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    box-shadow: 0 2px 4px rgba(59,130,246,0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 4px 8px rgba(59,130,246,0.3);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    box-shadow: 0 2px 4px rgba(16,185,129,0.25);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    box-shadow: 0 2px 4px rgba(239,68,68,0.25);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: #fff;
    box-shadow: 0 2px 4px rgba(245,158,11,0.25);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff;
    transform: translateY(-1px);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text-primary);
}

.btn-outline-danger {
    border-color: #fecaca;
    color: #ef4444;
}

.btn-outline-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.btn-outline-primary {
    border-color: #bfdbfe;
    color: #3b82f6;
}

.btn-outline-primary:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.btn-outline-info {
    border-color: #a5f3fc;
    color: #0891b2;
}

.btn-outline-info:hover {
    background: #ecfeff;
    border-color: #67e8f9;
    color: #0e7490;
}

.btn-whatsapp {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(37,211,102,0.25);
}

.btn-whatsapp:hover {
    background: linear-gradient(135deg, #128C7E, #075E54);
    color: white;
    transform: translateY(-1px);
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    transition: var(--transition);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.input-group-text {
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

/* ---------- Quick Actions ---------- */
.quick-action {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem 0.75rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition);
    display: block;
    background: #fff;
}

.quick-action:hover {
    border-color: var(--info);
    color: var(--info);
    background: #eff6ff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quick-action i {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 0.35rem;
}

.quick-action small {
    font-weight: 600;
    font-size: 0.75rem;
}

/* ---------- Alerts ---------- */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.85rem 1.25rem;
}

.alert-success {
    background: rgba(16,185,129,0.1);
    color: #065f46;
}

.alert-danger {
    background: rgba(239,68,68,0.1);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245,158,11,0.1);
    color: #92400e;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 300px;
    margin: 0 auto 1rem;
}

/* ---------- Amount Colors ---------- */
.text-credit { color: var(--danger) !important; }
.text-debit { color: var(--success) !important; }

/* ---------- Filter Bar ---------- */
.filter-bar {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.filter-bar .form-control-sm,
.filter-bar .form-select-sm {
    font-size: 0.82rem;
    border-radius: 6px;
}

/* ---------- Summary Row ---------- */
.summary-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    text-align: center;
}

.summary-card .summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.summary-card .summary-value {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* ---------- Login / Register ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(59,130,246,0.08);
    top: -200px;
    right: -200px;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(139,92,246,0.06);
    bottom: -100px;
    left: -100px;
}

.auth-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    position: relative;
    z-index: 1;
}

.auth-left .auth-heading {
    color: #fff;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
}

.auth-left .auth-sub {
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 380px;
}

.auth-left .auth-features {
    margin-top: 2rem;
    list-style: none;
    padding: 0;
}

.auth-left .auth-features li {
    color: #cbd5e1;
    font-size: 0.9rem;
    padding: 0.4rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auth-left .auth-features li i {
    color: var(--success);
    font-size: 1rem;
}

.auth-right {
    width: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.auth-card {
    width: 100%;
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.auth-card .auth-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.auth-card .auth-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.page-header h5 {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

/* ---------- Dropdown ---------- */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    font-size: 0.85rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
    font-weight: 500;
}

.dropdown-item:hover {
    background: #f1f5f9;
}

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

/* ---------- Bottom Nav (Mobile) ---------- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border-color);
    z-index: 1030;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
    padding: 0.4rem 0;
}

.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s;
}

.bottom-nav a i {
    font-size: 1.2rem;
}

.bottom-nav a.active {
    color: var(--info);
}

.bottom-nav a.active i {
    color: var(--info);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
}

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

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

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

    .topbar {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: 56px;
    }

    .content-header {
        position: relative;
    }

    .bottom-nav {
        display: flex;
    }

    .content-body {
        padding: 1rem;
        padding-bottom: 5rem;
    }

    .auth-wrapper {
        flex-direction: column;
    }

    .auth-left {
        display: none;
    }

    .auth-right {
        width: 100%;
        min-height: 100vh;
        background: var(--sidebar-bg);
    }

    .auth-card {
        max-width: 420px;
    }
}

@media (max-width: 575.98px) {
    .stat-card .stat-value {
        font-size: 1.1rem;
    }

    .content-body {
        padding: 0.75rem;
        padding-bottom: 5rem;
    }

    .table tbody td,
    .table thead th {
        padding: 0.6rem 0.65rem;
        font-size: 0.78rem;
    }
}

/* ---------- P&L Table ---------- */
.pl-table td {
    padding: 0.6rem 0;
    border: none;
}

.pl-table .pl-indent {
    padding-left: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.pl-table .pl-divider td {
    padding: 0;
}

.pl-table .pl-divider hr {
    margin: 0.3rem 0;
    border-color: var(--border-color);
}

.pl-table .pl-total {
    font-size: 1.1rem;
}

/* ---------- Ledger ---------- */
.ledger-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ledger-header .party-info h5 {
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.ledger-header .party-info small {
    color: var(--text-secondary);
}
