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

:root {
    --red: #ff0000;
    --red-hover: #cc0000;
    --bg: #f9f9f9;
    --bg2: #ffffff;
    --bg3: #f1f1f1;
    --border: #e0e0e0;
    --text: #0f0f0f;
    --text2: #606060;
    --text3: #909090;
    --shadow: 0 1px 6px rgba(0,0,0,0.1);
    --radius: 12px;
    --sidebar-w: 240px;
    --header-h: 56px;
}

body.dark {
    --bg: #0f0f0f;
    --bg2: #212121;
    --bg3: #2a2a2a;
    --border: #3a3a3a;
    --text: #f1f1f1;
    --text2: #aaaaaa;
    --text3: #717171;
    --shadow: 0 1px 6px rgba(0,0,0,0.4);
}

body {
    font-family: 'Roboto', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
    gap: 8px;
    transition: background 0.2s;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.menu-btn {
    width: 40px; height: 40px;
    border: none;
    background: none;
    font-size: 20px;
    color: var(--text);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.menu-btn:hover { background: var(--bg3); }

.logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}
.logo-icon {
    background: var(--red);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 14px;
}

.search-bar {
    display: flex;
    flex: 1;
    max-width: 600px;
}
.search-bar input {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 24px 0 0 24px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}
.search-bar input:focus { border-color: #1c62b9; }
.search-bar button {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 0 24px 24px 0;
    background: var(--bg3);
    color: var(--text);
    font-size: 16px;
    transition: background 0.15s;
}
.search-bar button:hover { background: var(--border); }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    width: 40px; height: 40px;
    border: none;
    background: none;
    font-size: 18px;
    color: var(--text);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg3); }

.upload-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg3);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
    white-space: nowrap;
}
.upload-btn:hover { background: var(--border); }
.upload-btn span { font-size: 18px; line-height: 1; }

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--red);
    color: white;
    font-size: 14px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h));
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    background: var(--bg2);
    padding: 12px 0;
    transition: transform 0.2s, background 0.2s;
    z-index: 100;
}

.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    transition: background 0.15s;
    cursor: pointer;
}
.sidebar-item:hover { background: var(--bg3); }
.sidebar-item.active { background: var(--bg3); font-weight: 600; }

.sidebar-icon { font-size: 18px; flex-shrink: 0; }
.sidebar-label { }

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

.sidebar-section-title {
    padding: 8px 12px 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 0 24px 40px;
    transition: margin-left 0.2s;
    min-width: 0;
}

.sidebar.collapsed ~ .main-content,
body.sidebar-hidden .main-content { margin-left: 0; }

/* ===== CHIPS ===== */
.chips-bar {
    display: flex;
    gap: 8px;
    padding: 16px 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: var(--header-h);
    background: var(--bg);
    z-index: 50;
}
.chips-bar::-webkit-scrollbar { display: none; }

.chip {
    padding: 6px 14px;
    border-radius: 8px;
    border: none;
    background: var(--bg3);
    color: var(--text);
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.chip:hover { background: var(--border); }
.chip.active {
    background: var(--text);
    color: var(--bg2);
}

/* ===== VIDEO GRID ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.video-card {
    cursor: pointer;
    border-radius: var(--radius);
    overflow: visible;
    transition: transform 0.15s;
    position: relative;
}
.video-card:hover { transform: translateY(-2px); }
.video-card:hover .card-menu-btn { opacity: 1; }

.card-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    overflow: hidden;
    position: relative;
}

.card-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-duration {
    position: absolute;
    bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.8);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.card-body {
    display: flex;
    gap: 12px;
    padding: 10px 4px 0;
    align-items: flex-start;
}

.card-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
}

.card-info { flex: 1; min-width: 0; }

.card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-channel {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 2px;
}

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

.card-menu-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}
.card-menu-btn:hover { background: rgba(0,0,0,0.9); }

.card-actions-row {
    display: flex;
    gap: 8px;
    padding: 6px 4px 0;
    align-items: center;
}

.card-like-btn, .card-views-btn {
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text2);
    padding: 4px 8px;
    border-radius: 16px;
    transition: background 0.15s;
    display: flex; align-items: center; gap: 4px;
}
.card-like-btn:hover, .card-views-btn:hover { background: var(--bg3); }
.card-like-btn.liked { color: var(--red); }

.card-delete-btn {
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text3);
    padding: 4px 8px;
    border-radius: 16px;
    transition: background 0.15s, color 0.15s;
    margin-left: auto;
}
.card-delete-btn:hover { background: #ff000015; color: var(--red); }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    font-size: 18px;
    color: var(--text3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.empty-state .empty-icon { font-size: 64px; }

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-close {
    position: absolute;
    top: 14px; right: 14px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg3);
    color: var(--text);
    border: none;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
    z-index: 2;
}
.modal-close:hover { background: var(--border); }

/* ===== PLAYER MODAL ===== */
.player-modal {
    background: var(--bg2);
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
}

.player-body { padding: 20px; }

.video-frame {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.video-frame iframe {
    width: 100%; height: 100%;
    border: none;
}
.placeholder-frame {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px;
    color: #ccc;
    width: 100%; height: 100%;
    min-height: 200px;
    text-align: center;
    padding: 20px;
}
.placeholder-frame .ph-emoji { font-size: 72px; }
.placeholder-frame p { font-size: 14px; color: #888; }

.player-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.3;
}

.player-meta-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.player-channel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.channel-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--red);
    color: white;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.channel-name { font-size: 15px; font-weight: 600; }
.channel-subs { font-size: 13px; color: var(--text2); }

.subscribe-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: var(--text);
    color: var(--bg2);
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}
.subscribe-btn.subscribed {
    background: var(--bg3);
    color: var(--text);
}
.subscribe-btn:hover { opacity: 0.85; }

