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

:root {
    /* Synaptiq Primary Palette */
    --soil: #312A29;
    --apricot: #F7CFA5;
    --arctic: #A1B8CA;
    /* Synaptiq Secondary */
    --mint: #C6E1D9;
    --sky: #B6DDED;
    --fog: #E2E1E3;
    --agave: #6A888D;
    /* Synaptiq Tertiary */
    --hale-navy: #494F5B;
    --pine: #1D6E6F;
    --jasper: #CC5E58;
    --parchment: #F6F2D6;
    --blush: #F1DCD0;

    /* Semantic mappings */
    --bg: #f4f1ee;
    --surface: #ffffff;
    --border: #E2E1E3;
    --text: #312A29;
    --text-secondary: #6A888D;
    --primary: #494F5B;
    --primary-hover: #312A29;
    --danger: #CC5E58;
    --danger-hover: #a84a45;
    --success: #1D6E6F;
    --success-bg: #e8f4f0;
    --error-bg: #fdf0ee;
    --error: #CC5E58;
    --accent: #F7CFA5;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(49,42,41,0.06), 0 1px 2px rgba(49,42,41,0.04);
    --shadow-lg: 0 10px 25px rgba(49,42,41,0.08), 0 4px 10px rgba(49,42,41,0.04);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

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

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo:hover { text-decoration: none; }
.navbar-logo { height: 36px; width: auto; }
.logo-icon { color: var(--apricot); font-size: 20px; }
.logo-icon.large { font-size: 48px; }

.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ── Container ───────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 28px; font-weight: 700; }
.subtitle { color: var(--text-secondary); margin-top: 4px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb { margin-bottom: 16px; }
.breadcrumb a { color: var(--text-secondary); font-size: 14px; }
.breadcrumb a:hover { color: var(--text); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    gap: 6px;
}
.btn:hover { background: var(--bg); text-decoration: none; }

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

.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--error-bg); }

.btn-secondary { background: var(--surface); }

.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-large { padding: 12px 24px; font-size: 16px; }
.btn-full { width: 100%; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    color: var(--text-secondary);
    border-radius: 4px;
}
.btn-icon:hover { background: var(--bg); }

/* ── Cards ───────────────────────────────────────────────── */
.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.deck-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: box-shadow 0.2s;
}
.deck-card:hover { box-shadow: var(--shadow-lg); }
.deck-card.inactive { opacity: 0.6; }

.deck-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.deck-card-header h3 { font-size: 18px; font-weight: 600; }
.deck-card-header a { color: var(--text); }
.deck-card-header a:hover { color: var(--primary); text-decoration: none; }

.deck-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.deck-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 12px;
}
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

.deck-meta { font-size: 13px; color: var(--text-secondary); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-active { background: #e8f4f0; color: var(--pine); }
.badge-inactive { background: #f3f4f6; color: var(--text-secondary); }

/* ── Tables ──────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 14px;
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .row-inactive { opacity: 0.5; }

.link-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}
.share-url {
    font-size: 12px;
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 4px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--arctic);
    box-shadow: 0 0 0 3px rgba(161, 184, 202, 0.3);
}

.optional { color: var(--text-secondary); font-weight: 400; }
.form-hint { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.input-inline {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    min-width: 280px;
}
.input-inline:focus {
    outline: none;
    border-color: var(--arctic);
    box-shadow: 0 0 0 3px rgba(161, 184, 202, 0.3);
}

.input-large {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: var(--font);
    text-align: center;
}
.input-large:focus {
    outline: none;
    border-color: var(--arctic);
    box-shadow: 0 0 0 3px rgba(161, 184, 202, 0.3);
}

/* ── File Upload ─────────────────────────────────────────── */
.file-upload {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.file-upload:hover { border-color: var(--arctic); background: rgba(161,184,202,0.06); }
.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-upload-icon { font-size: 24px; display: block; margin-bottom: 8px; color: var(--text-secondary); }
.file-upload-label { color: var(--text-secondary); font-size: 14px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    z-index: 1;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { font-size: 20px; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

/* ── Flash Messages ──────────────────────────────────────── */
.flash-messages { margin-bottom: 24px; }
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 8px;
    word-break: break-all;
}
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--error-bg); color: var(--error); }

/* ── Stats Grid (Analytics) ──────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}
.stat-card-value { font-size: 36px; font-weight: 700; color: var(--text); }
.stat-card-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Chart ───────────────────────────────────────────────── */
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-height: 200px;
}
.chart-empty { text-align: center; color: var(--text-secondary); padding: 60px 0; }
.chart-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.chart-bar-label { font-size: 13px; color: var(--text-secondary); min-width: 80px; text-align: right; }
.chart-bar-track { flex: 1; height: 28px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--arctic); border-radius: 4px; min-width: 2px; transition: width 0.3s; display: flex; align-items: center; padding-left: 8px; }
.chart-bar-value { font-size: 12px; font-weight: 600; color: var(--soil); }

/* ── Sections ────────────────────────────────────────────── */
.section { margin-bottom: 40px; }
.section h2 { font-size: 20px; font-weight: 600; margin-bottom: 16px; }

.muted { color: var(--text-secondary); font-size: 14px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}
.empty-icon { font-size: 64px; color: var(--apricot); margin-bottom: 16px; opacity: 0.6; }
.empty-state h2 { font-size: 24px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 24px; }

/* ── Viewer Pages ────────────────────────────────────────── */
.viewer-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8edf2 0%, #f4f1ee 50%, #f1e8e0 100%);
}
.gate-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.gate-logo { margin-bottom: 24px; }
.gate-logo-img { height: 48px; width: auto; }
.gate-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.gate-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 15px; }
.gate-form { text-align: left; }
.gate-form .form-group { margin-bottom: 16px; }
.gate-footer {
    margin-top: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.powered-label { font-size: 7px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.powered-logo { height: 60px; width: auto; }
.topbar-logo { height: 26px; width: auto; vertical-align: middle; }

/* ── Deck Viewer Frame ───────────────────────────────────── */
.viewer-frame-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.viewer-topbar {
    height: 66px;
    background: var(--fog);
    color: var(--soil);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 14px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.viewer-topbar-title { font-weight: 500; }
.viewer-topbar-brand { font-size: 12px; }
.deck-iframe {
    flex: 1;
    width: 100%;
    border: none;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .container { padding: 20px 16px; }
    .page-header { flex-direction: column; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .input-inline { min-width: auto; }
    .gate-card { padding: 32px 24px; margin: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
