/* ============================================
   MOVIE TRACKER - DESIGN SYSTEM
   Enhanced 2026 Redesign
   ============================================ */

/* --- 1. COLOR PALETTE --- */

:root {
    /* Primary - Chelsea Blue with variations */
    --chelsea-blue: #034694;
    --chelsea-blue-light: #0457b8;
    --chelsea-blue-dark: #02357a;
    --chelsea-blue-glow: rgba(3, 70, 148, 0.3);

    /* Backgrounds - Deeper blacks for better contrast */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-elevated: #222222;

    /* Text - Better hierarchy */
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #6b7280;

    /* Accents */
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.18);

    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
}

/* --- 2. BASE OVERRIDES --- */

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- 3. CUSTOM SCROLLBAR --- */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--chelsea-blue);
}

/* --- 4. GLASSMORPHISM VARIANTS --- */

/* Elevated glass effect */
.glass-elevated {
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-medium);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.4),
        0 2px 4px -1px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Subtle glass effect */
.glass-subtle {
    background: rgba(17, 17, 17, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
}

/* Original glass class (kept for compatibility) */
.glass {
    background: rgba(22, 22, 22, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
}

/* --- 5. TYPOGRAPHY UTILITIES --- */

.text-display-xl {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.text-display-lg {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.text-h1 {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.3;
}

.text-h2 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
}

.text-h3 {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.4;
}

.text-body-lg {
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.6;
}

.text-body {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
}

.text-body-sm {
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
}

.text-label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --- 6. ANIMATIONS --- */

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

/* Staggered delays */
.animate-delay-100 {
    animation-delay: 100ms;
}

.animate-delay-200 {
    animation-delay: 200ms;
}

.animate-delay-300 {
    animation-delay: 300ms;
}

.animate-delay-400 {
    animation-delay: 400ms;
}

/* --- 7. TRANSITIONS --- */

.transition-all-200 {
    transition: all 0.2s ease;
}

.transition-all-300 {
    transition: all 0.3s ease;
}

.transition-colors-200 {
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.transition-transform-200 {
    transition: transform 0.2s ease;
}

.transition-opacity-200 {
    transition: opacity 0.2s ease;
}

/* --- 8. TABLE STYLES (Desktop) --- */

.modern-table-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-card);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.movie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    table-layout: fixed;
}

.movie-table th {
    background: linear-gradient(180deg, var(--chelsea-blue) 0%, var(--chelsea-blue-dark) 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-secondary);
    text-overflow: ellipsis;
}

.movie-table td.has-tooltip {
    overflow: visible;
}

.movie-table tbody tr {
    transition: all 0.2s ease;
}

.movie-table tbody tr:hover {
    background: linear-gradient(90deg,
            rgba(3, 70, 148, 0.08) 0%,
            rgba(3, 70, 148, 0.03) 50%,
            rgba(3, 70, 148, 0.08) 100%);
}

/* --- 9. ALIGNMENT HELPERS --- */

.text-center-header {
    text-align: center !important;
}

.text-right-header {
    text-align: right !important;
}

/* --- 10. TOOLTIP LOGIC --- */

.has-tooltip {
    position: relative;
}

.tooltip-content {
    position: absolute;
    z-index: 9999;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 320px;
    background: rgba(15, 15, 15, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 16px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.9),
        0 8px 20px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.has-tooltip:hover .tooltip-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%);
}

/* --- 11. BUTTON STYLES --- */

.btn-primary {
    background: linear-gradient(135deg, var(--chelsea-blue) 0%, var(--chelsea-blue-dark) 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px var(--chelsea-blue-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px -1px var(--chelsea-blue-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid var(--border-medium);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* --- 12. MOBILE FLIP CARD LOGIC --- */

/* Mobile flip card container */
.mobile-flip-card {
    position: relative;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    transition: all 0.3s ease;
    cursor: pointer;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

.mobile-flip-card:hover {
    border-color: var(--border-medium);
}

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

/* Make flipper preserve 3D */
.mobile-list-flip-container {
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

.mobile-list-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-transition: -webkit-transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

.mobile-list-front,
.mobile-list-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.mobile-list-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.mobile-list-back {
    z-index: 1;
    transform: rotateY(180deg);
}

.mobile-list-flipper.is-flipped {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

/* --- 13. FOCUS STATES (Accessibility) --- */

*:focus-visible {
    outline: 2px solid var(--chelsea-blue);
    outline-offset: 2px;
}

/* --- 14. CARD ENHANCEMENTS --- */

.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.4);
}

/* --- 15. INPUT STYLES --- */

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: var(--chelsea-blue);
    box-shadow: 0 0 0 3px var(--chelsea-blue-glow);
}

input::placeholder {
    color: var(--text-muted);
}

/* --- 16. BADGE STYLES --- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--chelsea-blue);
    color: white;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-warning);
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

/* --- 17. DIVIDER --- */

.divider {
    height: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            var(--border-medium) 50%,
            transparent 100%);
    margin: 1.5rem 0;
}

/* --- 18. LOADING STATES --- */

.skeleton {
    background: linear-gradient(90deg,
            var(--bg-card) 0%,
            var(--bg-elevated) 50%,
            var(--bg-card) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- 19. MOBILE OPTIMIZATIONS --- */

@media (hover: none) {
    .btn-primary:active {
        transform: scale(0.95);
        opacity: 0.8;
    }

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

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

/* --- 20. RESPONSIVE UTILITIES --- */

@media (max-width: 640px) {
    .text-display-xl {
        font-size: 2.5rem;
    }

    .text-display-lg {
        font-size: 1.75rem;
    }

    .text-h1 {
        font-size: 1.5rem;
    }

    .text-h2 {
        font-size: 1.25rem;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .text-display-xl {
        font-size: 3rem;
    }
}

@media (min-width: 1025px) {
    .text-display-xl {
        font-size: 3.5rem;
    }
}

/* --- 21. WATCHLIST FLIP GRID --- */

/* Grid container */
.wl-flip-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}
@media (max-width: 1280px) { .wl-flip-grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 1024px) { .wl-flip-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px)  { .wl-flip-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

/* Card shell — holds perspective */
.wl-card {
    aspect-ratio: 2/3;
    perspective: 1000px;
    cursor: pointer;
    -webkit-perspective: 1000px;
}

/* The flipping inner */
.wl-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-transition: -webkit-transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
}

/* Desktop: CSS hover flips the card */
@media (hover: hover) {
    .wl-card:hover .wl-card-inner {
        transform: rotateY(180deg);
        -webkit-transform: rotateY(180deg);
    }
}

/* Touch/JS: toggled class flips the card */
.wl-card.is-flipped .wl-card-inner {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

/* Shared face rules */
.wl-card-front,
.wl-card-back {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* FRONT — poster */
.wl-card-front {
    background: var(--bg-card);
}
.wl-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wl-card-front-grad {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, transparent 100%);
    pointer-events: none;
}
.wl-card-front-title {
    position: absolute;
    bottom: 9px;
    left: 9px;
    right: 30px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.wl-card-front-tmdb {
    position: absolute;
    top: 7px;
    right: 7px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--accent-warning);
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
}
.wl-card-front-hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    color: rgba(255, 255, 255, 0.28);
    font-size: 10px;
}

/* Rating pill on the back face — mirrors the front badge */
.wl-back-tmdb {
    position: absolute;
    top: 9px;
    right: 9px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--accent-warning);
    font-size: 10px;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 4px;
    z-index: 2;
}

/* BACK — info + actions */
.wl-card-back {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    display: flex;
    flex-direction: column;
    padding: 13px;
}
.wl-back-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 5px;
    padding-right: 52px;
}
.wl-back-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.wl-back-year {
    font-size: 10px;
    font-weight: 700;
    color: var(--chelsea-blue);
    flex-shrink: 0;
}
.wl-back-director {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: right;
    min-width: 0;
    line-height: 1.3;
}
.wl-back-submeta {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: baseline;
}
.wl-back-submeta-sep { opacity: 0.55; }
.wl-back-divider {
    height: 1px;
    background: var(--border-subtle);
    margin-bottom: 8px;
    flex-shrink: 0;
}
.wl-back-overview {
    font-size: 9px;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    margin-bottom: 10px;
}
.wl-back-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.wl-btn-watched {
    flex: 1;
    background: var(--chelsea-blue);
    color: #fff;
    border: none;
    padding: 8px 0;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Geist', sans-serif;
    cursor: pointer;
    transition: background 0.2s;
}
.wl-btn-watched:hover { background: var(--chelsea-blue-light); }
.wl-btn-remove {
    width: 32px;
    flex-shrink: 0;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.wl-btn-remove:hover { background: rgba(239, 68, 68, 0.25); }

/* Mobile (≤768px) — cards are now 2-col, ~170px wide × ~255px tall.
   Comfortable room for full back-face content including runtime + overview. */
@media (max-width: 768px) {
    .wl-card-front-title { font-size: 11px; bottom: 8px; left: 8px; right: 28px; }
    .wl-card-front-tmdb  { font-size: 9px;  padding: 2px 6px; top: 7px; right: 7px; }
    .wl-card-front-hint  { display: none; }
    .wl-card-back        { padding: 11px; }
    .wl-back-tmdb        { top: 8px; right: 8px; font-size: 9px; padding: 2px 6px; }
    .wl-back-title       { font-size: 12px; margin-bottom: 4px; padding-right: 44px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .wl-back-row         { margin-bottom: 4px; gap: 6px; }
    .wl-back-year        { font-size: 10px; }
    .wl-back-director    { font-size: 10px; }
    .wl-back-submeta     { font-size: 9px; margin-bottom: 7px; }
    .wl-back-divider     { margin-bottom: 6px; }
    .wl-back-overview    { font-size: 10px; line-height: 1.4; -webkit-line-clamp: 6; margin-bottom: 8px; }
    .wl-back-actions     { gap: 5px; margin-top: auto; }
    .wl-btn-watched      { padding: 7px 0; font-size: 10px; }
    .wl-btn-remove       { width: 28px; font-size: 11px; }
}

/* Mobile sort pills */
.wl-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 16px 12px;
    margin: 0 -16px 0;
}
@media (min-width: 768px) {
    .wl-pills { padding: 0 0 12px; margin: 0; flex-wrap: wrap; overflow-x: visible; }
}
.wl-pills::-webkit-scrollbar { display: none; }
.wl-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 13px;
    border-radius: 999px;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: 'Geist', sans-serif;
}
.wl-pill:hover { color: var(--text-primary); border-color: var(--border-medium); }
.wl-pill.is-active {
    background: var(--chelsea-blue);
    color: #fff;
    border-color: var(--chelsea-blue);
}
.wl-pill .wl-pill-arrow { font-size: 9px; opacity: 0.85; }