/* Delilah Home — Family-first design */

:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --bg-hover: #475569;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Auth pages ─────────────────────────────────────────────────── */

.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
    text-align: center;
}

.auth-card .subtitle {
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-dim);
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
}

.auth-link a:hover { text-decoration: underline; }

.error-msg {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.success-msg {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

/* ── Main layout ────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 700;
}

.top-bar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-dim);
}

.top-bar .tier-badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 72px;
}

/* ── Tab bar (bottom nav) ───────────────────────────────────────── */

.tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn.active { color: var(--accent); }
.tab-btn:hover { color: var(--text); }

.tab-btn svg {
    width: 24px;
    height: 24px;
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active { display: block; }

/* ── Search ─────────────────────────────────────────────────────── */

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar button {
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
}

.search-bar button:hover { background: var(--accent-hover); }

/* ── Media cards ────────────────────────────────────────────────── */

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.media-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
}

.media-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.media-card .poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: var(--bg-input);
    display: block;
}

.media-card .poster-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 48px;
}

.media-card .card-info {
    padding: 10px 12px;
}

.media-card .card-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-card .card-meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

.media-card .card-status {
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.status-available { background: rgba(34,197,94,0.2); color: var(--success); }
.status-pending { background: rgba(245,158,11,0.2); color: var(--warning); }
.status-requested { background: rgba(59,130,246,0.2); color: var(--accent); }

/* ── Media detail modal ─────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.visible { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    gap: 16px;
    padding: 20px;
}

.modal-poster {
    width: 120px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.modal-info h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.modal-info .meta {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 8px;
}

.modal-info .overview {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ── Season list in modal ──────────────────────────────────────── */

.modal-seasons {
    padding: 0 20px;
}

.seasons-list {
    max-height: 240px;
    overflow-y: auto;
}

.season-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.season-row:last-child { border-bottom: none; }

.season-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.season-name {
    font-size: 14px;
    font-weight: 600;
}

.season-eps {
    font-size: 12px;
    color: var(--text-muted);
}

.modal-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

/* ── Chat ───────────────────────────────────────────────────────── */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-msg .msg-name {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.7;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.chat-input-area input:focus { border-color: var(--accent); }

.chat-input-area button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-input-area button:hover { background: var(--accent-hover); }
.chat-input-area button:disabled { opacity: 0.5; cursor: not-allowed; }

.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    color: var(--text-dim);
    font-size: 14px;
}

.typing-indicator.visible { display: block; }

/* ── Requests list ──────────────────────────────────────────────── */

.request-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.request-item .req-poster {
    width: 48px;
    height: 72px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-input);
    flex-shrink: 0;
}

.request-item .req-info { flex: 1; }
.request-item .req-title { font-weight: 600; font-size: 15px; }

.request-item .req-meta {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 2px;
}

.request-item .req-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
}

/* ── Admin panel ────────────────────────────────────────────────── */

.admin-section {
    margin-top: 24px;
}

.admin-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.user-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.user-row .user-name { flex: 1; font-weight: 500; }

.user-row select {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

/* ── Placeholder cards & components ─────────────────────────────── */

.placeholder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.placeholder-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-dim);
}

.placeholder-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.placeholder-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.placeholder-shimmer {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite ease-in-out;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.placeholder-scroll-row {
    display: flex;
    gap: 12px;
    overflow-x: hidden;
}

.poster-shimmer {
    width: 110px;
    height: 165px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.device-shimmer {
    width: 100px;
    height: 80px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.placeholder-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.placeholder-scene {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.placeholder-room-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.placeholder-room {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.placeholder-room-icon {
    display: block;
    margin-bottom: 4px;
}

.placeholder-room-count {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.6;
}

.placeholder-transport-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
}

.placeholder-transport-play {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    opacity: 0.5;
}

/* ── More links ────────────────────────────────────────────────── */

.more-link {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    font-family: inherit;
    transition: background 0.2s;
}

.more-link:hover { background: var(--bg-hover); }

.more-link svg { flex-shrink: 0; color: var(--accent); }

.more-link-info { flex: 1; }

.more-link-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
}

.more-link-desc {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.placeholder-section {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.placeholder-section svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.placeholder-section h3 {
    font-size: 18px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.placeholder-section p {
    font-size: 14px;
    max-width: 300px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ── Category tabs within media ─────────────────────────────────── */

.category-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

.cat-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 6px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.cat-tab.active {
    background: var(--accent);
    color: white;
}

.cat-tab:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text);
}

/* ── Section header ─────────────────────────────────────────────── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
}

/* ── Loading spinner ────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
    display: flex;
    justify-content: center;
    padding: 40px;
}

/* ── Toast notifications ────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--accent); color: white; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .modal-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .modal-poster { width: 150px; }

    .chat-msg { max-width: 90%; }

    .tab-content { padding: 14px; }

    .auth-card { padding: 24px; }
}

/* ── Empty state ────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 15px;
    line-height: 1.5;
}

/* ── Bug report ────────────────────────────────────────────────── */

.bug-report-form {
    max-width: 500px;
}

.bug-report-desc {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.bug-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    margin-bottom: 16px;
    min-height: 120px;
}

.bug-textarea:focus { border-color: var(--accent); }
.bug-textarea::placeholder { color: var(--text-muted); }
