/* ================================================================
   Music Session Journal — Global Styles
   Palette: #f5f0e8 cream · #1c1a16 ink · #c8922a amber
   Fonts: Playfair Display (headings) · Lato (body)
================================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font: inherit; }
a { color: inherit; text-decoration: none; }

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    --cream:      #f5f0e8;
    --cream-dark: #ede7d9;
    --ink:        #1c1a16;
    --ink-muted:  #5a5650;
    --amber:      #c8922a;
    --amber-light:#e8b85a;
    --amber-pale: #fdf3e3;
    --white:      #ffffff;
    --danger:     #c0392b;
    --success:    #27ae60;
    --border:     #d4cdc1;
    --shadow:     0 1px 4px rgba(28,26,22,.08);
    --shadow-md:  0 4px 16px rgba(28,26,22,.12);
    --radius:     6px;
    --sidebar-w:  240px;
    --topbar-h:   56px;
}

/* ── Base ───────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    background: var(--cream);
    color: var(--ink);
    font-family: 'Lato', system-ui, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5 {
    font-family: 'Playfair Display', Georgia, serif;
    line-height: 1.25;
    font-weight: 600;
}
h1 { font-size: 2rem;   margin-bottom: .75rem; }
h2 { font-size: 1.5rem; margin-bottom: .6rem;  }
h3 { font-size: 1.2rem; margin-bottom: .5rem;  }

p  { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--ink);
    color: var(--cream);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--amber-light);
}
.brand-icon { font-size: 1.4rem; line-height: 1; }
.brand-text  { line-height: 1.2; }

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--cream);
    font-size: 1.1rem;
    opacity: .6;
    padding: .25rem;
}
.sidebar-close:hover { opacity: 1; }

.nav-list {
    list-style: none;
    padding: .75rem 0;
    flex: 1;
}
.nav-item { margin: .1rem 0; }
.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.25rem;
    color: rgba(245,240,232,.75);
    font-size: .9rem;
    font-weight: 400;
    letter-spacing: .01em;
    transition: background .15s, color .15s;
    border-radius: 0;
}
.nav-link:hover        { background: rgba(255,255,255,.07); color: var(--cream); }
.nav-link--active      { background: var(--amber); color: var(--ink); font-weight: 700; }
.nav-link--active:hover{ background: var(--amber-light); }
.nav-icon              { font-size: 1rem; width: 1.2rem; text-align: center; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: .75rem 0;
}
.nav-link--logout { color: rgba(245,240,232,.5); }
.nav-link--logout:hover { color: var(--cream); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
}

/* Main wrap */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top bar (hidden on desktop) */
.topbar {
    display: none;
    align-items: center;
    gap: 1rem;
    height: var(--topbar-h);
    padding: 0 1.25rem;
    background: var(--ink);
    color: var(--cream);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--amber-light);
}
.hamburger {
    background: none;
    border: none;
    color: var(--cream);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.main-content {
    flex: 1;
    padding: 2.5rem 2rem;
    max-width: 1100px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}
.card-body { padding: 1.25rem; }
.card-footer {
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--cream);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-title { color: var(--ink); }
.page-subtitle { color: var(--ink-muted); font-size: .9rem; margin-top: .2rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .02em;
    border: 2px solid transparent;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn-primary   { background: var(--amber); color: var(--ink); border-color: var(--amber); }
.btn-primary:hover { background: var(--amber-light); border-color: var(--amber-light); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--amber); color: var(--amber); }
.btn-danger    { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-section { margin-bottom: 2rem; }
.form-section-title {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: .85rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group--full { grid-column: 1 / -1; }
.form-group label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.form-group input,
.form-group select,
.form-group textarea {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: .55rem .75rem;
    font: inherit;
    font-size: .9rem;
    color: var(--ink);
    transition: border-color .15s;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(200,146,42,.15);
}
.form-group textarea {
    resize: vertical;
    min-height: 100px;
}
.form-hint { font-size: .78rem; color: var(--ink-muted); }

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .85rem;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .88rem;
    cursor: pointer;
    white-space: nowrap;
}
.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--amber);
    cursor: pointer;
}

/* Star input */
.star-input {
    display: flex;
    gap: .15rem;
}
.star-input input[type="radio"] { display: none; }
.star-input label {
    font-size: 2rem;
    color: var(--border);
    cursor: pointer;
    line-height: 1;
    transition: color .1s;
}
.star-input label:hover,
.star-input label:hover ~ label { color: var(--amber-light); }
.star-input input:checked ~ label { color: var(--border); }

/* JS-powered star: when a radio is checked, highlight it and previous via JS */
.star-input.js-stars label.active { color: var(--amber); }

/* Star display */
.stars .star      { color: var(--border); font-size: 1rem; }
.stars .star--on  { color: var(--amber); }

/* Errors */
.error-list {
    background: #fdf0ef;
    border: 1.5px solid var(--danger);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin-bottom: 1.25rem;
    list-style: disc;
    list-style-position: inside;
    font-size: .88rem;
    color: var(--danger);
}
.field-error { font-size: .78rem; color: var(--danger); margin-top: .2rem; }

/* ── Filters Bar ────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 130px;
}
.filter-group label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-muted);
}
.filter-group input,
.filter-group select {
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: .4rem .6rem;
    font: inherit;
    font-size: .85rem;
    color: var(--ink);
    width: 100%;
}
.filter-group input:focus,
.filter-group select:focus { outline: none; border-color: var(--amber); }
.filter-search { flex: 1; min-width: 200px; }

/* ── Session List ───────────────────────────────────────────── */
.session-list { display: flex; flex-direction: column; gap: .75rem; }
.session-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.session-item:hover { border-color: var(--amber); box-shadow: var(--shadow-md); }

