/* ============================================================
   assets/css/style.css  —  Partnership Ledger v3.0
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@400;500;600;700&family=Noto+Serif+Bengali:wght@400;600;700&display=swap');

:root {
    --bg:           #f4f6f9;
    --bg-alt:       #eef1f5;
    --surface:      #ffffff;
    --surface-2:    #f8f9fc;
    --border:       #dde2ea;
    --border-light: #eaeef4;

    --accent:       #1a56db;
    --accent-dark:  #1344b8;
    --accent-light: rgba(26,86,219,0.08);
    --accent-glow:  rgba(26,86,219,0.15);

    --income:       #0d9f6e;
    --income-light: rgba(13,159,110,0.10);
    --expense:      #e02424;
    --expense-light:rgba(224,36,36,0.10);
    --warning:      #d97706;
    --warning-light:rgba(217,119,6,0.10);
    --info:         #0284c7;
    --info-light:   rgba(2,132,199,0.10);

    --text:         #1a202c;
    --text-sub:     #4a5568;
    --muted:        #718096;
    --placeholder:  #a0aec0;

    --nav-height:   60px;
    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    14px;
    --radius-xl:    20px;

    --shadow-xs:    0 1px 2px rgba(0,0,0,.05);
    --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:    0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
    --shadow-focus: 0 0 0 3px var(--accent-glow);

    --font-bn:      'Hind Siliguri', 'Noto Serif Bengali', system-ui, sans-serif;
    --font-num:     'SF Mono', 'Fira Code', 'Consolas', monospace;
    --transition:   all 0.18s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family:    var(--font-bn);
    background:     var(--bg);
    color:          var(--text);
    font-size:      14.5px;
    line-height:    1.65;
    min-height:     100vh;
    display:        flex;
    flex-direction: column;
}

.font-num { font-family: var(--font-num) !important; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Navbar ─────────────────────────────────────────────── */
#mainNav {
    background:    var(--surface);
    border-bottom: 1px solid var(--border);
    min-height:    var(--nav-height);
    box-shadow:    var(--shadow-sm);
    position:      sticky;
    top: 0; z-index: 1000;
}

.brand-wrap { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-icon-box {
    width: 36px; height: 36px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 8px var(--accent-glow);
    overflow: hidden;
}
.brand-text  { font-weight: 700; font-size: 1rem; letter-spacing: -.02em; color: var(--text); line-height: 1.2; }
.brand-sub   { font-family: var(--font-num); font-size: .58rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

#mainNav .nav-link {
    color: var(--text-sub);
    font-weight: 500;
    font-size: .875rem;
    padding: .4rem .8rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex; align-items: center; gap: 5px;
}
#mainNav .nav-link:hover  { color: var(--accent); background: var(--accent-light); }
#mainNav .nav-link.active { color: var(--accent); background: var(--accent-light); font-weight: 600; }
#mainNav .nav-link i      { font-size: .85rem; }

/* User button dropdown */
.btn-user {
    display: flex; align-items: center; gap: 7px;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-sub); font-weight: 500; font-size: .8rem;
    padding: .35rem .85rem; border-radius: 999px;
    transition: var(--transition); cursor: pointer;
}
.btn-user:hover, .btn-user.show { border-color: var(--accent); color: var(--accent); }
.btn-user::after { display: none; } /* remove bootstrap caret */
.btn-user .avatar {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem; color: white; font-weight: 700;
}
.role-badge {
    background: var(--accent-light); color: var(--accent);
    font-size: .65rem; padding: 1px 6px; border-radius: 999px; font-weight: 600;
}

/* PWA Install button */
.btn-pwa-install {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white; border: none;
    padding: .35rem .8rem; border-radius: 999px;
    font-size: .8rem; font-weight: 600;
    display: flex; align-items: center; gap: 5px;
    transition: var(--transition); cursor: pointer;
    box-shadow: 0 2px 8px rgba(16,185,129,.25);
}
.btn-pwa-install:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,.35); color: white; }

/* ── Page hero ──────────────────────────────────────────── */
.page-hero {
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}
.page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.03em; margin: 0; color: var(--text); }
.page-sub   { font-size: .82rem; color: var(--muted); margin: 2px 0 0 0; }

/* ── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .875rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.income-card::before  { background: linear-gradient(90deg, var(--income), #34d399); }
.stat-card.expense-card::before { background: linear-gradient(90deg, var(--expense), #f87171); }
.stat-card.profit-card::before  { background: linear-gradient(90deg, var(--accent), #60a5fa); }
.stat-card.count-card::before   { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card-top    { display: flex; align-items: center; justify-content: space-between; margin-bottom: .65rem; }
.stat-card-label  { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-icon-box    { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: .95rem; }
.stat-icon-box.income  { background: var(--income-light); color: var(--income); }
.stat-icon-box.expense { background: var(--expense-light); color: var(--expense); }
.stat-icon-box.profit  { background: var(--accent-light);  color: var(--accent); }
.stat-icon-box.count   { background: var(--warning-light); color: var(--warning); }

.stat-card-value { font-family: var(--font-num); font-size: 1.4rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-card-value.income-val  { color: var(--income); }
.stat-card-value.expense-val { color: var(--expense); }
.stat-card-value.profit-val  { color: var(--accent); }
.stat-card-value.count-val   { color: var(--warning); }
.stat-card-sub   { font-size: .75rem; color: var(--muted); margin-top: 4px; }

/* ── Card ───────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-light);
    font-weight: 600; font-size: .88rem;
    padding: .8rem 1.25rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: var(--text);
}
.card-title-icon { margin-right: 6px; opacity: .7; }
.card-body { padding: 1.25rem; }

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-xs);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    border: none; color: white; font-weight: 600;
    padding: .5rem 1.1rem; border-radius: var(--radius-md);
    display: inline-flex; align-items: center; gap: 6px;
    transition: var(--transition);
    box-shadow: 0 2px 6px var(--accent-glow);
}
.btn-primary-custom:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); color: white; }

.btn-outline-custom {
    border: 1.5px solid var(--border); background: var(--surface);
    color: var(--text-sub); font-weight: 500;
    padding: .45rem 1rem; border-radius: var(--radius-md);
    display: inline-flex; align-items: center; gap: 6px;
    transition: var(--transition);
}
.btn-outline-custom:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.btn-outline-income  { border: 1.5px solid var(--income);  color: var(--income);  font-weight: 600; padding: .55rem 1rem; border-radius: var(--radius-md); background: transparent; transition: var(--transition); }
.btn-outline-expense { border: 1.5px solid var(--expense); color: var(--expense); font-weight: 600; padding: .55rem 1rem; border-radius: var(--radius-md); background: transparent; transition: var(--transition); }
.btn-check:checked + .btn-outline-income  { background: var(--income);  color: white; }
.btn-check:checked + .btn-outline-expense { background: var(--expense); color: white; }

.btn-xs {
    padding: .2rem .45rem; font-size: .78rem;
    border-radius: var(--radius-sm); line-height: 1.4;
    display: inline-flex; align-items: center; gap: 3px;
}

/* ── Type toggle (add transaction) ─────────────────────── */
.type-toggle-group {
    display: flex; gap: .75rem;
}
.type-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    padding: 1rem; border-radius: var(--radius-md);
    border: 2px solid var(--border); cursor: pointer;
    transition: var(--transition); gap: 4px;
}
.type-btn i    { font-size: 1.4rem; }
.type-btn span { font-weight: 700; font-size: .95rem; }
.type-btn small{ font-size: .72rem; color: var(--muted); }
.income-btn  { border-color: var(--income-light); color: var(--income); }
.expense-btn { border-color: var(--expense-light); color: var(--expense); }
.btn-check:checked + .income-btn  { background: var(--income); color: white; border-color: var(--income); box-shadow: 0 4px 12px rgba(13,159,110,.25); }
.btn-check:checked + .income-btn small { color: rgba(255,255,255,.7); }
.btn-check:checked + .expense-btn { background: var(--expense); color: white; border-color: var(--expense); box-shadow: 0 4px 12px rgba(224,36,36,.25); }
.btn-check:checked + .expense-btn small { color: rgba(255,255,255,.7); }

/* Amount input highlight */
.amount-input { font-size: 1.1rem !important; font-weight: 700; letter-spacing: .02em; }

