/* ========================================
   TinyTV - Cinémathèque Noire Theme
   ======================================== */

:root {
    --noir: #0a0a0c;
    --charcoal: #151518;
    --slate: #1e1e24;
    --gold: #d4a853;
    --gold-dim: #b8944a;
    --gold-glow: rgba(212, 168, 83, 0.15);
    --ivory: #f5f2eb;
    --silver: #9a9a9e;
    --crimson: #8b2635;
    --success: #50c878;
    --danger: #e53935;
    --warning: #ffb000;
}

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

html, body {
    font-family: 'Outfit', sans-serif;
    background: var(--noir);
    color: var(--ivory);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1, h2, h3, .title {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    letter-spacing: -0.02em;
}

a {
    color: var(--gold);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

a:hover {
    opacity: 0.8;
}

/* ========================================
   LAYOUT
   ======================================== */

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 80px;
    height: 100vh;
    background: linear-gradient(180deg, var(--charcoal) 0%, var(--noir) 100%);
    border-right: 1px solid rgba(212, 168, 83, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    z-index: 100;
}

main {
    margin-left: 80px;
    flex: 1;
    min-height: 100vh;
}

.content {
    padding: 0;
}

/* ========================================
   HERO SECTION
   ======================================== */

.hero {
    padding: 4rem 4rem 3rem;
    background: linear-gradient(135deg, var(--charcoal) 0%, var(--noir) 50%, var(--slate) 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(ellipse, var(--gold-glow) 0%, transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.hero-title span {
    color: var(--gold);
    font-style: italic;
}

.hero-subtitle {
    color: var(--silver);
    font-weight: 300;
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

/* ========================================
   SEARCH
   ======================================== */

.search-container {
    position: relative;
    max-width: 600px;
}

.search-box {
    width: 100%;
    padding: 1.25rem 1.5rem;
    padding-right: 140px;
    background: var(--slate);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 16px;
    color: var(--ivory);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-box::placeholder {
    color: var(--silver);
}

.search-box:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 30px var(--gold-glow);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
    border: none;
    border-radius: 10px;
    color: var(--noir);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-btn:hover {
    transform: translateY(-50%) scale(1.02);
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.4);
}

.search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.search-hint {
    color: var(--silver);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

/* ========================================
   SECTIONS
   ======================================== */

.section {
    padding: 3rem 4rem;
}

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

.section-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 28px;
    background: var(--gold);
    border-radius: 2px;
}

.see-all {
    color: var(--gold);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: gap 0.3s ease;
}

.see-all:hover {
    gap: 0.75rem;
    opacity: 1;
}

.deco-line {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--gold) 20%, var(--gold) 80%, transparent 100%);
    margin: 3rem 4rem;
    opacity: 0.3;
}

/* ========================================
   MEDIA GRID
   ======================================== */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.media-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--charcoal);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    animation: fadeInUp 0.6s ease forwards;
}

.media-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 60px var(--gold-glow);
}

.media-poster {
    aspect-ratio: 2/3;
    width: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.media-card:hover .media-poster {
    transform: scale(1.08);
}

.media-placeholder {
    aspect-ratio: 2/3;
    width: 100%;
    background: var(--slate);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--silver);
    font-size: 0.85rem;
}

.media-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--noir) 0%, transparent 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.25rem;
}

.media-card:hover .media-overlay {
    opacity: 1;
}

.media-title {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.media-meta {
    color: var(--silver);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
    color: var(--noir);
}

.btn-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.4);
}

.btn-secondary {
    background: var(--slate);
    color: var(--ivory);
    border: 1px solid rgba(212, 168, 83, 0.2);
}

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

.btn-success {
    background: var(--success);
    color: var(--noir);
}