.player-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-pill {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: var(--bg3);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
    display: flex; align-items: center; gap: 6px;
}
.action-pill:hover { background: var(--border); }
.action-pill.liked { background: #ff000020; color: var(--red); }
.action-pill.danger { color: var(--red); }
.action-pill.danger:hover { background: #ff000015; }

.player-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text2);
    white-space: pre-wrap;
    margin-bottom: 8px;
}

.player-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text3);
}

/* ===== UPLOAD MODAL ===== */
.upload-modal {
    background: var(--bg2);
    border-radius: 16px;
    width: 100%;
    max-width: 820px;
    max-height: 92vh;
    overflow-y: auto;
    position: relative;
}

.upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.upload-header h2 { font-size: 20px; }
.upload-header .modal-close { position: static; }

.upload-form { padding: 20px 24px 0; }

.form-row {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.form-left { width: 220px; flex-shrink: 0; }
.form-right { flex: 1; display: flex; flex-direction: column; gap: 14px; }

.thumb-preview {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    margin-bottom: 12px;
    background: #6c5ce7;
    transition: background 0.2s;
}

.thumb-emoji { font-size: 52px; }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin: 6px 0;
}

.emoji-opt {
    font-size: 20px;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    transition: border-color 0.1s, background 0.1s;
}
.emoji-opt:hover { background: var(--bg3); }
.emoji-opt.selected { border-color: var(--red); background: #ff000010; }

.color-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 6px 0;
}

.color-opt {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}
.color-opt:hover { transform: scale(1.15); }
.color-opt.selected { border-color: var(--text); transform: scale(1.2); }

.form-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text2);
    position: relative;
}

.required { color: var(--red); }

.form-label input,
.form-label textarea,
.form-label select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    resize: vertical;
}
.form-label input:focus,
.form-label textarea:focus,
.form-label select:focus { border-color: #1c62b9; }
.form-label input.error { border-color: var(--red); }

.char-count {
    font-size: 12px;
    color: var(--text3);
    text-align: right;
    position: absolute;
    bottom: 8px;
    right: 12px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.upload-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 0 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-bottom: 20px;
}

.btn-primary {
    padding: 10px 24px;
    border-radius: 20px;
    border: none;
    background: var(--red);
    color: white;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--red-hover); }

.btn-secondary {
    padding: 10px 24px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg3); }

/* ===== SHARE MODAL ===== */
.share-modal {
    background: var(--bg2);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 460px;
    position: relative;
}

.share-hint { font-size: 14px; color: var(--text2); margin: 16px 0 8px; }

.share-link-row {
    display: flex;
    gap: 8px;
}
.share-link-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg3);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.share-toast {
    margin-top: 12px;
    font-size: 14px;
    color: #00b894;
    opacity: 0;
    transition: opacity 0.3s;
}
.share-toast.visible { opacity: 1; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    transition: transform 0.3s, opacity 0.3s;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 24px 20px;
    font-size: 13px;
    color: var(--text3);
    border-top: 1px solid var(--border);
    margin-left: var(--sidebar-w);
}
.footer a { color: var(--text3); text-decoration: underline; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-240px); width: 240px; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
    .main-content { margin-left: 0; }
    .footer { margin-left: 0; }
}

@media (max-width: 640px) {
    .header { padding: 0 10px; }
    .logo { font-size: 17px; }
    .search-bar input { font-size: 14px; padding: 7px 12px; }
    .upload-btn span { display: none; }
    .upload-btn { padding: 6px 10px; }
    .main-content { padding: 0 12px 40px; }
    .video-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-left { width: 100%; }
    .form-row-2 { grid-template-columns: 1fr; }
    .player-meta-row { flex-direction: column; }
    .player-actions { justify-content: flex-start; }
}
