/* ==========================================================================
   Lookie UI — shared design tokens & components
   Flat, sharp-cornered, blue. No glass/blur, no glow, no rounded corners.
   Used by: index, watch, channel, settings, login, register, posts,
            search, upload, delete_account, playlists, playlist
   Keep page-specific <style> blocks limited to layout that is unique
   to that page — anything else belongs here so buttons/cards/forms
   stay visually in sync across the site.
   ========================================================================== */

:root {
    --bg: #0d1420;
    --surface: #141e2e;
    --surface-2: #1b273a;
    --border: #2a3a52;

    --accent: #2d7cff;
    --accent-hover: #4a90ff;
    --danger: #e74c3c;
    --danger-hover: #ff4d4d;
    --success: #2ecc71;
    --warning: #f1c40f;

    --text-primary: #ffffff;
    --text-secondary: #a7b2c2;

    /* legacy aliases kept so any page-specific style block that still
       references the old glass tokens degrades to the flat look */
    --glass-bg: var(--surface);
    --glass-border: var(--border);
    --glass-border-light: var(--border);
    --glass-shine: none;
    --glass-shadow: none;
    --glass-inset: none;
    --accent-solid: var(--accent);
}

/* --------------------------------------------------------------------
   Light theme (Features 6 & 7) — dark stays the bare :root default above
   (unchanged, so anything without the theme script/attribute still looks
   exactly like it always has). Explicit choice stamps data-theme on <html>;
   'system' mode leaves data-theme unset and just follows prefers-color-scheme.
   -------------------------------------------------------------------- */
:root[data-theme="light"] {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --border: #d8dee8;

    --text-primary: #10151f;
    --text-secondary: #55627a;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]):not([data-theme="light"]) {
        --bg: #f4f6fa;
        --surface: #ffffff;
        --surface-2: #eef1f6;
        --border: #d8dee8;

        --text-primary: #10151f;
        --text-secondary: #55627a;
    }
}

/* --------------------------------------------------------------------
   Accent color swatches — Feature 6. Applied via data-accent on <html>;
   default (no attribute, or data-accent="blue") keeps today's --accent.
   -------------------------------------------------------------------- */