/* ── Entry-by badge ──────────────────────────────────────── */
.entry-by-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--accent-light); color: var(--accent);
    font-size: .75rem; font-weight: 600;
    padding: 2px 8px; border-radius: 999px;
    white-space: nowrap;
}
.updated-tag {
    display: inline-flex; align-items: center;
    background: var(--warning-light); color: var(--warning);
    padding: 1px 5px; border-radius: 999px;
    font-size: .7rem; margin-left: 3px;
}

/* Entry user tag in add_transaction */
.entry-user-tag {
    background: var(--accent-light); color: var(--accent);
    font-size: .82rem; padding: .4rem .9rem;
    border-radius: 999px; white-space: nowrap;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge-income  { background: var(--income-light); color: var(--income); font-weight: 600; font-size: .75rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-expense { background: var(--expense-light); color: var(--expense); font-weight: 600; font-size: .75rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-cat { background: var(--surface-2); border: 1px solid var(--border-light); color: var(--text-sub); font-size: .75rem; padding: 2px 8px; border-radius: var(--radius-sm); }

.text-income  { color: var(--income)  !important; }
.text-expense { color: var(--expense) !important; }
.text-accent  { color: var(--accent)  !important; }
.text-sub     { color: var(--text-sub); }

/* ── Tables ─────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
    background: var(--surface-2); font-weight: 600;
    font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-light);
}
.table tbody td { padding: .7rem 1rem; vertical-align: middle; border-color: var(--border-light); }
.table-hover tbody tr:hover { background: var(--accent-light); }

/* ── Mobile Transaction Cards ────────────────────────────── */
.txn-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: .625rem;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.txn-card.income  { border-left: 3px solid var(--income); }
.txn-card.expense { border-left: 3px solid var(--expense); }

.txn-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .6rem .875rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-light);
    gap: .5rem;
}
.txn-amount { font-family: var(--font-num); font-weight: 700; font-size: .95rem; white-space: nowrap; }
.txn-card-body { padding: .6rem .875rem; }
.txn-desc { font-size: .875rem; color: var(--text); margin-bottom: .35rem; line-height: 1.4; }
.txn-meta {
    display: flex; flex-wrap: wrap; gap: .5rem;
    font-size: .75rem; color: var(--muted);
}
.txn-meta span { display: flex; align-items: center; gap: 3px; }
.txn-card-actions {
    padding: .5rem .875rem;
    border-top: 1px solid var(--border-light);
    display: flex; gap: .5rem;
    background: var(--surface-2);
}

/* ── Split card (dashboard) ─────────────────────────────── */
.split-card {
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    color: white;
    box-shadow: var(--shadow-md);
}
.split-divider { border-color: rgba(255,255,255,.2); margin: 1rem 0; }
.split-row  { display: flex; justify-content: space-between; align-items: center; }
.split-label{ font-size: .82rem; opacity: .9; display: flex; align-items: center; gap: 6px; }
.split-val  { font-family: var(--font-num); font-weight: 700; font-size: .95rem; }
.split-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Settings sections ──────────────────────────────────── */
.settings-section { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-lg); margin-bottom: 1.25rem; overflow: hidden; box-shadow: var(--shadow-xs); }
.settings-section-header { background: var(--surface-2); padding: .8rem 1.25rem; font-weight: 700; font-size: .88rem; color: var(--text); border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 8px; }
.settings-section-body { padding: 1.25rem; }

/* Logo preview */
.logo-preview-row { display: flex; align-items: flex-start; gap: 1.25rem; flex-wrap: wrap; }
.logo-preview-box {
    width: 100px; height: 100px; flex-shrink: 0;
    border: 2px dashed var(--border); border-radius: var(--radius-md);
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: var(--surface-2);
}
.logo-preview-img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: .75rem; }
.logo-preview-info { flex: 1; min-width: 200px; }

