/* ============================================================
   NUÔI NICK · Giao diện đơn giản
   Xanh dương + trắng · scroll feed
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Tokens ---------- */
:root {
    --blue: #1e6fff;
    --blue-dark: #1455cc;
    --blue-soft: #e8f1ff;
    --ink: #0b2545;
    --paper: #ffffff;
    --rule: #e3edf8;
    --muted: #6b7d99;
    --danger: #d33c3c;
    --maxw: 1280px;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--blue-soft);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--blue);
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

img, video {
    display: block;
    max-width: 100%;
}

/* ---------- Container ---------- */
.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 1rem 5rem;
}

/* ---------- Top bar (đơn giản) ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    min-height: 56px;
}

.site-name {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--blue);
    letter-spacing: -0.02em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-tag {
    background: var(--blue);
    color: var(--paper);
    padding: 0.2rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.topbar-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    transition: background 0.15s, color 0.15s;
}

.topbar-link:hover {
    background: var(--blue);
    color: var(--paper);
    border-color: var(--blue);
}

/* ---------- Layout ---------- */
.layout {
    margin-top: 1.5rem;
}

aside#upload-panel {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.panel-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font: inherit;
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    border-radius: 8px;
    transition: border-color 0.15s, background 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--blue-soft);
}

.form-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2rem;
}

.dropzone {
    border: 1.5px dashed var(--rule);
    background: var(--paper);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
    background: var(--blue-soft);
    border-color: var(--blue);
}

.dropzone-prompt {
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.dropzone-hint {
    font-size: 0.78rem;
    color: var(--muted);
}

.file-info {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px;
    background: var(--blue);
    color: var(--paper);
    border: 0;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
}

.btn:hover {
    background: var(--blue-dark);
}

/* ---------- Section head ---------- */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink);
}

.section-meta {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}

/* ---------- Category filter ---------- */
.category-sticky {
    /* desktop: không sticky, để trong flow */
    position: relative;
    z-index: 5;
    margin: 0 -1rem 1.5rem;          /* tràn mép container để scroll sát mép */
    padding: 0.25rem 1rem;
    background: var(--blue-soft);    /* che nội dung phía sau khi lướt ngang */
}

.category-scroller {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.25rem 0;
}

.category-tab {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 999px;
    white-space: nowrap;            /* pill không bị gãy */
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.category-tab:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.category-tab.active {
    background: var(--blue);
    color: var(--paper);
    border-color: var(--blue);
}

/* ---------- Video feed (lưới responsive) ---------- */
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Pad / tablet: 2 cột */
@media (max-width: 900px) {
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 cột */
@media (max-width: 600px) {
    .video-grid {
        grid-template-columns: 1fr;
    }
}

.entry {
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 14px;
    overflow: hidden;
}

.entry-figure {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
    cursor: pointer;
}

.entry-figure video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.entry-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: var(--paper);
    opacity: 1;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.entry-figure.playing .entry-overlay {
    opacity: 0;
}

.entry-overlay .entry-play {
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.55);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

/* Body */
.entry-body {
    padding: 0.85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.entry-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 500;
}

.entry-index {
    color: var(--blue);
    font-weight: 600;
}

.entry-cat {
    color: var(--blue);
    font-weight: 600;
    background: var(--blue-soft);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.entry-time {
    color: var(--muted);
}

.entry-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--ink);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.entry-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.entry-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    cursor: pointer;
    flex: 0 1 auto;
}

.entry-btn-primary {
    background: var(--blue);
    color: var(--paper);
    border-color: var(--blue);
}

.entry-btn-primary:hover {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
}

.entry-btn-ghost:hover {
    background: var(--blue-soft);
    color: var(--blue);
    border-color: var(--blue);
}

.entry-btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.entry-btn-danger:hover {
    background: var(--danger);
    color: var(--paper);
}

/* ---------- Empty state ---------- */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 14px;
}

.empty-state-kicker {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.empty-state h3 {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.3rem;
}

.empty-state-hint {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---------- Progress ---------- */
.progress-container {
    margin-top: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--rule);
    background: var(--blue-soft);
    border-radius: 8px;
}

.progress-bar-wrapper {
    height: 5px;
    background: var(--paper);
    border-radius: 999px;
    margin-bottom: 0.4rem;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--blue);
    width: 0%;
    transition: width 0.2s ease;
}

.progress-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    max-width: 320px;
}

.toast {
    background: var(--ink);
    color: var(--paper);
    padding: 0.7rem 0.9rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    border-radius: 8px;
    border-left: 4px solid var(--blue);
    animation: slideUp 0.2s ease;
}

.toast.toast-error {
    border-left-color: var(--danger);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ---------- Touch device overlay ---------- */
@media (hover: none) {
    .entry-overlay {
        background: rgba(0, 0, 0, 0.25);
    }
}

/* ---------- Mobile: mục lục sticky + scroll ngang ---------- */
@media (max-width: 700px) {
    .category-sticky {
        position: sticky;
        top: 0;                   /* dính sát mép trên vì header không còn sticky */
        margin: 0 -1rem;          /* tràn full-width */
        padding: 0.5rem 0.75rem;
        background: var(--paper);
        border-top: 1px solid var(--rule);
        border-bottom: 1px solid var(--rule);
    }

    .category-scroller {
        flex-wrap: nowrap;         /* KHÔNG xuống dòng, cuộn ngang */
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        scrollbar-width: none;        /* Firefox */
        -ms-overflow-style: none;     /* IE/Edge cũ */
        padding: 0.25rem 0.25rem 0.5rem;
        gap: 0.4rem;
    }

    .category-scroller::-webkit-scrollbar {
        display: none;              /* Chrome/Safari */
    }

    /* Viền fade 2 mép để gợi ý có thể trượt thêm */
    .category-sticky::before,
    .category-sticky::after {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        width: 24px;
        pointer-events: none;
        z-index: 1;
    }
    .category-sticky::before {
        left: 0;
        background: linear-gradient(to right, var(--paper), transparent);
    }
    .category-sticky::after {
        right: 0;
        background: linear-gradient(to left, var(--paper), transparent);
    }
}