.btn-success:hover {
    box-shadow: 0 4px 15px rgba(80, 200, 120, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   DOWNLOADS
   ======================================== */

.downloads-section {
    background: var(--charcoal);
    border-radius: 20px;
    padding: 2rem;
    margin-top: 1rem;
}

.download-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.download-item:last-child {
    border-bottom: none;
}

.download-thumb {
    width: 50px;
    height: 70px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--slate);
}

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

.download-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.download-progress {
    height: 4px;
    background: var(--slate);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.download-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dim) 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.download-status {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-downloading {
    background: rgba(212, 168, 83, 0.15);
    color: var(--gold);
}

.status-completed {
    background: rgba(80, 200, 120, 0.15);
    color: var(--success);
}

.status-pending {
    background: rgba(154, 154, 158, 0.15);
    color: var(--silver);
}

.status-failed {
    background: rgba(229, 57, 53, 0.15);
    color: var(--danger);
}

.status-cancelled {
    background: rgba(255, 176, 0, 0.15);
    color: var(--warning);
}

/* ========================================
   FORMS
   ======================================== */

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

.form-label {
    display: block;
    color: var(--silver);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--slate);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 10px;
    color: var(--ivory);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-control::placeholder {
    color: var(--silver);
}

.form-control:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 20px var(--gold-glow);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239a9a9e'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--charcoal);
    border: 1px solid rgba(212, 168, 83, 0.1);
    border-radius: 16px;
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* ========================================
   ALERTS
   ======================================== */

.alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.alert-info {
    background: rgba(212, 168, 83, 0.1);
    border: 1px solid rgba(212, 168, 83, 0.2);
    color: var(--gold);
}

.alert-warning {
    background: rgba(255, 176, 0, 0.1);
    border: 1px solid rgba(255, 176, 0, 0.2);
    color: var(--warning);
}

.alert-danger {
    background: rgba(229, 57, 53, 0.1);
    border: 1px solid rgba(229, 57, 53, 0.2);
    color: var(--danger);
}

.alert-success {
    background: rgba(80, 200, 120, 0.1);
    border: 1px solid rgba(80, 200, 120, 0.2);
    color: var(--success);
}

/* ========================================
   TOAST
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1100;
}

.toast {
    background: var(--charcoal);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

.toast-body {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--silver);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.2rem;
    line-height: 1;
}

.btn-close:hover {
    color: var(--ivory);
}

/* ========================================
   SPINNER
   ======================================== */

.spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--slate);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-border-sm {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 2px;
}

/* ========================================
   TABLES
   ======================================== */

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 1rem;
    color: var(--silver);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.table tr:hover {
    background: rgba(212, 168, 83, 0.03);
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background: var(--gold-glow);
    color: var(--gold);
}

.badge-success {
    background: rgba(80, 200, 120, 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(229, 57, 53, 0.15);
    color: var(--danger);
}

.badge-secondary {
    background: rgba(154, 154, 158, 0.15);
    color: var(--silver);
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

/* Staggered animation delays */
.media-card:nth-child(1) { animation-delay: 0.05s; }
.media-card:nth-child(2) { animation-delay: 0.1s; }
.media-card:nth-child(3) { animation-delay: 0.15s; }
.media-card:nth-child(4) { animation-delay: 0.2s; }
.media-card:nth-child(5) { animation-delay: 0.25s; }
.media-card:nth-child(6) { animation-delay: 0.3s; }
.media-card:nth-child(7) { animation-delay: 0.35s; }
.media-card:nth-child(8) { animation-delay: 0.4s; }

/* ========================================
   UTILITIES
   ======================================== */

.text-center { text-align: center; }
.text-muted { color: var(--silver); }
.text-gold { color: var(--gold); }
.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ========================================
   BLAZOR SPECIFICS
   ======================================== */

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem 1.5rem;
    color: white;
    border-radius: 10px;
}

.blazor-error-boundary::after {
    content: "Une erreur s'est produite.";
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--charcoal);
    border: 1px solid var(--danger);
    padding: 1rem 2rem;
    border-radius: 10px;
    z-index: 1100;
}

#blazor-error-ui .reload, #blazor-error-ui .dismiss {
    color: var(--gold);
    margin-left: 1rem;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
    }

    main {
        margin-left: 70px;
    }

    .hero {
        padding: 3rem 2.5rem 2rem;
    }

    .hero-title {
        font-size: 2.8rem;
    }

    .section {
        padding: 2rem 2.5rem;
    }

    .deco-line {
        margin: 2rem 2.5rem;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .downloads-section {
        padding: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 70px;
        flex-direction: row;
        justify-content: space-around;
        padding: 0 1rem;
        border-right: none;
        border-top: 1px solid rgba(212, 168, 83, 0.15);
        background: var(--charcoal);
        backdrop-filter: blur(10px);
    }

    main {
        margin-left: 0;
        margin-bottom: 70px;
    }

    .hero {
        padding: 2rem 1.5rem;
    }

    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .search-container {
        max-width: 100%;
    }

    .search-box {
        padding: 1rem 1.25rem;
        padding-right: 1.25rem;
        font-size: 0.95rem;
        border-radius: 12px;
    }

    .search-btn {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        width: 100%;
        margin-top: 0.75rem;
        padding: 1rem;
        border-radius: 12px;
    }

    .section {
        padding: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1.25rem;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .deco-line {
        margin: 1.5rem;
    }

    .media-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .media-card {
        border-radius: 10px;
    }

    .media-overlay {
        opacity: 1;
        background: linear-gradient(0deg, var(--noir) 0%, rgba(0,0,0,0.4) 40%, transparent 100%);
        padding: 1rem;
    }

    .media-title {
        font-size: 0.85rem;
    }

    .media-meta {
        font-size: 0.7rem;
        margin-bottom: 0.75rem;
    }

    .downloads-section {
        padding: 1rem;
        border-radius: 14px;
    }

    .download-item {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.75rem 0;
    }

    .download-thumb {
        width: 40px;
        height: 55px;
    }

    .download-name {
        font-size: 0.9rem;
    }

    .toast-container {
        bottom: 90px;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        width: 100%;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .hero-title {
        font-size: 1.65rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .media-grid {
        gap: 0.6rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

/* Touch devices */
@media (hover: none) {
    .media-card:hover {
        transform: none;
        box-shadow: none;
    }

    .media-card:hover .media-poster {
        transform: none;
    }

    .media-card:active {
        transform: scale(0.98);
    }

    .btn:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.95);
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .sidebar {
            padding-bottom: env(safe-area-inset-bottom);
            height: calc(70px + env(safe-area-inset-bottom));
        }

        main {
            margin-bottom: calc(70px + env(safe-area-inset-bottom));
        }

        .toast-container {
            bottom: calc(90px + env(safe-area-inset-bottom));
        }
    }
}
