/* static/css/app.css */

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

:root {
    --white:       #FFFFFF;
    --bg:          #F7F8FA;
    --border:      #E2E6EA;
    --text:        #1E293B;
    --text-muted:  #64748B;
    --accent:      #3B82F6;
    --accent-dark: #2563EB;
    --success:     #22C55E;
    --danger:      #EF4444;
    --warning:     #F59E0B;
    --radius:      10px;
    --shadow:      0 1px 4px rgba(0,0,0,0.08);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
}

html, body {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: 'DM Serif Display', serif;
    line-height: 1.2;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

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

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-full { width: 100%; justify-content: center; }

/* ── Form elements ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Cards ── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert-error {
    background: #FEF2F2;
    color: #B91C1C;
    border-color: #FECACA;
}

.alert-success {
    background: #F0FDF4;
    color: #15803D;
    border-color: #BBF7D0;
}

/* ── Auth layout ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo h1 {
    font-size: 28px;
    color: var(--text);
}

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

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

/* ── App Shell ── */

.app-body {
    background: var(--bg);
}

.topnav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.topnav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topnav-logo {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    color: var(--text);
    text-decoration: none;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topnav-email {
    font-size: 13px;
    color: var(--text-muted);
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

.app-layout {
    display: flex;
    padding-top: 60px;
    min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--white);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 90;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

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

.nav-item.active {
    background: #EFF6FF;
    color: var(--accent);
}

.nav-item.active svg {
    stroke: var(--accent);
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 4px;
}

.sidebar-overlay {
    display: none;
}

/* ── Main content ── */

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 32px;
    min-height: calc(100vh - 60px);
}

/* ── Page header ── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 26px;
    color: var(--text);
}

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

/* ── Stats row ── */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-family: 'DM Serif Display', serif;
    font-size: 28px;
    color: var(--text);
}

/* ── Document table ── */

.doc-table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.doc-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.doc-table-header h3 {
    font-size: 16px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 4px;
    border-radius: 8px;
}

.filter-tab {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.filter-tab:hover { color: var(--text); text-decoration: none; }
.filter-tab.active {
    background: var(--white);
    color: var(--text);
    box-shadow: var(--shadow);
}

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

thead th {
    text-align: left;
    padding: 12px 24px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

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

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }

tbody td {
    padding: 14px 24px;
    font-size: 14px;
    color: var(--text);
}

/* ── Status badges ── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-draft    { background: #F1F5F9; color: #64748B; }
.badge-sent     { background: #EFF6FF; color: #3B82F6; }
.badge-paid     { background: #F0FDF4; color: #16A34A; }
.badge-void     { background: #FEF2F2; color: #DC2626; }

/* ── Row actions ── */

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Empty state ── */

.empty-state {
    text-align: center;
    padding: 64px 24px;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }
    .action-card {
        position: static;
    }
}

@media (max-width: 768px) {
    /* Nav */
    .hamburger { display: flex; }

    .sidebar {
        left: -220px;
        transition: left 0.25s ease;
    }
    .sidebar.open { left: 0; }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.3);
        z-index: 80;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }
    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: all;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .topnav-email { display: none; }

    /* Tables — hide less important columns */
    .doc-table-wrap thead th:nth-child(3),
    .doc-table-wrap tbody td:nth-child(3) { display: none; }

    /* Stats row */
    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header div[style*="display:flex"] {
        flex-wrap: wrap;
        width: 100%;
    }

    /* Doc table */
    .doc-table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Buttons full width on mobile in forms */
    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Cards */
    .card { padding: 20px; }

    /* Auth */
    .auth-page { padding: 16px; align-items: flex-start; padding-top: 48px; }

    /* Row actions in tables */
    .row-actions { flex-direction: column; gap: 4px; }
    .row-actions .btn { font-size: 11px; padding: 4px 10px; }
}

@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr 1fr; }
    .topnav { padding: 0 14px; }
}

/* ── Upgrade / Pro ── */

.pro-badge {
    display: inline-block;
    background: #EFF6FF;
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid #BFDBFE;
    margin-left: 6px;
    vertical-align: middle;
}

.upgrade-banner {
    background: #EFF6FF;
    border: 1.5px solid #BFDBFE;
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.upgrade-banner p {
    font-size: 14px;
    color: #1E40AF;
    margin: 0;
}

.upgrade-banner strong {
    font-weight: 600;
}

.feature-locked {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
    position: relative;
}

.lock-overlay {
    background: #F7F8FA;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.lock-overlay strong {
    display: block;
    color: var(--text);
    margin-bottom: 6px;
    font-size: 15px;
}

.lock-overlay a {
    color: var(--accent);
    font-weight: 600;
}

.usage-bar-wrap {
    margin-bottom: 6px;
}

.usage-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.usage-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}

.usage-bar-fill.warn { background: var(--warning); }
.usage-bar-fill.danger { background: var(--danger); }