/* ── User management ────────────────────────────────────── */
.avatar-sm {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; color: white; font-weight: 700;
}
.role-pill { display: inline-flex; align-items: center; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.role-admin  { background: rgba(26,86,219,.1); color: var(--accent); }
.role-viewer { background: var(--surface-2); color: var(--muted); }

/* ── Timeline (history) ──────────────────────────────────── */
.timeline { position: relative; }
.timeline-item { display: flex; gap: 1rem; margin-bottom: 1.25rem; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 7px; top: 20px; bottom: -20px; width: 2px; background: var(--border-light); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; margin-top: 2px; border: 2px solid white; box-shadow: var(--shadow-sm); }
.timeline-dot.income  { background: var(--income); }
.timeline-dot.expense { background: var(--expense); }
.timeline-dot.info    { background: var(--info); }
.timeline-dot.warning { background: var(--warning); }
.timeline-body { flex: 1; min-width: 0; }

/* ── Login page ──────────────────────────────────────────── */
.login-page { background: linear-gradient(135deg, var(--bg), var(--bg-alt)); }
.login-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%; max-width: 400px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    margin: 1rem;
}
.login-logo { font-size: 2.5rem; line-height: 1; display: block; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-icon  { font-size: 2.5rem; margin-bottom: .75rem; opacity: .6; }

/* ── Footer ──────────────────────────────────────────────── */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    padding: .75rem 0; font-size: .8rem; color: var(--muted);
    margin-top: auto;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
    border-color: var(--border); border-radius: var(--radius-sm);
    font-family: var(--font-bn); font-size: .88rem;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: var(--text-sub); }
.form-text  { font-size: .78rem; color: var(--muted); margin-top: 3px; }

/* ── Pagination ──────────────────────────────────────────── */
.page-link { border-color: var(--border); color: var(--text-sub); font-size: .85rem; }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); }
.page-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { border-radius: var(--radius-md); font-size: .875rem; }
.alert-success { background: var(--income-light); border-color: rgba(13,159,110,.2); color: #065f46; }
.alert-danger  { background: var(--expense-light); border-color: rgba(224,36,36,.2); color: #7f1d1d; }
.alert-info    { background: var(--info-light);    border-color: rgba(2,132,199,.2); color: #0c4a6e; }
.alert-warning { background: var(--warning-light); border-color: rgba(217,119,6,.2); color: #78350f; }

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown-menu { border-radius: var(--radius-md); border-color: var(--border-light); box-shadow: var(--shadow-lg); font-size: .875rem; }
.dropdown-item { color: var(--text-sub); padding: .5rem 1rem; }
.dropdown-item:hover { background: var(--accent-light); color: var(--accent); }

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
    body { font-size: 14px; }

    .page-title { font-size: 1.2rem; }

    /* Compact navbar on mobile */
    #mainNav { min-height: 54px; }
    .brand-text { font-size: .9rem; }
    .brand-sub  { display: none; }

    /* Stats grid: 2 columns on mobile */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
    .stat-card  { padding: .9rem .875rem; }
    .stat-card-value { font-size: 1.15rem; }

    /* Full-width filter bar items on mobile */
    .filter-bar .row > [class*="col-"] { }

    /* Hide less important table columns on mobile (use cards instead) */
    .table-mobile-hide { display: none !important; }

    /* Compact card body on mobile */
    .card-body { padding: .875rem; }
    .settings-section-body { padding: .875rem; }

    /* Login card: more padding on small screens */
    .login-card { padding: 1.5rem; }

    /* Split card compact */
    .split-card { padding: 1.1rem; }

    /* Type toggle stacked nicely */
    .type-toggle-group { gap: .5rem; }
    .type-btn { padding: .75rem .5rem; }
    .type-btn i { font-size: 1.2rem; }

    /* Page hero compact */
    .page-hero { margin-bottom: 1rem; padding-bottom: .75rem; }

    /* Collapse long nav links */
    #navMenu .nav-link { padding: .55rem 1rem; border-radius: 0; }
    #navMenu .navbar-nav { padding: .5rem 0; }

    /* Bottom safe area for iOS */
    .app-footer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card-value { font-size: 1rem; }
    .btn-primary-custom { padding: .45rem .85rem; font-size: .85rem; }
}

/* PWA standalone mode adjustments */
@media (display-mode: standalone) {
    #mainNav { padding-top: env(safe-area-inset-top, 0px); }
    body { padding-top: 0; }
}
