/* ═══════════════════════════════════════════════════════════════════
   CEO Payment Portal — Premium Stylesheet
   Fonts: Playfair Display (headings) + Inter (body)
   Palette: Deep navy accent, gold highlights, soft neutrals
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
    --accent:       #1a2744;
    --accent-light: #2a3d66;
    --gold:         #c9a84c;
    --gold-light:   #e8d48b;
    --green:        #16a34a;
    --green-bg:     #dcfce7;
    --green-text:   #166534;
    --amber:        #d97706;
    --amber-bg:     #fef3c7;
    --amber-text:   #92400e;
    --red:          #dc2626;
    --red-bg:       #fee2e2;
    --red-text:     #991b1b;

    --bg:           #f5f5f0;
    --bg-card:      #ffffff;
    --text:         #1e293b;
    --text-muted:   #64748b;
    --border:       #e2e8f0;
    --border-focus: var(--accent);
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:    0 10px 30px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
    --radius:       12px;
    --radius-sm:    8px;
    --transition:   0.2s ease;
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    line-height: 1.3;
    color: var(--accent);
}

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

img { max-width: 100%; }

/* ── Login Page ────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--accent) 0%, #0f172a 100%);
    padding: 1.5rem;
}

.login-container { width: 100%; max-width: 420px; text-align: center; }

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2.5rem 2rem 2rem;
    box-shadow: var(--shadow-lg);
}

.login-logo { margin-bottom: 1.5rem; }
.login-logo h1 { font-size: 1.5rem; margin-top: 0.75rem; color: var(--accent); }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

.logo-icon { display: inline-block; }

.login-footer {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    margin-top: 1.5rem;
}

/* ── Top Bar ───────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    gap: 1rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.brand-name {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    white-space: nowrap;
}

.topbar-tabs { display: flex; gap: 0.25rem; }

.tab-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tab-link.active { background: rgba(255,255,255,0.15); color: var(--gold-light); }

.tab-icon { font-size: 1rem; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Role Badge ────────────────────────────────────────────────── */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.role-admin { background: var(--gold); color: var(--accent); }
.role-ceo   { background: rgba(255,255,255,0.2); color: #fff; border: 1px solid rgba(255,255,255,0.3); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-light); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-outline {
    background: transparent;
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.25);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); color: #fff; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.btn-block { width: 100%; }

.btn-logout { }

.active-link { background: rgba(255,255,255,0.12); }

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
    max-width: 1300px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ── Summary Cards ─────────────────────────────────────────────── */
.summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border-left: 4px solid var(--border);
    transition: transform var(--transition), box-shadow var(--transition);
}

.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.summary-card.accent  { border-left-color: var(--gold); }
.summary-card.card-green { border-left-color: var(--green); }
.summary-card.card-amber { border-left-color: var(--amber); }

.summary-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.summary-value {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.summary-value.accent { color: var(--accent); }

.summary-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.card-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.card-narrow { max-width: 520px; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26, 39, 68, 0.1);
}

input[type="file"].form-control {
    padding: 0.45rem 0.6rem;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 1.25rem;
    align-items: end;
}

.fg-wide { grid-column: 1 / -1; }
.fg-btn { display: flex; align-items: end; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: #f8f9fa;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #f8f9fb; }
.data-table tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.no-wrap { white-space: nowrap; }
.fw-600 { font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }

.actions-cell {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form { display: inline; }

.link-file {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.link-file:hover { color: var(--gold); }

/* ── Status Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }

.received-date {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── Table Footer / Totals ─────────────────────────────────────── */
.table-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 0.75rem 0.25rem;
    border-top: 2px solid var(--border);
    margin-top: 0.5rem;
}

.footer-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.footer-stat span {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

.footer-stat strong {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--text);
}

.footer-stat.stat-green strong { color: var(--green); }
.footer-stat.stat-amber strong { color: var(--amber); }
.footer-stat.accent-stat strong { color: var(--accent); }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }
.empty-state p { font-size: 1rem; }

/* ── Alerts & Toasts ───────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.alert-error { background: var(--red-bg); color: var(--red-text); border: 1px solid #fca5a5; }

.toast {
    position: fixed;
    top: 76px;
    right: 1.5rem;
    z-index: 200;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 420px;
    animation: slideIn 0.3s ease;
    transition: opacity 0.4s ease;
}

.toast-success { background: var(--green-bg); color: var(--green-text); border: 1px solid #86efac; }
.toast-error   { background: var(--red-bg); color: var(--red-text); border: 1px solid #fca5a5; }

.toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    line-height: 1;
}
.toast-close:hover { opacity: 1; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.modal-header h3 { font-size: 1.15rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--red); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ── Info Table (settings) ─────────────────────────────────────── */
.info-table { width: 100%; }
.info-table td { padding: 0.5rem 0; font-size: 0.9rem; }
.info-table td:first-child { font-weight: 600; color: var(--text-muted); width: 40%; }

/* ── Utility ───────────────────────────────────────────────────── */
.mb-1 { margin-bottom: 0.75rem; }
.mt-2 { margin-top: 1.5rem; }

/* ── Dark outline button (visible on white bg) ─────────────────── */
.btn-outline-dark {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--border);
}
.btn-outline-dark:hover { background: var(--bg); color: var(--accent); }

