/* assets/css/app.css */
:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-primary: #0d6efd;
    --color-primary-hover: #0b5ed7;
    --color-danger: #dc3545;
    --color-danger-bg: #fdecea;
    --color-success: #198754;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
}

/* ---------- Layout ---------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.container--narrow {
    max-width: 480px;
}

/* ---------- Auth Screen (Login) ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #eef2ff 0%, #f4f6f8 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}

.auth-brand__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 26px;
    margin-bottom: 12px;
}

.auth-brand__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.auth-brand__subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
    margin: 4px 0 0;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--color-text);
    transition: border-color .15s, box-shadow .15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
    line-height: 1.2;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}
.btn--primary:hover { background: var(--color-primary-hover); }

.btn--block { width: 100%; }

.btn--ghost {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn--ghost:hover { background: #f1f5f9; }

/* ---------- Alerts ---------- */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: #f5c6cb;
}

.alert--success {
    background: #e7f5ec;
    color: var(--color-success);
    border-color: #c3e6cb;
}

/* ---------- App Shell (Dashboard) ---------- */
.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
    color: var(--color-text);
    text-decoration: none;
}

.app-header__brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.app-main {
    padding: 28px 0 60px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 6px;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 14px;
    margin: 0 0 24px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.card__title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 14px;
}

/* ---------- Grid of Stat Cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat__label {
    font-size: 13px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0 0 6px;
}

.stat__value {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

/* ---------- Responsive Breakpoints ---------- */
@media (min-width: 640px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .auth-card {
        padding: 36px 32px;
    }
}

@media (min-width: 960px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .page-title { font-size: 26px; }
}

/* ---------- Print (nice-to-have for invoices later) ---------- */
@media print {
    .app-header, .btn { display: none !important; }
    body { background: #fff; }
}


/* ============================================================
   SIDEBAR LAYOUT
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
}

.sidebar.is-open {
    transform: translateX(0);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px;
    border-bottom: 1px solid #1e293b;
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
}

.sidebar__brand-icon {
    font-size: 22px;
}

.sidebar__nav {
    padding: 12px 0;
    flex: 1;
}

.sidebar__section {
    padding: 16px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    font-weight: 600;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}

.sidebar__link:hover {
    background: #1e293b;
    color: #ffffff;
}

.sidebar__link.is-active {
    background: #1e293b;
    color: #ffffff;
    border-left-color: #0d6efd;
}

.sidebar__icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ---------- Overlay (mobile) ---------- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    z-index: 40;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ---------- Main content area ---------- */
.app-content {
    flex: 1;
    min-width: 0;
    width: 100%;
}

/* ---------- Mobile top bar (hamburger) ---------- */
.app-header__menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    color: var(--color-text);
    padding: 0;
}

.app-header__menu-btn:hover {
    background: #f1f5f9;
}

/* ---------- Responsive: show sidebar on desktop ---------- */
@media (min-width: 960px) {
    .sidebar {
        transform: translateX(0);
    }

    .app-content {
        margin-left: 250px;
    }

    .app-header__menu-btn {
        display: none;
    }

    .sidebar-overlay {
        display: none;
    }
}

.stat__meta {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 4px 0 0;
}

/* ---------- Tables ---------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ---------- Stat grid: 6 cards responsive ---------- */
@media (min-width: 640px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 960px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    line-height: 1.6;
}

.badge--success {
    background: #d1fae5;
    color: #065f46;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
    margin: 24px 0 8px;
}

.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--color-text);
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, border-color .15s;
}

.pagination__link:hover {
    background: #f1f5f9;
}

.pagination__link.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.pagination__link.is-disabled {
    color: #cbd5e1;
    pointer-events: none;
    background: #f8fafc;
}

.pagination__ellipsis {
    padding: 0 4px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ---------- Table: padding for edge cells ---------- */
.table thead th:first-child,
.table tbody td:first-child {
    padding-left: 20px;
}

.table thead th:last-child,
.table tbody td:last-child {
    padding-right: 20px;
}
/* Payment link input row */
.pay-link-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.pay-link-row .form-input {
    font-size: 12px;
    padding: 8px;
}

/* ---------- Warning badge (for "sent" status) ---------- */
.badge--warning {
    background: #fef3c7;
    color: #92400e;
}

/* ---------- Danger badge (for "cancelled" status) ---------- */
.badge--danger {
    background: #fee2e2;
    color: #991b1b;
}

/* ---------- Truncate long descriptions in table ---------- */
.table td.truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.badge--danger {
    background: #fee2e2;
    color: #991b1b;
}
