/* Household Budget — style.css */
/* Mobile-first, pink + lavender theme, customizable via --accent */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --accent:       #d81b60;
    --accent-light: #f06292;
    --accent-bg:    #fce4ec;
    --purple:       #ce93d8;
    --purple-light: #e1bee7;
    --green:        #2e7d32;
    --green-light:  #e8f5e9;
    --red:          #c62828;
    --red-light:    #ffebee;
    --amber:        #f57f17;
    --amber-light:  #fff8e1;
    --bg:           #f5e3ec;
    --bg2:          #edcfdb;
    --card:         #ffffff;
    --border:       #f0dce3;
    --text:         #2d1f2d;
    --muted:        #7c6b7c;
    --nav-h:        60px;
}

html { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Bottom Navigation ───────────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    height: var(--nav-h);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text);
    font-size: 10px;
    font-weight: 500;
    gap: 2px;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
    opacity: 0.5;
}

.nav-tab .nav-icon {
    font-size: 22px;
    line-height: 1;
}

.nav-tab.active {
    opacity: 1;
    font-weight: 700;
}

.nav-tab:hover {
    opacity: 0.8;
}

/* Center scan button — larger, prominent */
.nav-tab.scan-btn {
    position: relative;
    opacity: 1;
}

.nav-tab.scan-btn .nav-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    margin-top: -16px;
    box-shadow: 0 2px 12px rgba(216,27,96,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.nav-tab.scan-btn:hover .nav-icon,
.nav-tab.scan-btn:active .nav-icon {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(216,27,96,0.4);
}

.nav-tab.scan-btn .nav-label {
    font-weight: 600;
}

/* ── Main content area ───────────────────────────────────── */

.main {
    flex: 1;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0) + 8px);
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.content {
    padding: 16px;
}

/* ── Flash messages ──────────────────────────────────────── */

.flashes { margin-bottom: 14px; }

.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13.5px;
    font-weight: 500;
}

.flash.success { background: var(--green-light); color: var(--green); border-left: 4px solid #43a047; }
.flash.error   { background: var(--red-light); color: var(--red); border-left: 4px solid #ef5350; }
.flash.info    { background: #f3e5f5; color: #7b1fa2; border-left: 4px solid var(--purple); }
.flash.warning { background: var(--amber-light); color: #e65100; border-left: 4px solid var(--amber); }

/* ── Cards ───────────────────────────────────────────────── */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
}

/* ── Budget hero card (dashboard) ────────────────────────── */

.budget-hero {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 14px;
    padding: 24px 20px;
    color: #fff;
    text-align: center;
    margin-bottom: 16px;
}

.budget-hero .label {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.85;
    margin-bottom: 4px;
}

.budget-hero .amount {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.budget-hero .amount.negative {
    color: #ffcdd2;
}

.budget-hero .sub {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 6px;
}

/* ── Stat cards ──────────────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.stat-card .label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-card .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.stat-card .value.positive { color: var(--green); }
.stat-card .value.negative { color: var(--red); }

/* ── Section titles ──────────────────────────────────────── */

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    margin-top: 8px;
}

/* ── Tables ──────────────────────────────────────────────── */

.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg2);
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

thead th.num { text-align: right; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-bg); }

tbody td {
    padding: 10px 12px;
    font-size: 13px;
    vertical-align: middle;
}

tbody td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

tbody td.muted { color: var(--muted); }

/* ── Badges ──────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-paid    { background: var(--green-light); color: var(--green); }
.badge-due     { background: var(--amber-light); color: #e65100; }
.badge-overdue { background: var(--red-light); color: var(--red); }

/* Card badge (colored dot + name) */
.card-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
}

.card-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* User badge */
.user-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-bg);
    color: var(--accent);
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    line-height: 1;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(0.85); }

.btn-success {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--bg2); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
    min-height: 36px;
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.btn-block {
    width: 100%;
}

/* ── Forms ────────────────────────────────────────────────── */

.form-group { margin-bottom: 14px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 5px;
}

input[type=text], input[type=password], input[type=number],
input[type=date], input[type=email], input[type=search],
input[type=color], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: var(--card);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    min-height: 44px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-hint {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 3px;
}

/* ── Filter bar ──────────────────────────────────────────── */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.filter-bar select, .filter-bar input {
    width: auto;
    min-width: 120px;
    min-height: 38px;
    padding: 6px 10px;
    font-size: 13px;
}

.search-input {
    flex: 1;
    min-width: 160px;
    position: relative;
}

.search-input input {
    padding-left: 34px;
}

.search-input::before {
    content: "🔍";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
}

/* ── Filter pills (category tabs) ────────────────────────── */

.filter-pills {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.filter-pill {
    padding: 6px 4px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    min-width: 0;
    padding-left: 10px;
}

.filter-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-pill.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.filter-pill-all {
    grid-column: 1 / -1;
    justify-content: center;
    padding-left: 4px;
}

/* ── Login page ──────────────────────────────────────────── */

.login-wrap {
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-box {
    background: var(--card);
    border-radius: 14px;
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-box h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
}

.login-box .sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.login-error {
    background: var(--red-light);
    color: var(--red);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    border-left: 4px solid var(--red);
}

/* ── Setup wizard progress ───────────────────────────────── */

.setup-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}

.setup-step {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg2);
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.setup-step.active {
    background: var(--accent);
    color: #fff;
}

/* ── Upload / Scan area ──────────────────────────────────── */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.upload-zone .upload-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.upload-zone p {
    font-size: 14px;
}

.upload-zone .hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
}

.upload-spinner {
    display: none;
    text-align: center;
    padding: 24px;
    color: var(--muted);
}

.upload-spinner.active {
    display: block;
}

/* ── Bill card (mobile-friendly) ─────────────────────────── */

.bill-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.bill-card .bill-info {
    flex: 1;
    min-width: 0;
}

.bill-card .bill-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.bill-card .bill-detail {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.bill-card .bill-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

/* ── Expense list item (mobile card view) ────────────────── */

.expense-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.expense-item .cat-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    background: var(--bg2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.expense-item .expense-info {
    flex: 1;
    min-width: 0;
}

.expense-item .expense-vendor {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-item .expense-detail {
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.expense-item .expense-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.expense-item .receipt-link {
    font-size: 11px;
    opacity: 0.5;
}

/* ── Empty state ─────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 14px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

/* ── Utilities ───────────────────────────────────────────── */

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-bold   { font-weight: 600; }

.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }

/* Hidden file input for scan */
.file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* ── Paste overlay ───────────────────────────────────────── */

.paste-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--accent);
    color: #fff;
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 16px rgba(216,27,96,0.3);
}

.paste-toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ── Settings color picker ───────────────────────────────── */

input[type=color] {
    width: 48px;
    height: 48px;
    padding: 2px;
    border-radius: 10px;
    cursor: pointer;
}

/* ── Responsive — desktop adjustments ────────────────────── */

@media (min-width: 769px) {
    .content {
        max-width: 800px;
        margin: 0 auto;
        padding: 24px;
    }

    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -2px 20px rgba(0,0,0,0.08);
    }
}

/* ── Mobile tweaks ───────────────────────────────────────── */

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .table-wrap table {
        min-width: 500px;
    }

    .login-box {
        padding: 24px 20px;
    }

    .budget-hero .amount {
        font-size: 32px;
    }
}