/* ── Mobile / Desktop visibility toggles ──────────────────────── */
.mobile-only  { display: none; }
.desktop-only { display: block; }

/* ── Mobile Card Layout ────────────────────────────────────────── */
.mobile-cards { display: flex; flex-direction: column; gap: 0.75rem; }

.m-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    border-left: 4px solid var(--border);
}
.m-card-pending  { border-left-color: var(--amber); }
.m-card-received { border-left-color: var(--green); }

.m-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.m-card-amount {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.m-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
}

.m-card-desc {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.m-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    align-items: center;
}

.m-card-received-info {
    font-size: 0.78rem;
    color: var(--green-text);
    background: var(--green-bg);
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.m-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

.m-card-form { flex: 1; }

/* Big "Mark as Received" button for CEO on mobile */
.btn-mobile-receive {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    -webkit-tap-highlight-color: transparent;
}

/* ── Responsive ────────────────────────────────────────────────── */

/* Tablet: ≤ 768px */
@media (max-width: 768px) {
    html { font-size: 15px; }

    .topbar-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .topbar-brand { order: 1; }
    .topbar-right { order: 2; margin-left: auto; }
    .topbar-tabs  { order: 3; width: 100%; }

    .tab-link {
        flex: 1;
        justify-content: center;
        padding: 0.6rem 0.5rem;
        min-height: 44px;   /* touch target */
    }

    .brand-name { font-size: 0.95rem; }

    .summary-row { grid-template-columns: 1fr 1fr; }

    .form-row-grid { grid-template-columns: 1fr; }
    .fg-wide { grid-column: auto; }

    .main-content { padding: 1rem; }

    .card { padding: 1rem; }

    .data-table { font-size: 0.82rem; }
    .data-table th, .data-table td { padding: 0.5rem 0.4rem; }

    .actions-cell { flex-direction: column; gap: 0.25rem; }

    .table-footer { gap: 1rem; }

    .toast {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    /* Buttons: bigger touch targets */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; padding: 0.45rem 0.85rem; font-size: 0.85rem; }

    /* Modal: slide up from bottom on mobile */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
        border-radius: var(--radius) var(--radius) 0 0;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1.25rem 1.25rem 2rem;
    }
    .modal-overlay.open .modal { transform: translateY(0); }
    .modal .modal-close { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

    /* Form controls: bigger for fingers */
    .form-control {
        padding: 0.75rem 0.9rem;
        font-size: 1rem;
        min-height: 48px;
    }
    input[type="file"].form-control { min-height: auto; padding: 0.6rem 0.7rem; }
}

/* Phone: ≤ 600px — switch to card layout */
@media (max-width: 600px) {
    .mobile-only  { display: block; }
    .desktop-only { display: none !important; }

    html { font-size: 14.5px; }

    .summary-row { grid-template-columns: 1fr; gap: 0.65rem; }
    .summary-card { padding: 1rem 1.15rem; }
    .summary-value { font-size: 1.35rem; }

    .main-content { padding: 0.75rem; }
    .card { padding: 0.85rem; border-radius: var(--radius-sm); }
    .card-title { font-size: 1.1rem; margin-bottom: 0.75rem; padding-bottom: 0.5rem; }

    .table-footer {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.85rem 0.5rem;
    }
    .footer-stat { flex-direction: row; justify-content: space-between; align-items: center; }
    .footer-stat strong { font-size: 1.05rem; }

    /* Topbar compact */
    .topbar-inner { padding: 0.4rem 0.75rem; gap: 0.35rem; }
    .brand-name { font-size: 0.88rem; }
    .topbar-brand svg { width: 26px; height: 26px; }
    .role-badge { font-size: 0.7rem; padding: 0.15rem 0.55rem; }
    .btn-logout { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

    .tab-link {
        font-size: 0.88rem;
        padding: 0.55rem 0.35rem;
        gap: 0.25rem;
    }

    /* Settings narrow card full width */
    .card-narrow { max-width: 100%; }
}

/* Very small phones: ≤ 380px */
@media (max-width: 380px) {
    html { font-size: 14px; }
    .m-card-amount { font-size: 1.1rem; }
    .summary-value { font-size: 1.15rem; }
    .topbar-right .btn-sm:not(.btn-logout) { display: none; }  /* hide settings gear, keep logout */
}

/* ── Print Styles ──────────────────────────────────────────────── */
@media print {
    body { background: #fff; }
    .topbar { position: static; background: #fff; color: #000; box-shadow: none; border-bottom: 2px solid #000; }
    .topbar-brand, .tab-link.active { color: #000; }
    .topbar-right .btn, .tab-link:not(.active) { display: none; }
    .role-badge { border: 1px solid #000; color: #000; background: none; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .summary-card { box-shadow: none; border: 1px solid #ccc; }
    .btn-success, .btn-danger, .btn-outline, .btn-primary { display: none; }
    .toast, .modal-overlay { display: none; }
    .summary-card:hover { transform: none; }
}
