/* Akoni Books - Web UI Styles */

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-muted: #718096;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --error: #ef4444;
    --error-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header h1 { font-size: 20px; font-weight: 700; color: var(--primary); }
.header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; }
.header nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s;
}
.header nav a:hover, .header nav a.active { color: var(--primary); }

/* Admin nav "More" menu: config and tool pages (2026-11-04). The daily
   queues stay in the bar itself. */
.nav-more { position: relative; }
.nav-more > summary {
    list-style: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after { content: " \25BE"; font-size: 11px; }
.nav-more > summary:hover, .nav-more > summary.active { color: var(--primary); }
.nav-more-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 30;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    padding: 6px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.header nav .nav-more-menu a { padding: 6px 16px; white-space: nowrap; }
@media (max-width: 700px) {
    /* Phone: the logo gets its own line and the admin nav wraps under it, so
       nothing is cut off and the page never scrolls sideways. A header that
       carries the nav stops being sticky here (it is two or three lines
       tall); a header without one (public pages) is unchanged. */
    .header .container { flex-wrap: wrap; row-gap: 4px; }
    .header nav { flex-basis: 100%; gap: 4px 14px; }
    .header:has(nav) { position: static; }
    .nav-more[open] { flex-basis: 100%; }
    .nav-more-menu {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px 14px;
        min-width: 0;
        margin-top: 6px;
        padding: 6px 0 0;
        border: 0;
        border-top: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
    }
    .header nav .nav-more-menu a { padding: 0; }
}

.main { padding: 32px 0; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 18px; margin-bottom: 16px; font-weight: 600; }
.card h3 { font-size: 15px; margin-bottom: 12px; font-weight: 600; color: var(--text-muted); }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
    background: var(--surface);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.form-section h3 {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

/* Book list */
.book-list { display: flex; flex-direction: column; gap: 8px; }
.book-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s;
}
.book-item:hover { border-color: var(--primary); }
.book-item a {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    flex: 1;
}
.book-item a:hover { color: var(--primary); }
.book-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.book-actions { display: flex; gap: 8px; }

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* Image gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.gallery-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.gallery-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.gallery-item .caption {
    padding: 8px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    text-align: center;
}

/* Story pages */
.story-page {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.story-page .page-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.story-page .page-text { font-size: 14px; margin-bottom: 8px; }
.story-page .page-prompt {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    white-space: pre-wrap;
}
.story-page .page-beat {
    font-size: 11px;
    color: var(--warning);
    margin-top: 6px;
    font-style: italic;
}

/* Prompt editor */
.prompt-editor {
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.prompt-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.prompt-editor-header h4 {
    font-size: 14px;
    font-weight: 600;
    font-family: 'SF Mono', Monaco, monospace;
}
.prompt-editor textarea {
    width: 100%;
    border: none;
    padding: 16px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
    min-height: 200px;
    background: var(--surface);
}
.prompt-editor textarea:focus { outline: none; }

/* Status page */
.status-card {
    text-align: center;
    padding: 48px 24px;
}
.status-card .step {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}
.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    margin: 24px 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}
.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state p { font-size: 15px; }

/* Mode selector */
.mode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.mode-option {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.mode-option:hover { border-color: var(--primary); }
.mode-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}
.mode-option input { display: none; }
.mode-option .mode-title { font-weight: 600; font-size: 14px; }
.mode-option .mode-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Page layout with sidebar */
.page-split {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 900px) {
    .page-split { grid-template-columns: 1fr; }
}

/* Name meaning widget (Name Story theme — Phase 1) */
.name-meaning-widget { margin-top: 8px; }
.name-meaning-pill {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
}
.name-meaning-pill-text { flex: 1 1 auto; }
.name-meaning-cta {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.name-meaning-cta:disabled { background: var(--success); cursor: default; }
.name-meaning-pill-active { border-color: var(--success); background: var(--success-light); }
.name-meaning-fill {
    margin-top: 8px;
    padding: 10px 14px;
    background: #fafafa;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.name-meaning-fill-label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 6px; }
.name-meaning-fill-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
