/* Axiam BookKeeper - Main Stylesheet */

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

:root {
    --bg-base:       #0f1117;
    --bg-surface:    #161b27;
    --bg-elevated:   #1e2638;
    --bg-hover:      #252e42;
    --border:        #2a3347;
    --border-light:  #1e2638;

    --accent:        #6366f1;
    --accent-hover:  #4f52d9;
    --accent-soft:   rgba(99,102,241,0.12);
    --accent-glow:   rgba(99,102,241,0.3);

    --success:       #10b981;
    --success-soft:  rgba(16,185,129,0.12);
    --warning:       #f59e0b;
    --warning-soft:  rgba(245,158,11,0.12);
    --danger:        #ef4444;
    --danger-soft:   rgba(239,68,68,0.12);
    --info:          #3b82f6;
    --info-soft:     rgba(59,130,246,0.12);

    --text-primary:  #f1f5f9;
    --text-secondary:#94a3b8;
    --text-muted:    #475569;

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

    --sidebar-width: 260px;
    --topbar-height: 64px;

    --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:     0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:     0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow:   0 0 24px rgba(99,102,241,0.2);
}

html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===================== LAYOUT ===================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.logo-sub { font-size: 0.7rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-close {
    display: none;
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; padding: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section { margin-bottom: 8px; }
.nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 450;
    transition: all 0.15s ease;
    position: relative;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}
.nav-item.active svg { color: var(--accent); }

.nav-item-danger:hover { background: var(--danger-soft); color: var(--danger); }

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 20px;
    flex-shrink: 0;
}
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-success { background: var(--success-soft); color: var(--success); }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-pill {
    display: flex; align-items: center; gap: 10px;
}

.user-avatar {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.875rem;
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.user-name { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-company { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tax-year-badge {
    display: flex; align-items: center; gap: 5px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.7rem; font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
    width: fit-content;
}

/* ===================== TOPBAR ===================== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 50;
}

.topbar h1 {
    font-size: 1.05rem; font-weight: 600;
    color: var(--text-primary);
}

.menu-toggle {
    display: none;
    background: none; border: none;
    color: var(--text-secondary); cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}
.menu-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.topbar-title { flex: 1; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.nz-flag {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-elevated);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* ===================== FLASH ===================== */
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px;
    margin: 16px 28px 0;
    border-radius: var(--radius-md);
    font-size: 0.875rem; font-weight: 500;
    animation: slideDown 0.2s ease;
}
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: 0.6; }
.flash-close:hover { opacity: 1; }
.flash-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.flash-info { background: var(--info-soft); color: var(--info); border: 1px solid rgba(59,130,246,0.2); }
.flash-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }

@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ===================== CONTENT ===================== */
.content { padding: 28px; flex: 1; }

/* ===================== CARDS ===================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.card-title {
    font-size: 1rem; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}
.card-title svg { width: 16px; height: 16px; color: var(--accent); }

/* ===================== STAT CARDS ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.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::before { background: var(--success); }
.stat-card.expense::before { background: var(--danger); }
.stat-card.profit::before { background: var(--accent); }
.stat-card.tax::before { background: var(--warning); }
.stat-card.owed::before { background: var(--danger); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-card.income .stat-icon { background: var(--success-soft); color: var(--success); }
.stat-card.expense .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat-card.profit .stat-icon { background: var(--accent-soft); color: var(--accent); }
.stat-card.tax .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat-card.owed .stat-icon { background: var(--danger-soft); color: var(--danger); }

.stat-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.stat-sub.positive { color: var(--success); }
.stat-sub.negative { color: var(--danger); }

/* ===================== TABLES ===================== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }
tbody td { padding: 12px 16px; color: var(--text-secondary); vertical-align: middle; }
tbody td:first-child { color: var(--text-primary); }

.amount-positive { color: var(--success) !important; font-weight: 600; }
.amount-negative { color: var(--danger) !important; font-weight: 600; }
.amount-neutral { color: var(--text-primary) !important; font-weight: 600; }

/* ===================== FORMS ===================== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
label .required { color: var(--danger); margin-left: 2px; }

input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="password"], select, textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

select { cursor: pointer; }
textarea { resize: vertical; min-height: 90px; }

input[type="file"] {
    background: var(--bg-elevated);
    border: 2px dashed var(--border);
    color: var(--text-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    transition: border-color 0.15s;
}
input[type="file"]:hover { border-color: var(--accent); color: var(--accent); }

.form-hint { font-size: 0.72rem; color: var(--text-muted); }

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem; font-weight: 500;
    font-family: inherit;
    cursor: pointer; border: none;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); }

.btn-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.btn-success:hover { background: var(--success); color: white; }

.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* ===================== PAGE HEADER ===================== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header-left h2 { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.page-header-left p { font-size: 0.875rem; color: var(--text-secondary); margin-top: 2px; }

/* ===================== GRID LAYOUT ===================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===================== INFO PANEL ===================== */
.info-panel {
    background: var(--info-soft);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex; gap: 10px;
    font-size: 0.8rem; color: var(--info);
    line-height: 1.5;
}
.info-panel svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.info-panel.warning { background: var(--warning-soft); border-color: rgba(245,158,11,0.2); color: var(--warning); }
.info-panel.danger { background: var(--danger-soft); border-color: rgba(239,68,68,0.2); color: var(--danger); }

/* ===================== MODAL ===================== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
}
.modal-overlay.active { display: block; }

.modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 300;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}
.modal.active { display: block; }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -48%); } to { opacity: 1; transform: translate(-50%, -50%); } }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); }
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===================== PILLS / TAGS ===================== */
.pill {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem; font-weight: 600;
}
.pill-green { background: var(--success-soft); color: var(--success); }
.pill-red { background: var(--danger-soft); color: var(--danger); }
.pill-yellow { background: var(--warning-soft); color: var(--warning); }
.pill-blue { background: var(--info-soft); color: var(--info); }
.pill-purple { background: var(--accent-soft); color: var(--accent); }

/* ===================== EMPTY STATE ===================== */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: 0.3; }
.empty-state h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.875rem; max-width: 300px; margin: 0 auto 20px; }

/* ===================== DIVIDER ===================== */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ===================== SECTION ===================== */
.section-gap { margin-bottom: 24px; }

/* ===================== RECEIPT THUMB ===================== */
.receipt-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s;
}
.receipt-thumb:hover { transform: scale(1.1); }

/* ===================== BALANCE DISPLAY ===================== */
.balance-display {
    background: var(--danger-soft);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.balance-label { font-size: 0.875rem; color: var(--danger); font-weight: 500; }
.balance-amount { font-size: 2rem; font-weight: 700; color: var(--danger); }
.balance-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ===================== LOGIN ===================== */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-base);
    padding: 20px;
}
.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center; margin-bottom: 32px;
}
.login-logo .logo { justify-content: center; }
.login-tagline { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.login-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.login-card .subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ===================== CHART CONTAINER ===================== */
.chart-container { position: relative; height: 260px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
    .main-wrapper { margin-left: 0; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: flex; }
    .menu-toggle { display: flex; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 16px; }
    .balance-display { flex-direction: column; gap: 8px; text-align: center; }
}
@media (max-width: 500px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===================== MISC ===================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
