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

:root {
    --bg: #0f0f0f;
    --surface: #1a1a2e;
    --surface-hover: #222240;
    --primary: #e94560;
    --primary-hover: #d63a54;
    --accent: #533483;
    --text: #eee;
    --text-muted: #999;
    --border: #333;
    --radius: 8px;
    --battle: #e94560;
    --show: #0f3460;
    --freestyle: #533483;
    --cours: #16213e;
}

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

a { color: inherit; text-decoration: none; }

/* Navbar */
.navbar {
    background: var(--surface);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}
.nav-logo { height: 36px; width: auto; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    transition: background 0.2s;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.7rem; }
.btn-icon {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1.1rem; padding: 0 0.3rem;
}
.btn-icon:hover { color: var(--primary); }

/* Feed Header */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.feed-header h1 { font-size: 1.6rem; }

/* Filters */
.filters { margin-bottom: 1.5rem; }
.filter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.filter-form select, .search-input {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}
.search-input { min-width: 180px; }

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
}
.video-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.video-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.15);
}
.video-thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-info { padding: 0.8rem; }
.video-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.3rem;
}
.video-channel { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.video-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.video-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
}
.video-thumb .badge { position: absolute; top: 0.5rem; right: 0.5rem; }
.badge-battle { background: var(--battle); }
.badge-show { background: var(--show); }
.badge-freestyle { background: var(--freestyle); }
.badge-cours { background: var(--cours); }

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.5rem;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    font-size: 0.7rem;
}
.tag-remove {
    background: none; border: none; color: rgba(255,255,255,0.6); cursor: pointer;
    font-size: 0.8rem; line-height: 1; padding: 0;
}
.tag-remove:hover { color: #fff; }
.tag-clickable {
    cursor: pointer; border: none; transition: opacity 0.15s, transform 0.1s;
    opacity: 0.6;
}
.tag-clickable:hover { opacity: 1; transform: scale(1.05); }
.tag-active, .tag-selected { opacity: 1; background: var(--primary); }

/* Tag picker */
.tag-picker { position: relative; }
.tag-picker-selected { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }
.tag-picker-input {
    width: 100%; padding: 0.5rem 0.7rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text); font-size: 0.9rem;
}
.tag-picker-existing {
    display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem;
}
.tag-picker-inline { display: flex; gap: 0.3rem; align-items: center; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Modal */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}
.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 90%; max-width: 500px;
    max-height: 80vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer;
}
.modal-body { padding: 1.2rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
}
.input-full { flex: 1; }
.input-sm {
    padding: 0.35rem 0.6rem; font-size: 0.8rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text); width: 150px;
}
.url-input-row { display: flex; gap: 0.5rem; }

/* Preview card */
.preview-card {
    display: flex; gap: 0.8rem; align-items: center;
    padding: 0.8rem; background: var(--bg); border-radius: var(--radius);
    margin-bottom: 1rem;
}
.preview-card img { width: 120px; border-radius: 4px; }
.preview-card .text-muted { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.error-msg { color: var(--primary); font-size: 0.85rem; margin-top: 0.5rem; }

/* Back link */
.back-link { color: var(--text-muted); font-size: 0.9rem; display: inline-block; margin-bottom: 1rem; }
.back-link:hover { color: var(--text); }

/* Video Detail — Preview Link */
.video-preview-link { display: block; margin-bottom: 1.2rem; }
.video-preview-large {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 16/9;
}
.video-preview-large img {
    width: 100%; height: 100%; object-fit: cover;
    transition: filter 0.2s;
}
.video-preview-link:hover .video-preview-large img { filter: brightness(0.7); }
.play-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.2s;
}
.video-preview-link:hover .play-overlay { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
.watch-label {
    position: absolute;
    bottom: 0.8rem; right: 0.8rem;
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}
.video-detail-header {
    display: flex; align-items: center; gap: 0.8rem;
    margin-bottom: 0.3rem;
}
.video-detail-header h1 { font-size: 1.4rem; }
.video-description { margin: 1rem 0; }
.video-description summary {
    cursor: pointer; color: var(--text-muted); font-size: 0.9rem;
}
.description-text {
    margin-top: 0.5rem; padding: 0.8rem;
    background: var(--bg); border-radius: var(--radius);
    font-family: inherit; font-size: 0.85rem;
    white-space: pre-wrap; word-break: break-word;
    max-height: 300px; overflow-y: auto;
}

/* Tags section */
.tags-section { margin: 1.2rem 0; }
.tags-section h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.tags-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.tag-add-form { display: flex; gap: 0.3rem; align-items: center; }

/* Comments */
.comments-section { margin-top: 2rem; }
.comments-section h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.comment-form { margin-bottom: 1.5rem; }
.comment-form-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.user-select {
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font-size: 0.85rem; min-width: 120px; align-self: flex-start;
}
.comment-form textarea {
    width: 100%; padding: 0.7rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 0.9rem;
    resize: vertical; flex: 1;
}
.comments-list { display: flex; flex-direction: column; gap: 0.8rem; }
.comment {
    padding: 0.8rem;
    background: var(--surface);
    border-radius: var(--radius);
}
.comment-header {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.3rem; font-size: 0.85rem;
}
.comment-date { color: var(--text-muted); font-size: 0.75rem; }
.comment-content { font-size: 0.9rem; line-height: 1.5; }

/* Responsive */
@media (max-width: 600px) {
    .container { padding: 1rem; }
    .video-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; }
    .filter-form select, .search-input { width: 100%; }
}
