/* ========================================
   Trip Dashboard — Design Tokens & Base
   ======================================== */

:root {
    --bg: #F5F3F0;
    --card: #FFFFFF;
    --text: #1A1A1A;
    --text-muted: #6B6B6B;
    --border: #E0DCD7;
    --accent: #2563EB;
    --accent-hover: #1d4ed8;
    --green: #16A34A;
    --red: #DC2626;
    --amber: #D97706;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --font: 'DM Sans', system-ui, -apple-system, sans-serif;
}

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

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

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

/* ========================================
   Navigation
   ======================================== */

.nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.nav-brand:hover { text-decoration: none; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}
.nav-links a:hover {
    color: var(--text);
    background: var(--bg);
    text-decoration: none;
}
.nav-links a.active {
    color: var(--accent);
    background: #EFF6FF;
}
.nav-logout { color: var(--red) !important; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 4px;
}
.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
}

/* ========================================
   Layout
   ======================================== */

.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}
.page-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ========================================
   Cards
   ======================================== */

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ========================================
   Flash Messages
   ======================================== */

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.flash-success { background: #F0FDF4; color: var(--green); }
.flash-error { background: #FEF2F2; color: var(--red); }
.flash-warning { background: #FFFBEB; color: var(--amber); }
.flash-info { background: #EFF6FF; color: var(--accent); }

/* ========================================
   Forms
   ======================================== */

label {
    display: block;
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="color"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--card);
    margin-bottom: 0.75rem;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
textarea { min-height: 80px; resize: vertical; }
select { cursor: pointer; }

input[type="color"] {
    padding: 0.2rem;
    height: 38px;
    width: 60px;
    cursor: pointer;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}
.inline-form input { margin-bottom: 0; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    font-size: 0.9rem;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.form-group {
    margin-bottom: 0.75rem;
}
.form-group label { margin-bottom: 0.25rem; }

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

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

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

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }

/* ========================================
   Badges
   ======================================== */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.badge-blue { background: #EFF6FF; color: var(--accent); }
.badge-green { background: #F0FDF4; color: var(--green); }
.badge-gray { background: #F3F4F6; color: #6B7280; }
.badge-amber { background: #FFFBEB; color: var(--amber); }
.badge-red { background: #FEF2F2; color: var(--red); }

/* ========================================
   Person Color Tag
   ======================================== */

.person-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
}
.person-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ========================================
   Tables
   ======================================== */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th {
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
}
td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAF8; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }

/* ========================================
   Amount Colors
   ======================================== */

.amount-positive { color: var(--green); font-weight: 500; }
.amount-negative { color: var(--red); font-weight: 500; }
.amount-neutral { color: var(--text-muted); }

/* ========================================
   Login Page
   ======================================== */

.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}
.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.login-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.totp-alt {
    text-align: center;
    margin-top: 1rem;
}
.totp-cancel {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
}
.totp-cancel a { color: var(--text-muted); }

/* ========================================
   Profile / 2FA
   ======================================== */

.profile-info p { margin-bottom: 0.35rem; }

.qr-container {
    display: inline-block;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.manual-key {
    display: block;
    background: var(--bg);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
    user-select: all;
}

.backup-codes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}
.backup-codes-grid code {
    display: block;
    background: var(--bg);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.9rem;
    text-align: center;
}

/* ========================================
   Tabs
   ======================================== */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}
.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.6rem 1rem;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ========================================
   Trip Cards
   ======================================== */

.trip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.trip-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    transition: box-shadow 0.15s;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: block;
}
.trip-card:hover {
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}
.trip-card h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}
.trip-card .trip-dest {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.trip-card .trip-dates {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.trip-card .trip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

/* ========================================
   Section Headers
   ======================================== */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.section-header h2 { margin-bottom: 0; }

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ========================================
   Filter Bar
   ======================================== */

.filter-bar {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filter-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--text-muted); color: var(--text); }
.filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ========================================
   Deadline Highlights
   ======================================== */

.deadline-warning { color: var(--amber); font-weight: 500; }
.deadline-passed { color: var(--red); font-weight: 500; }

/* ========================================
   Dashboard
   ======================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.dashboard-grid .card-full { grid-column: 1 / -1; }

.timeline-container {
    overflow-x: auto;
    padding: 0.5rem 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ========================================
   Membership
   ======================================== */

.membership-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.membership-card h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.membership-detail {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 1rem;
    font-size: 0.85rem;
}
.membership-detail dt { color: var(--text-muted); font-weight: 500; }
.membership-detail dd { color: var(--text); }

.masked-number {
    font-family: monospace;
    cursor: pointer;
    user-select: none;
}

.expiry-warning { color: var(--amber); font-weight: 500; }
.expiry-critical { color: var(--red); font-weight: 500; }

/* ========================================
   Utility Classes
   ======================================== */

.mt-05 { margin-top: 0.25rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.hidden { display: none; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .nav-toggle { display: flex; }
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 0.5rem;
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 0.6rem 1rem; }

    .dashboard-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .trip-grid { grid-template-columns: 1fr; }

    .container { padding: 1rem; }
    .card { padding: 1rem; }
}

@media (max-width: 480px) {
    .login-card { padding: 1.5rem; }
    .backup-codes-grid { grid-template-columns: 1fr; }
}
