/* ========== Base & Variables ========== */
:root {
    --primary:   #6366f1;
    --primary-d: #4f46e5;
    --success:   #10b981;
    --warning:   #f59e0b;
    --danger:    #ef4444;
    --info:      #3b82f6;
    --bg:        #f1f5f9;
    --card-bg:   #ffffff;
    --text:      #1e293b;
    --muted:     #64748b;
    --border:    #e2e8f0;
    --radius:    12px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== Navbar ========== */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-d) 100%);
    box-shadow: 0 2px 12px rgba(99,102,241,.35);
    padding: .7rem 1.5rem;
}

.navbar-brand { font-size: 1.3rem; letter-spacing: .5px; }

.nav-link { color: rgba(255,255,255,.85) !important; font-weight: 500; transition: color .2s; }
.nav-link:hover, .nav-link.active { color: #fff !important; }
.nav-link.active { font-weight: 700; border-bottom: 2px solid #fff; }

.btn-add-main {
    background: rgba(255,255,255,.15);
    color: #fff !important;
    border: 1.5px solid rgba(255,255,255,.5);
    border-radius: 8px;
    font-weight: 600;
    transition: background .2s;
}
.btn-add-main:hover { background: rgba(255,255,255,.28); }

/* ========== Page Title ========== */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .3rem;
}

/* ========== Stat Cards ========== */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.4rem 1.6rem;
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    border-right: 4px solid;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }

.stat-card-primary { border-right-color: var(--primary); }
.stat-card-success  { border-right-color: var(--success); }
.stat-card-warning  { border-right-color: var(--warning); }
.stat-card-info     { border-right-color: var(--info); }

.stat-icon {
    font-size: 2rem;
    flex-shrink: 0;
}
.stat-card-primary .stat-icon { color: var(--primary); }
.stat-card-success  .stat-icon { color: var(--success); }
.stat-card-warning  .stat-icon { color: var(--warning); }
.stat-card-info     .stat-icon { color: var(--info); }

.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-sub   { font-size: .78rem; color: var(--muted); margin-top: .2rem; }

/* ========== Cards ========== */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ========== Tables ========== */
.table { font-size: .9rem; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table thead th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    font-weight: 700;
    padding: .85rem 1rem;
}
.table td { padding: .9rem 1rem; vertical-align: middle; }

/* ========== Category Badge ========== */
.cat-badge {
    display: inline-flex;
    align-items: center;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ========== Color Dot ========== */
.color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    border: 1px solid rgba(0,0,0,.1);
}

/* ========== Expense list item ========== */
.expense-item { padding: .9rem 1.25rem; }

/* ========== Empty State ========== */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--muted);
}
.empty-state i { font-size: 3.5rem; display: block; margin-bottom: 1rem; opacity: .45; }
.empty-state p  { font-size: 1rem; margin-bottom: 1rem; }

/* ========== Buttons ========== */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
}
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }

/* ========== Forms ========== */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(99,102,241,.2);
}

/* ========== Footer ========== */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ========== Tabs ========== */
.nav-tabs .nav-link {
    color: var(--muted) !important;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
}
.nav-tabs .nav-link.active {
    color: var(--primary) !important;
    border-bottom-color: var(--card-bg);
    background: var(--card-bg);
}

/* ========== Stat Card Danger ========== */
.stat-card-danger { border-right-color: var(--danger); }
.stat-card-danger .stat-icon { color: var(--danger); }

/* ========== Dashboard Balance Banner ========== */
.dashboard-balance-card {
    border-radius: var(--radius);
    padding: 1.4rem 1.8rem;
    color: #fff;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.dashboard-balance-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.balance-pos { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.balance-neg { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.db-balance-label  { font-size: .85rem; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }
.db-balance-value  { font-size: 2rem; font-weight: 800; margin: .2rem 0; }
.db-balance-sub    { font-size: .8rem; opacity: .8; }
.db-balance-icon   { font-size: 3.5rem; opacity: .25; flex-shrink: 0; }

/* ========== Debt Mini Cards ========== */
.debt-mini-card {
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform .2s;
    color: #fff;
}
.debt-mini-card:hover { transform: translateY(-3px); }
.debt-lent     { background: linear-gradient(135deg, #10b981, #059669); }
.debt-borrowed { background: linear-gradient(135deg, #ef4444, #dc2626); }
.debt-mini-icon  { font-size: 1.8rem; opacity: .8; margin-bottom: .3rem; }
.debt-mini-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; opacity: .85; }
.debt-mini-amount{ font-size: 1.25rem; font-weight: 800; margin: .15rem 0; }
.debt-mini-sub   { font-size: .75rem; opacity: .75; }

/* ========== Balance Hero (wallet.php) ========== */
.balance-hero {
    border-radius: var(--radius);
    padding: 2rem;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.balance-positive { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.balance-negative { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.balance-label  { font-size: .85rem; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: 1px; }
.balance-amount { font-size: 2.5rem; font-weight: 800; margin: .3rem 0; }
.balance-sub    { font-size: .85rem; opacity: .8; }
.balance-formula { background: rgba(255,255,255,.15); border-radius: 10px; padding: 1rem 1.2rem; }
.formula-row    { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .9rem; }
.formula-label  { opacity: .9; }
.formula-val    { font-weight: 700; }

/* ========== Entry Type Cards (wallet.php) ========== */
.entry-type-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: var(--card-bg);
}
.entry-type-card:hover  { border-color: var(--primary); background: #f5f3ff; }
.entry-type-card.selected { border-color: var(--primary); background: #ede9fe; }

/* ========== Person Avatar (debts.php) ========== */
.person-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
    flex-shrink: 0;
}

/* ========== Debt Type Buttons in Modal ========== */
.debt-type-btn { cursor: pointer; }
.debt-type-inner { transition: border-color .2s, background .2s; cursor: pointer; }
.debt-type-inner:hover { background: #f8fafc; }

/* ========== Responsive ========== */
@media (max-width: 576px) {
    .stat-value { font-size: 1.2rem; }
    .page-title { font-size: 1.3rem; }
    .balance-amount { font-size: 1.8rem; }
    .db-balance-value { font-size: 1.5rem; }
}
