/* ── Timeliner — Custom styles on top of Oat ── */

:root {
    --tl-accent: #7c5bf5;
    --tl-accent-light: #a78bfa;
    --tl-accent-dim: rgba(124, 91, 245, 0.15);
    --tl-line: rgba(124, 91, 245, 0.30);
    --tl-dot: #7c5bf5;
    --tl-dot-glow: rgba(124, 91, 245, 0.45);
    --tl-card-bg: rgba(30, 30, 40, 0.65);
    --tl-card-border: rgba(255, 255, 255, 0.06);
    --tl-input-bar-bg: rgba(18, 18, 26, 0.85);
    --tl-danger: #f87171;
    --tl-badge-host-bg: rgba(56, 189, 248, 0.15);
    --tl-badge-host-fg: #38bdf8;
    --tl-badge-user-bg: rgba(52, 211, 153, 0.15);
    --tl-badge-user-fg: #34d399;
    --tl-radius: 12px;
    --tl-transition: 0.2s ease;
}

/* ── Global ── */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0e0e14;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 91, 245, 0.12), transparent);
    overflow: hidden;
}

/* ── Header ── */
#app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    background: rgba(14, 14, 20, 0.75);
    border-bottom: 1px solid var(--tl-card-border);
    padding: 0.75rem 1.5rem;
}

.header-inner {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #fff 30%, var(--tl-accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-icon {
    width: 22px;
    height: 22px;
    color: var(--tl-accent-light);
    /* override background-clip text for the icon */
    -webkit-text-fill-color: currentColor;
}

#event-count {
    font-size: 0.72rem;
    font-weight: 500;
}

/* ── New Event button (header) ── */
.btn-new-event {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--tl-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--tl-transition), box-shadow var(--tl-transition), transform var(--tl-transition);
    white-space: nowrap;
}

.btn-new-event:hover {
    background: var(--tl-accent-light);
    box-shadow: 0 0 16px var(--tl-dot-glow);
    transform: translateY(-1px);
}

.btn-new-event:active {
    transform: translateY(0);
}

.btn-new-event svg {
    flex-shrink: 0;
}

/* ── Download PDF button (header) ── */
.btn-download-pdf {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--tl-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--tl-transition), box-shadow var(--tl-transition), transform var(--tl-transition);
    white-space: nowrap;
}

.btn-download-pdf:hover {
    background: var(--tl-accent-light);
    box-shadow: 0 0 16px var(--tl-dot-glow);
    transform: translateY(-1px);
}

.btn-download-pdf:active {
    transform: translateY(0);
}

.btn-download-pdf svg {
    flex-shrink: 0;
}

/* ── Main area ── */
#timeline-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 2rem 1.5rem 2rem;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

/* ── Empty state ── */
#empty-state {
    text-align: center;
    padding: 6rem 1rem 2rem;
    color: rgba(255,255,255,0.45);
}

#empty-state .empty-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
    opacity: 0.35;
}

#empty-state h3 {
    margin: 0 0 0.4rem;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
}

#empty-state p {
    margin: 0;
    font-size: 0.88rem;
}

/* ── Timeline ── */
#timeline-container {
    position: relative;
    padding-left: 32px;
}

/* vertical line */
#timeline-container::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--tl-line);
    border-radius: 1px;
}

/* ── Event card ── */
.tl-event {
    position: relative;
    margin-bottom: 1.25rem;
    animation: slideIn 0.35s ease both;
}

.tl-event::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 18px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--tl-dot);
    box-shadow: 0 0 8px var(--tl-dot-glow);
    border: 2px solid #0e0e14;
    z-index: 2;
}

.tl-card {
    background: var(--tl-card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--tl-card-border);
    border-radius: var(--tl-radius);
    padding: 1rem 1.15rem;
    transition: border-color var(--tl-transition), box-shadow var(--tl-transition);
}

.tl-card:hover {
    border-color: rgba(124, 91, 245, 0.25);
    box-shadow: 0 0 20px rgba(124, 91, 245, 0.08);
}

/* card body: flex row with content on left and attachments on right */
.tl-card-body {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.tl-card-content {
    flex: 1;
    min-width: 0;
}

/* card header row */
.tl-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.tl-title {
    font-size: 1rem;
    font-weight: 600;
    color: #f0f0f5;
    margin: 0;
    line-height: 1.35;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background var(--tl-transition);
    min-width: 0;
    word-break: break-word;
}

.tl-title:hover {
    background: rgba(255,255,255,0.06);
}

.tl-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color var(--tl-transition), background var(--tl-transition);
    line-height: 0;
}

.tl-delete:hover {
    color: var(--tl-danger);
    background: rgba(248, 113, 113, 0.12);
}

/* meta row: date / time / host / user */
.tl-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 0.15rem;
}

.tl-meta .tl-badge {
    margin: 0;
}

.tl-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 4px;
    transition: background var(--tl-transition);
}

.tl-meta-item:hover {
    background: rgba(255,255,255,0.06);
}