.session-summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .75rem 1.25rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    align-items: start;
}
.session-date-col { min-width: 6rem; }
.session-date {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 600;
}
.session-meta { font-size: .78rem; color: var(--ink-muted); margin-top: .2rem; }
.session-title { font-weight: 700; font-size: 1rem; }
.session-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .35rem;
}
.tag {
    display: inline-block;
    background: var(--cream-dark);
    border-radius: 100px;
    padding: .15rem .6rem;
    font-size: .73rem;
    color: var(--ink-muted);
    font-weight: 700;
    letter-spacing: .02em;
}
.tag--amber { background: var(--amber-pale); color: var(--amber); }
.tag--warning { background: #fff3e0; color: #e65100; }

.session-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }

/* Session detail expand */
.session-detail {
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    background: var(--cream);
    display: none;
}
.session-detail.is-open { display: block; }
.session-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
.detail-field-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-muted);
    margin-bottom: .25rem;
}
.detail-field-value { font-size: .9rem; }

/* ── Session View Page ──────────────────────────────────────── */
.session-view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.session-view-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    font-size: .88rem;
    color: var(--ink-muted);
    margin-top: .4rem;
}
.session-view-meta strong { color: var(--ink); }

.prose { line-height: 1.7; font-size: .95rem; }
.prose h1, .prose h2, .prose h3 { margin: 1.25rem 0 .5rem; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: .75rem; }
.prose code { background: var(--cream-dark); padding: .1rem .35rem; border-radius: 3px; font-size: .85em; }
.prose pre  { background: var(--ink); color: var(--cream); padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: .75rem; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--amber); padding-left: 1rem; color: var(--ink-muted); }

/* ── Photo Gallery ──────────────────────────────────────────── */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-top: .75rem;
}
.photo-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--cream-dark);
    border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb-del {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(0,0,0,.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px; height: 22px;
    font-size: .75rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}
.photo-thumb:hover .photo-thumb-del { opacity: 1; }

.upload-zone {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    font-size: .88rem;
    color: var(--ink-muted);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    margin-top: .75rem;
}
.upload-zone:hover { border-color: var(--amber); background: var(--amber-pale); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 .5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--white);
    font-size: .85rem;
    transition: background .12s, border-color .12s;
}
.page-link:hover        { border-color: var(--amber); background: var(--amber-pale); }
.page-link--active      { background: var(--amber); border-color: var(--amber); color: var(--ink); font-weight: 700; }
.page-link--disabled    { opacity: .4; pointer-events: none; }

/* ── Generator Page ─────────────────────────────────────────── */
.gen-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}
.gen-controls { position: sticky; top: 2rem; }
.gen-output {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 400px;
}
.gen-output-header {
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
}
.gen-output-body {
    padding: 1.5rem;
    font-size: .9rem;
    line-height: 1.7;
    min-height: 300px;
}
.gen-placeholder {
    color: var(--ink-muted);
    font-style: italic;
}
#gen-spinner {
    display: none;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: var(--ink-muted);
}
#gen-spinner.visible { display: flex; }
.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Settings Page ──────────────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
    align-items: start;
}
.info-box {
    background: var(--amber-pale);
    border: 1px solid var(--amber-light);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    font-size: .88rem;
    line-height: 1.6;
}
.info-box strong { color: var(--amber); }
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: .4rem;
    vertical-align: middle;
}
.status-dot--green { background: var(--success); }
.status-dot--red   { background: var(--danger); }

/* ── Login Page ─────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
    padding: 2rem;
}
.login-card {
    background: var(--cream);
    border-radius: 10px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.login-brand-icon { font-size: 2.5rem; }
.login-brand h1 {
    font-size: 1.6rem;
    color: var(--ink);
    margin-top: .5rem;
}
.login-brand p { color: var(--ink-muted); font-size: .88rem; }
.login-error {
    background: #fdf0ef;
    border: 1.5px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius);
    padding: .65rem .9rem;
    font-size: .88rem;
    margin-bottom: 1rem;
}

/* ── Notice / Flash ─────────────────────────────────────────── */
.notice {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .88rem;
    margin-bottom: 1.25rem;
}
.notice--success { background: #eafaf1; border: 1px solid #a9dfbf; color: #1e8449; }
.notice--error   { background: #fdf0ef; border: 1px solid #f5b7b1; color: var(--danger); }

/* ── Utilities ──────────────────────────────────────────────── */
.text-muted   { color: var(--ink-muted); }
.text-amber   { color: var(--amber); }
.text-sm      { font-size: .85rem; }
.text-right   { text-align: right; }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* Loading shimmer */
.skeleton {
    background: linear-gradient(90deg, var(--cream-dark) 25%, var(--border) 50%, var(--cream-dark) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--radius);
    height: 1rem;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar--open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-overlay.overlay--visible { display: block; }

    .main-wrap  { margin-left: 0; }
    .topbar     { display: flex; }
    .main-content { padding: 1.5rem 1rem; }

    .gen-layout { grid-template-columns: 1fr; }
    .gen-controls { position: static; }
    .settings-grid { grid-template-columns: 1fr; }
    .session-summary { grid-template-columns: 1fr auto; }
    .session-date-col { display: none; }
}

@media (max-width: 540px) {
    .form-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* Autocomplete dropdown */
.autocomplete-list {
    position: absolute;
    z-index: 50;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    left: 0;
    top: 100%;
    list-style: none;
}
.autocomplete-list li {
    padding: .45rem .75rem;
    font-size: .88rem;
    cursor: pointer;
}
.autocomplete-list li:hover { background: var(--amber-pale); }
.autocomplete-wrap { position: relative; }
