/* InvoicePro — Professional Dark Theme */
/* Font: Syne (headings) + DM Sans (body) + JetBrains Mono (numbers) */

:root {
    --bg: #0d0f14;
    --bg-card: #141720;
    --bg-input: #1c2030;
    --bg-hover: #1e2335;
    --sidebar-bg: #10131a;
    --sidebar-width: 250px;

    --border: #252a3a;
    --border-light: #1e2438;

    --text-primary: #e8eaf0;
    --text-secondary: #7c85a0;
    --text-muted: #4d566e;

    --accent: #4f7cff;
    --accent-hover: #6b91ff;
    --accent-glow: rgba(79, 124, 255, 0.15);

    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.1);
    --cyan: #06b6d4;
    --cyan-bg: rgba(6, 182, 212, 0.1);
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.1);

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;

    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.brand-name {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

.nav-section {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 14px 8px 6px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(79,124,255,0.2); }
.nav-item i { width: 18px; text-align: center; font-size: 0.95rem; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

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

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.logout-btn {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}
.logout-btn:hover { color: var(--red); }

/* ──────────────────── MAIN CONTENT ──────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-title {
    font-family: var(--font-head);
    font-size: 1.05rem;
    font-weight: 700;
    flex: 1;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
}

.top-bar-actions { display: flex; align-items: center; gap: 10px; }
.page-content { padding: 28px; flex: 1; }

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

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

.card-title {
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ──────────────────── STAT CARDS ──────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--accent); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--accent-glow); color: var(--accent); }
.stat-icon.green  { background: var(--green-bg); color: var(--green); }
.stat-icon.red    { background: var(--red-bg); color: var(--red); }
.stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-icon.cyan   { background: var(--cyan-bg); color: var(--cyan); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* ──────────────────── TABLES ──────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }

tbody td {
    padding: 12px 16px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody td:first-child { color: var(--text-primary); font-weight: 500; }
.mono { font-family: var(--font-mono); }

/* ──────────────────── BADGES ──────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success  { background: var(--green-bg); color: var(--green); }
.badge-danger   { background: var(--red-bg); color: var(--red); }
.badge-warning  { background: var(--yellow-bg); color: var(--yellow); }
.badge-info     { background: var(--cyan-bg); color: var(--cyan); }
.badge-secondary { background: rgba(124,133,160,0.1); color: var(--text-secondary); }
.badge-dark     { background: rgba(30,36,56,0.8); color: var(--text-muted); }
.badge-purple   { background: var(--purple-bg); color: var(--purple); }

/* ──────────────────── BUTTONS ──────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-sm { padding: 6px 13px; font-size: 0.82rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }

.btn-secondary { background: var(--bg-input); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-success { background: var(--green-bg); color: var(--green); border-color: rgba(34,197,94,0.3); }
.btn-success:hover { background: var(--green); color: #fff; }

.btn-danger { background: var(--red-bg); color: var(--red); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-warning { background: var(--yellow-bg); color: var(--yellow); border-color: rgba(245,158,11,0.3); }
.btn-warning:hover { background: var(--yellow); color: #fff; }

.btn-whatsapp { background: rgba(37,211,102,0.1); color: #25d366; border-color: rgba(37,211,102,0.3); }
.btn-whatsapp:hover { background: #25d366; color: #fff; }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ──────────────────── FORMS ──────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%237c85a0'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.input-group { position: relative; }
.input-group .prefix {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 0.9rem; pointer-events: none;
}
.input-group .form-control { padding-left: 32px; }

/* ──────────────────── ALERTS ──────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin: 0 28px 16px;
}

.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.alert-danger   { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.alert-warning  { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.alert-info     { background: var(--cyan-bg); color: var(--cyan); border: 1px solid rgba(6,182,212,0.3); }

/* ──────────────────── PAGINATION ──────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.page-link:hover, .page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ──────────────────── PAGE HEADERS ──────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.page-header p { color: var(--text-secondary); font-size: 0.875rem; margin-top: 2px; }

/* ──────────────────── INVOICE ITEMS TABLE ──────────────────── */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
    background: var(--bg);
    padding: 10px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.items-table td { padding: 8px; vertical-align: middle; }
.items-table td .form-control { background: var(--bg); border-color: var(--border-light); }
.items-table td .form-control:focus { background: var(--bg-input); border-color: var(--accent); }
.remove-item { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 4px; transition: color var(--transition); }
.remove-item:hover { color: var(--red); }

/* ──────────────────── INVOICE TOTALS ──────────────────── */
.totals-section {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-top: 16px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.total-row:last-child { border-bottom: none; }

.total-row.grand-total {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-top: 12px;
    margin-top: 4px;
}

/* ──────────────────── LOGIN PAGE ──────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    margin-left: 0;
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .brand-icon {
    width: 60px; height: 60px;
    border-radius: var(--radius);
    font-size: 28px;
    margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent);
    box-shadow: 0 0 40px var(--accent-glow);
}

.login-logo h1 {
    font-family: var(--font-head);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.login-logo p { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

/* ──────────────────── MODAL ──────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }

/* ──────────────────── SEARCH BAR ──────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrap .form-control { padding-left: 36px; }

/* ──────────────────── INVOICE PRINT ──────────────────── */
.invoice-view-wrap {
    max-width: 820px;
    margin: 0 auto;
}

/* ──────────────────── OVERDUE HIGHLIGHT ──────────────────── */
.row-overdue td { border-left: 3px solid var(--red); }

/* ──────────────────── ACTIONS COL ──────────────────── */
.actions { display: flex; align-items: center; gap: 6px; }

/* ──────────────────── MOBILE ──────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .top-bar { padding: 12px 16px; }
    .btn-text { display: none; }
}

/* ──────────────────── UTILITIES ──────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--yellow); }
.text-accent { color: var(--accent); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