.tl-meta-item svg {
    width: 13px;
    height: 13px;
    opacity: 0.6;
}

/* badges (inline with meta) */

.tl-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
    transition: filter var(--tl-transition);
}

.tl-badge:hover {
    filter: brightness(1.2);
}

.tl-badge-host {
    background: var(--tl-badge-host-bg);
    color: var(--tl-badge-host-fg);
}

.tl-badge-user {
    background: var(--tl-badge-user-bg);
    color: var(--tl-badge-user-fg);
}

.tl-badge svg {
    width: 12px;
    height: 12px;
}

/* ── Add field buttons (host/user placeholders) ── */
.tl-add-field-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: border-color var(--tl-transition), color var(--tl-transition), background var(--tl-transition);
}

.tl-add-field-btn:hover {
    border-color: var(--tl-accent);
    color: var(--tl-accent-light);
    background: var(--tl-accent-dim);
}

.tl-add-field-btn svg {
    width: 11px;
    height: 11px;
}

/* ── Inline editing ── */
.tl-inline-input {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--tl-accent);
    border-radius: 6px;
    padding: 3px 6px;
    outline: none;
    width: 100%;
    box-shadow: 0 0 0 2px var(--tl-accent-dim);
}

textarea.tl-inline-input {
    resize: vertical;
    min-height: 2rem;
    line-height: 1.35;
}

.tl-inline-input-sm {
    width: auto;
    min-width: 80px;
    max-width: 160px;
    font-size: 0.82rem;
}

/* ── Attachments (thumbnails) — right-aligned ── */
.tl-attachments {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex-shrink: 0;
    justify-content: flex-end;
}

.tl-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--tl-card-border);
    cursor: pointer;
    transition: border-color var(--tl-transition), transform var(--tl-transition);
}

.tl-thumb:hover {
    border-color: var(--tl-accent);
    transform: scale(1.08);
}

/* ── Add attachment "+" button ── */
.tl-add-attachment-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: border-color var(--tl-transition), color var(--tl-transition), background var(--tl-transition);
    padding: 0;
    flex-shrink: 0;
}

.tl-add-attachment-btn:hover {
    border-color: var(--tl-accent);
    color: var(--tl-accent-light);
    background: var(--tl-accent-dim);
}

/* ── Image modal ── */
.tl-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
}

.tl-modal.tl-modal-open {
    display: flex;
}

.tl-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background var(--tl-transition);
    z-index: 1001;
}

.tl-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tl-modal-img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ── New Event Form Modal ── */
.tl-form-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tl-form-modal.tl-form-modal-open {
    display: flex;
}

.tl-form-modal-content {
    background: rgba(22, 22, 32, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--tl-card-border);
    border-radius: var(--tl-radius);
    padding: 1.75rem;
    width: fit-content;
    min-width: min(340px, calc(100vw - 2rem));
    max-width: min(520px, calc(100vw - 2rem));
    margin: 1rem;
    flex-shrink: 0;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.5);
}

.tl-form-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.tl-form-modal-header h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: #f0f0f5;
}

.tl-form-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 6px;
    transition: color var(--tl-transition), background var(--tl-transition);
}

.tl-form-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: clamp(280px, 45vw, 466px);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.form-field span {
    font-size: 0.82rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.45);
}

.form-field span abbr {
    color: var(--tl-accent-light);
    text-decoration: none;
}

.form-field-row {
    display: flex;
    gap: 0.75rem;
}

.form-field input[type="text"],
.form-field textarea {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 400;
    color: #f0f0f5;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--tl-card-border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    outline: none;
    width: 100%;
    transition: border-color var(--tl-transition), box-shadow var(--tl-transition);
}

.form-field input[type="text"]:focus,
.form-field textarea:focus {
    border-color: var(--tl-accent);
    box-shadow: 0 0 0 2px var(--tl-accent-dim);
}

.form-field textarea {
    resize: vertical;
    min-height: 2.5rem;
    line-height: 1.4;
}

.form-field input[type="file"] {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.75);
}

/* ── File preview thumbnails in form ── */
.form-file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.form-file-preview:empty {
    display: none;
}

.form-file-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--tl-card-border);
}

.form-file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.form-file-thumb-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity var(--tl-transition);
}

.form-file-thumb:hover .form-file-thumb-remove {
    opacity: 1;
}

.form-field-action {
    padding-top: 0.35rem;
}

.form-field-action button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--tl-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--tl-transition), box-shadow var(--tl-transition);
}

.form-field-action button:hover {
    background: var(--tl-accent-light);
    box-shadow: 0 0 16px var(--tl-dot-glow);
}

/* ── Animations ── */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive ── */
@media (max-width: 640px) {
    #timeline-area {
        padding: 1.5rem 1rem 2rem;
    }

    .form-field-row {
        flex-direction: column;
        gap: 0.85rem;
    }

    .tl-card-body {
        flex-direction: column;
    }

    .tl-attachments {
        justify-content: flex-start;
    }
}
