/* ============================================================
   EventPlanner – PostHog-inspired design system
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
    --ph-sidebar-bg:   #1d1d20;
    --ph-sidebar-text: #c9c9d0;
    --ph-sidebar-hover:#2d2d32;
    --ph-sidebar-active: #f9bd2b;
    --ph-sidebar-width: 220px;

    --ph-bg:       #f3ede3;     /* warm cream */
    --ph-surface:  #ffffff;
    --ph-border:   #e5ddd0;
    --ph-text:     #1d1d20;
    --ph-muted:    #6b6b7a;
    --ph-accent:   #f9bd2b;     /* PostHog yellow */
    --ph-accent-hover: #f0ac10;

    --ph-danger:   #dc2626;
    --ph-success:  #16a34a;

    --radius:      8px;
    --radius-sm:   4px;
    --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:   0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);

    --font-sans:   'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ph-text);
    background: var(--ph-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layouts ─────────────────────────────────────────────────── */

/* Authenticated layout: sidebar + main */
.layout-authenticated {
    display: flex;
    min-height: 100vh;
}

/* Guest layout: full-page centered */
.layout-guest {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--ph-sidebar-bg);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: var(--ph-sidebar-width);
    min-height: 100vh;
    background: var(--ph-sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid #2d2d34;
}
.sidebar-icon { font-size: 1.4rem; }
.sidebar-title {
    font-weight: 700;
    font-size: 15px;
    color: #ffffff;
    letter-spacing: -0.01em;
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--ph-sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--ph-sidebar-hover); color: #ffffff; text-decoration: none; }
.nav-link.active { background: #2d2d34; color: var(--ph-accent); }

.nav-sub-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4a4a58;
    padding: 8px 10px 2px;
}

.nav-sub {
    padding-left: 22px;
    font-size: 13px;
    font-weight: 400;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #2d2d34;
}

.btn-logout {
    width: 100%;
    background: transparent;
    color: var(--ph-sidebar-text);
    border: 1px solid #2d2d34;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-logout:hover { background: var(--ph-sidebar-hover); color: #ffffff; }

/* ── Main content ────────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    min-width: 0;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ph-text);
    letter-spacing: -0.02em;
}
.page-subtitle {
    font-size: 13px;
    color: var(--ph-muted);
    margin-top: 2px;
}
.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.breadcrumb {
    font-size: 12px;
    color: var(--ph-muted);
    margin-bottom: 4px;
}
.breadcrumb a { color: var(--ph-muted); }
.breadcrumb a:hover { color: var(--ph-text); }

.event-meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.meta-chip {
    background: #ebe3d4;
    border: 1px solid var(--ph-border);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 12px;
    color: var(--ph-muted);
}

/* ── Card ────────────────────────────────────────────────────── */
.card {
    background: var(--ph-surface);
    border: 1px solid var(--ph-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ph-text);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.1s;
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:focus { outline: 2px solid var(--ph-accent); outline-offset: 1px; }

.btn-primary {
    background: var(--ph-accent);
    color: #1a1000;
    border-color: var(--ph-accent);
}
.btn-primary:hover { background: var(--ph-accent-hover); border-color: var(--ph-accent-hover); }

.btn-secondary {
    background: #f0e8d8;
    color: var(--ph-text);
    border-color: var(--ph-border);
}
.btn-secondary:hover { background: #e5d8c4; }

.btn-outline {
    background: transparent;
    color: var(--ph-text);
    border-color: var(--ph-border);
}
.btn-outline:hover { background: #f0e8d8; }

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

.btn-ghost {
    background: transparent;
    color: var(--ph-muted);
    border-color: transparent;
    padding: 4px 6px;
    font-size: 14px;
}
.btn-ghost:hover { background: #f0e8d8; color: var(--ph-text); }

.btn-sm   { padding: 5px 10px; font-size: 12.5px; }
.btn-xs   { padding: 3px 7px;  font-size: 11.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ph-text);
    margin-bottom: 5px;
}
.required { color: var(--ph-danger); }

.form-control {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--ph-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: #fff;
    color: var(--ph-text);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--font-sans);
}
.form-control:focus {
    outline: none;
    border-color: var(--ph-accent);
    box-shadow: 0 0 0 3px rgba(249,189,43,0.18);
}
.form-control-sm { padding: 4px 8px; font-size: 12.5px; }

textarea.form-control { resize: vertical; line-height: 1.5; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b7a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--ph-border);
}

/* ── Table ───────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table th {
    background: #f5ede0;
    color: var(--ph-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--ph-border);
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { filter: brightness(0.97); }

/* Timeline table – compact rows */
.table-timeline td { padding: 7px 12px; }

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

.monospace { font-family: var(--font-mono); font-size: 12.5px; }
.comment-cell { font-size: 12px; color: var(--ph-muted); max-width: 200px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    background: #ebe3d4;
    border: 1px solid var(--ph-border);
    border-radius: 20px;
    padding: 1px 8px;
    font-size: 11.5px;
    color: var(--ph-muted);
    font-weight: 500;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--ph-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state a { color: var(--ph-text); font-weight: 500; text-decoration: underline; }

/* ── Login ───────────────────────────────────────────────────── */
.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-card {
    background: var(--ph-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 32px;
    width: 100%;
}

.login-header { text-align: center; margin-bottom: 24px; }
.login-logo   { font-size: 3rem; margin-bottom: 8px; }
.login-title  { font-size: 22px; font-weight: 700; color: var(--ph-text); }
.login-subtitle { font-size: 13px; color: var(--ph-muted); margin-top: 2px; }

.login-form .form-group { margin-bottom: 20px; }

.login-footer {
    margin-top: 16px;
    font-size: 12px;
    color: #4a4a58;
}

/* ── Admin grid ──────────────────────────────────────────────── */
.admin-grid {
    display: grid;
    grid-template-columns: minmax(660px, 2fr) minmax(240px, 1fr) minmax(240px, 1fr);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }
    .admin-grid > .card:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 700px) {
    .admin-grid { grid-template-columns: 1fr; }
}

.inline-add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.inline-add-form .form-control { flex: 1; min-width: 0; }

.lookup-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lookup-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.lookup-edit-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.lookup-edit-form .form-control { flex: 1; min-width: 0; }

.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid var(--ph-border);
    flex-shrink: 0;
    display: inline-block;
}
.color-picker {
    width: 36px;
    height: 28px;
    padding: 1px;
    border: 1px solid var(--ph-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    flex-shrink: 0;
}

/* ── Misc helpers ────────────────────────────────────────────── */
.inline-form { display: inline; }

.lock-badge {
    font-size: 14px;
    padding: 3px 6px;
    opacity: 0.5;
    cursor: default;
}

/* ── Event show: two-column layout ──────────────────────────── */
.event-show-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 20px;
    align-items: start;
}

.timeline-col { min-width: 0; }

.timeline-card { min-height: 200px; transition: outline .15s; }
.timeline-card.drag-over { outline: 2px dashed var(--ph-accent); outline-offset: -3px; }

/* Drag handle column */
.col-handle { width: 28px; padding-right: 2px !important; }
.drag-handle {
    cursor: grab;
    color: var(--ph-muted);
    font-size: 16px;
    user-select: none;
    text-align: center;
    padding: 0 4px;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle-locked { cursor: default; opacity: 0.4; }
.tr-ghost { opacity: 0.38; background: #f9e8a0 !important; }

/* Drop-zone strip at bottom of card */
.timeline-drop-zone {
    border-top: 1px dashed var(--ph-border);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--ph-muted);
    text-align: center;
    transition: background .15s, color .15s;
}
.timeline-card.drag-over .timeline-drop-zone {
    background: #fef9e7;
    color: var(--ph-accent);
    font-weight: 600;
}

/* ── Activity palette ────────────────────────────────────────── */
.palette-col { position: sticky; top: 20px; }

.palette-card-wrap {
    padding: 14px 12px;
}

.palette-header {
    margin-bottom: 4px;
}

.palette-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ph-muted);
}

.palette-hint {
    font-size: 11px;
    color: var(--ph-muted);
    margin: 0 0 10px;
}

.palette-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 70vh;
    overflow-y: auto;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--ph-surface);
    border: 1px solid var(--ph-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: grab;
    transition: background .12s, border-color .12s;
    user-select: none;
}
.palette-item:hover { background: #e8dfd0; border-color: #c8bfb0; }
.palette-item:active { cursor: grabbing; }
.palette-item.is-dragging { opacity: 0.45; }

.palette-item-grip { color: var(--ph-muted); font-size: 14px; flex-shrink: 0; }
.palette-item-name { flex: 1; }
.palette-item-dur {
    font-size: 10px;
    color: var(--ph-muted);
    background: rgba(0,0,0,.06);
    border-radius: 3px;
    padding: 1px 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.palette-empty { font-size: 12px; color: var(--ph-muted); }

/* monospace time columns */
.monospace { font-family: monospace; font-size: 13px; }
.timetofaceoff { color: var(--ph-muted); }
.comment-cell { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
    .event-show-layout { grid-template-columns: 1fr; }
    .palette-col { position: static; }
}

/* Palette item dragging over row: insert-before indicator */
tr.insert-before > td {
    border-top: 2px solid var(--ph-accent) !important;
}
tr.insert-before > td:first-child {
    border-top-left-radius: 3px;
}

/* Activity table */
.act-table {
    table-layout: fixed;
    width: 100%;
    min-width: 730px;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
.act-table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ph-muted);
    padding: 4px 8px 8px;
    text-align: left;
    border-bottom: 1px solid var(--ph-border);
    white-space: nowrap;
}
.act-table td {
    padding: 3px 4px;
    vertical-align: middle;
    overflow: hidden;
}
.act-table tbody tr + tr td { border-top: 1px solid var(--ph-border); }
.act-add-row td { padding-top: 2px; padding-bottom: 10px; border-bottom: 2px solid var(--ph-border); }

/* Column widths — fixed layout respects these exactly */
col.act-col-name { width: 200px; }
col.act-col-hh   { width: 60px; }
col.act-col-mm   { width: 60px; }
col.act-col-ss   { width: 60px; }
col.act-col-type { width: 130px; }
col.act-col-resp { width: 145px; }
col.act-col-btn  { width: 55px; }
col.act-col-del  { width: 30px; }

.act-table .form-control { width: 100%; box-sizing: border-box; }
.act-table .inline-form  { margin: 0; }

/* Allow horizontal scroll if card is narrower than table */
#activities { overflow-x: auto; }