:root[data-accent="purple"] { --accent: #8b5cf6; --accent-hover: #a78bfa; }
:root[data-accent="red"]    { --accent: #e5484d; --accent-hover: #f16569; }
:root[data-accent="green"]  { --accent: #2ecc71; --accent-hover: #4cd787; }
:root[data-accent="orange"] { --accent: #f0883e; --accent-hover: #f6a05f; }
:root[data-accent="pink"]   { --accent: #ec4899; --accent-hover: #f472b6; }

/* --------------------------------------------------------------------
   Base
   -------------------------------------------------------------------- */
html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
}

a { color: inherit; }

* { box-sizing: border-box; }

/* --------------------------------------------------------------------
   Header / nav
   -------------------------------------------------------------------- */
header {
    background: var(--surface);
    padding: 12px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 { margin: 0; font-size: 24px; }
header h1 a,
header a.logo {
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
}

.beta-tag {
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border: 1px solid var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    margin-left: 12px;
}

header form {
    display: flex;
    flex-grow: 1;
    max-width: 500px;
    margin: 0 20px;
}

header form input {
    flex-grow: 1;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: #fff;
    outline: none;
    transition: border-color 0.15s;
}

header form input:focus {
    border-color: var(--accent);
}

header form button {
    border-left: none;
}

nav {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

nav a:hover { color: var(--accent-hover); }

.back-link {
    display: inline-block;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: color 0.15s;
}

.back-link:hover { color: var(--accent-hover); }

/* --------------------------------------------------------------------
   Headings / section titles
   -------------------------------------------------------------------- */
.section-title {
    font-size: 22px;
    font-weight: 700;
    padding-left: 10px;
    border-left: 4px solid var(--accent);
}

/* --------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------- */
label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    color: #e0e0e0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="file"],
input:not([type]),
textarea,
select,
.report-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: #fff;
    font-size: 15px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

textarea { resize: vertical; min-height: 90px; }

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    outline: none;
}

input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

/* --------------------------------------------------------------------
   Buttons
   A bare <button> defaults to the accent/primary look — that's the
   look every "main action" button (Login, Save, Upload, Search…)
   already used. Anything that needs the neutral look opts in
   via .btn; danger/follow/etc. are modifiers on top of that.
   -------------------------------------------------------------------- */
button,
.btn,
.fmt-btn,
.reaction-btn,
.btn-react,
.btn-dismiss,
.action-btn,
.btn-follow,
.btn-danger,
.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1px solid var(--accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--accent);
    transition: background-color 0.15s, border-color 0.15s;
}

button:hover, .btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

button:disabled, .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Neutral button — the default look for secondary actions
   (Follow, toolbar buttons, reactions, dismiss, etc). */
.btn,
.fmt-btn,
.reaction-btn,
.btn-react,
.btn-dismiss,
.action-btn,
.btn-follow {
    background: var(--surface-2);
    border-color: var(--border);
}

.btn:hover,
.fmt-btn:hover,
.reaction-btn:hover,
.btn-react:hover,
.btn-dismiss:hover,
.action-btn:hover,
.btn-follow:hover {
    background: var(--surface);
    border-color: var(--accent);
}

.fmt-btn { padding: 6px 12px; }

/* Accent-filled variants (the ones that opt back into the primary look) */
.btn-primary,
.fmt-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
}
.btn-primary:hover,
.fmt-btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Danger variant */
.btn-danger,
.danger-btn {
    border-color: var(--danger);
    background: var(--danger);
}
.btn-danger:hover,
.danger-btn:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

/* Following state (channel/watch follow button) */
.btn-follow.following {
    background: var(--surface);
    border-color: var(--border);
}

/* Reaction pill group (like/dislike segmented control) */
.reaction-group {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.btn-react {
    border: none;
    padding: 10px 18px;
    background: transparent;
}
.btn-react:first-child { border-right: 1px solid var(--border); }
.btn-react:hover { background: var(--surface); }
.btn-react.active { background: var(--accent); color: #fff; }

.reaction-box { display: flex; gap: 12px; }
.reaction-btn { padding: 8px 18px; font-size: 13px; }
.reaction-btn.dislike:hover {
    background: var(--danger);
    border-color: var(--danger);
}

/* --------------------------------------------------------------------
   Cards / video grid — simple YouTube-style "islands"
   -------------------------------------------------------------------- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 16px 12px;
}

@media (max-width: 1600px) { .video-grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 1100px) { .video-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .video-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .video-grid { grid-template-columns: 1fr; } }

.card {
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
}

.thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    margin-bottom: 8px;
}

.thumb-wrapper img, .thumb-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card h3 {
    font-size: 15px;
    margin: 0 0 4px 0;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
}

.card a.card-title { text-decoration: none; color: var(--text-primary); }
.card a.card-title:hover { color: var(--accent-hover); }

.card .meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.card .card-channel {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 2px;
}
.card .card-channel:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.card .card-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------
   Panels shared by watch / settings / upload / posts / comments
   -------------------------------------------------------------------- */
.panel, .post-section, .post-item, .comment-box, .auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px;
}

.post-meta {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.post-meta strong { color: var(--text-primary); }

.post-content {
    font-size: 15px;
    margin-bottom: 16px;
    background: var(--surface-2);
    padding: 15px;
    border: 1px solid var(--border);
}

.editor-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }

.editor-box {
    min-height: 80px;
    background: var(--surface-2);
    padding: 16px;
    border: 1px solid var(--border);
    color: #fff;
    outline: none;
    margin-bottom: 12px;
}
.editor-box:focus { border-color: var(--accent); }

.comment-thread { border-bottom: 1px solid var(--border); padding: 15px 0; }
.comment-thread:last-child { border: none; }
.comment { padding: 6px 0; }
.comment-reply { margin-left: 32px; padding-top: 12px; border-top: 1px solid var(--border); }
.comment-user { font-weight: 700; color: var(--accent-hover); font-size: 15px; }
.comment-date { font-size: 12px; color: var(--text-secondary); margin-left: 8px; }

.comment-reply-box { margin-top: 10px; margin-left: 32px; }
.comment-reply-box textarea { min-height: 50px; }

.comment-count {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    padding: 1px 9px;
    margin-left: 8px;
    vertical-align: middle;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
}

.comment-react-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.comment-react-btn:hover { background: var(--surface); }
.comment-react-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.comment-edit-box { margin-top: 8px; }
.comment-edit-box textarea { min-height: 60px; }
.comment-edit-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Plain text action — a <button>/<a> that should look like a link,
   not a pill (e.g. "Delete" under a comment). */
.link-btn {
    display: inline;
    padding: 0;
    border: none;
    background: none;
    color: #ff6666;
    font-size: 12px;
    font-weight: 600;
}
.link-btn:hover {
    background: none;
    text-decoration: underline;
}

/* --------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------- */
.success {
    background: rgba(46, 204, 113, 0.15);
    padding: 12px 15px;
    border: 1px solid var(--success);
    margin-bottom: 20px;
}

.error {
    background: rgba(231, 76, 60, 0.15);
    padding: 12px 15px;
    border: 1px solid var(--danger);
    border-left: 4px solid var(--danger);
    margin-bottom: 20px;
}

/* --------------------------------------------------------------------
   Danger zone (settings / delete account)
   -------------------------------------------------------------------- */
.danger-zone {
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid var(--danger);
}

.danger-text {
    color: #ff6666;
    font-weight: bold;
    border-bottom-color: rgba(231,76,60,0.4);
}

/* --------------------------------------------------------------------
   Profile pictures
   -------------------------------------------------------------------- */
.pfp-preview, .channel-pfp {
    object-fit: cover;
    border: 2px solid var(--border);
    background: var(--surface-2);
    display: block;
}

/* --------------------------------------------------------------------
   Modal (playlist picker, etc.)
   -------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    padding: 0;
    line-height: 1;
}
.modal-close:hover { background: none; color: #fff; }

.modal-body { padding: 12px 20px; overflow-y: auto; }

.playlist-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    cursor: pointer;
}
.playlist-option:last-child { border-bottom: none; }
.playlist-option .pl-count { margin-left: auto; color: var(--text-secondary); font-size: 12px; }

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.modal-footer input { flex: 1; }
