/* ─── Ledger One - Stylesheet ─── */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
}

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

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

/* ─── Navbar ─── */
.navbar {
    background: #1a1a2e;
    color: white;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left { display: flex; align-items: center; gap: 1rem; }
.nav-brand {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.nav-account {
    background: var(--primary);
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-link {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}
.nav-link:hover { color: white; }
.nav-logout { color: #f87171; }
.nav-user {
    color: #94a3b8;
    font-size: 0.8rem;
    padding-left: 0.5rem;
    border-left: 1px solid #334155;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ─── Container ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ─── Flash Messages ─── */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ─── Login ─── */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}
.login-title {
    text-align: center;
    font-size: 2rem;
    color: #1a1a2e;
    margin-bottom: 0.25rem;
}
.login-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* ─── Account Selector ─── */
.accounts-container { text-align: center; }
.accounts-container h1 { margin-bottom: 2rem; }
.account-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}
.account-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    border-top: 4px solid var(--primary);
}
.account-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.account-card.account-personal { border-top-color: #8b5cf6; }
.account-card.account-business { border-top-color: var(--primary); }
.account-type-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}
.account-card h2 { margin-bottom: 1rem; }
.balance-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
}
.balance-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}
.balance-amount.negative { color: var(--danger); }

/* ─── Ledger ─── */
.ledger-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.ledger-header h1 { flex: 1; }
.ledger-balance {
    font-size: 1.25rem;
    font-weight: 600;
}
.ledger-balance .negative { color: var(--danger); }

.filter-bar {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.filter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.filter-form input, .filter-form select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
}

/* ─── Tables ─── */
.table-responsive { overflow-x: auto; }
.ledger-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 0.875rem;
}
.ledger-table th {
    background: #f1f5f9;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.ledger-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
}
.ledger-table tr:hover { background: #f8fafc; }
.ledger-table tr.reconciled { background: #f0fdf4; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.deposit { color: var(--success); font-weight: 500; }
.debit { color: var(--danger); font-weight: 500; }
.negative { color: var(--danger); }
.memo-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    font-size: 0.75rem;
}
.badge-reconciled { background: #dcfce7; color: var(--success); }
.badge-pending { background: #f1f5f9; color: var(--text-light); }

.actions { white-space: nowrap; }
.empty-state { padding: 2rem; color: var(--text-light); }

/* ─── Forms ─── */
.form-container { max-width: 600px; }
.form-container h1 { margin-bottom: 1.5rem; }
.entry-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-row { display: flex; gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.inline-form input, .inline-form select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.card h3 { margin-bottom: 1rem; color: var(--text); }

/* ─── Categories ─── */
.category-list { display: flex; flex-direction: column; gap: 0.5rem; }
.category-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
}
.category-item:last-child { border-bottom: none; }

/* ─── Buttons ─── */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}
.btn:hover { background: #f1f5f9; }
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-outline { background: transparent; }
.btn-full { width: 100%; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .nav-right {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #1a1a2e;
        flex-direction: column;
        padding: 1rem;
        gap: 0.75rem;
    }
    .nav-right.open { display: flex; }
    .nav-toggle { display: block; }
    .nav-user { border-left: none; padding-left: 0; }

    .form-row { flex-direction: column; }
    .filter-form { flex-direction: column; }
    .filter-form input, .filter-form select { width: 100%; }

    .ledger-header { flex-direction: column; align-items: flex-start; }
    .account-cards { grid-template-columns: 1fr; }
}
