:root {
    --bg-primary: #0d0f14;
    --bg-secondary: #151922;
    --bg-tertiary: #1c2129;
    --accent: #00d9a5;
    --accent-dim: rgba(0, 217, 165, 0.15);
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a8;
    --text-muted: #5f6672;
    --border: #2a3039;
    --danger: #ff6b6b;
    --radius: 8px;
    --radius-lg: 12px;
    --touch-min: 44px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

.header {
    margin-bottom: 1.5rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, #00b894 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

/* Mobile first: colonne unique */
.main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 900px) {
    .app {
        padding: 2rem;
        max-width: 1400px;
    }
    .header { margin-bottom: 2.5rem; }
    .header h1 { font-size: 2rem; }
    .tagline { font-size: 0.95rem; }
    .main {
        display: grid;
        grid-template-columns: 320px 1fr;
        gap: 2rem;
    }
}

.section-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.btn {
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.6rem 1rem;
    min-height: var(--touch-min);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: #00efb8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-small {
    padding: 0.4rem 0.6rem;
    min-height: 36px;
    font-size: 0.75rem;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.15);
}

.series-list {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.series-item {
    flex: 0 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem;
    cursor: pointer;
    transition: all 0.2s;
    max-width: 50vw;
}

.series-item:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.series-item.active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.series-poster {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.series-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.series-poster .poster-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1rem;
    color: var(--text-muted);
}

.series-info {
    padding-top: 0.5rem;
}

.series-item h3 {
    font-size: 0.75rem;
    font-weight: 500;
}

.series-item p {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 900px) {
    .series-list {
        flex-direction: column;
        overflow-x: visible;
    }
    .series-item {
        flex: none;
        min-width: unset;
        padding: 1rem 1.25rem;
        display: flex;
        gap: 1rem;
    }
    .series-poster {
        width: 56px;
        min-width: 56px;
        aspect-ratio: 2/3;
    }
    .series-info { padding-top: 0; }
    .series-item h3 { font-size: 1rem; }
    .series-item p {
        font-size: 0.8rem;
        -webkit-line-clamp: unset;
    }
}

.detail-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-height: 200px;
}

.detail-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-cover {
    position: relative;
    width: 100%;
    max-width: 85px;
    aspect-ratio: 2/3;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-tertiary);
}

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

.detail-cover .poster-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.5rem;
    color: var(--text-muted);
}

.cover-upload {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.7);
    color: var(--accent);
    font-size: 0.75rem;
    text-align: center;
    cursor: pointer;
}

.cover-upload input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.detail-meta h3 {
    font-size: 1.25rem;
}

.detail-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

@media (min-width: 600px) {
    .detail-section { padding: 1.5rem; }
    .detail-header {
        flex-direction: row;
        align-items: flex-start;
    }
    .detail-cover {
        max-width: 140px;
    }
    .detail-cover .poster-placeholder { font-size: 2rem; }
}

@media (min-width: 900px) {
    .detail-section { min-height: 400px; }
    .detail-cover {
        max-width: 200px;
    }
}

.placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 3rem;
}

.seasons-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.season-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.season-header {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.season-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.episodes-list {
    padding: 0.5rem;
}

.episode-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    min-height: var(--touch-min);
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    transition: background 0.2s;
}

.episode-item:hover {
    background: var(--bg-tertiary);
}

.episode-item .ep-order-btns {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.episode-item .btn-order {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    min-width: 28px;
    font-size: 0.6rem;
    line-height: 0.9;
}

.episode-item .btn-order:hover {
    color: var(--accent);
}

.episode-item .ep-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    min-width: 2rem;
}

.episode-item .ep-title {
    flex: 1;
    font-size: 0.9rem;
}

.episode-item .ep-actions {
    display: flex;
    gap: 0.5rem;
}

.episode-item .play-btn {
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.1rem;
    line-height: 1;
}

.episode-item .play-btn:hover {
    color: #00efb8;
}

.episode-item.upload-pending {
    opacity: 0.7;
}

.episode-item.upload-pending .ep-title::after {
    content: " (upload requis)";
    color: var(--text-muted);
    font-size: 0.8rem;
}

.player-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.player-overlay.active {
    display: flex;
}

.player-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.close-player {
    position: absolute;
    top: -2.5rem;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
}

.close-player:hover {
    opacity: 1;
}

.video-wrapper {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.video-wrapper:hover .player-controls,
.player-controls:hover {
    opacity: 1;
}

.player-container video {
    display: block;
    width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
}

.player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 1rem 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-bar {
    position: relative;
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.progress-filled {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s;
}

.progress-hover {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255,255,255,0.5);
    width: 0%;
    pointer-events: none;
    border-radius: 3px;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.controls-left, .controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ctrl-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.9;
}

.ctrl-btn:hover {
    opacity: 1;
}

.volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
}

.time-display {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.9);
    font-family: 'JetBrains Mono', monospace;
}

.speed-select {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.upload-progress-toast {
    min-width: 200px;
}

.upload-progress-toast .toast-progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-bottom: 0.25rem;
    overflow: hidden;
}

.upload-progress-toast .toast-progress {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s;
}

.episode-title {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.9rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-zone input {
    display: none;
}

.upload-progress {
    margin-top: 1rem;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

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

.toast-container {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 600px) {
    .toast-container {
        left: auto;
        right: 2rem;
        bottom: 2rem;
    }
}

.toast {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.toast.success {
    border-color: var(--accent);
}

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