/* ==========================================================================
   AI MOVIE — BASE & GLOBAL STYLES (base.css)
   Tokens, Reset, Typography, Navigation, Buttons, Badges, Modals
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-base: #0B0E14;
    --bg-surface: #141A24;
    --bg-card: #1A2230;
    --bg-card-hover: #222C3D;
    --border-subtle: #2A364B;
    --border-highlight: #3B4B68;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    /* Brand & Accent Colors */
    --imdb-gold: #F5C518;
    --rt-tomato: #FA320A;
    --rt-fresh: #00B140;
    --rt-popcorn: #F59E0B;
    --accent-blue: #38BDF8;
    --accent-glow: rgba(56, 189, 248, 0.15);
    --accent-emerald: #20C997;
    --accent-purple: #A855F7;
    --danger: #EF4444;

    /* Border Radii */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.7);

    /* Typography */
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --container-max: 1360px;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    color-scheme: dark;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

input, button, textarea, select {
    font: inherit;
    color: inherit;
}

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

/* --------------------------------------------------------------------------
   Layout Containers
   -------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

main.container {
    padding-top: 1.75rem;
    padding-bottom: 3.5rem;
}

@media (max-width: 640px) {
    .container {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }
    main.container {
        padding-top: 1rem;
        padding-bottom: 2.5rem;
    }
}

/* --------------------------------------------------------------------------
   Global Sticky Header (Index & General)
   -------------------------------------------------------------------------- */
header {
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(11, 14, 20, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
    flex-shrink: 0;
}

.brand-icon {
    font-size: 1.6rem;
    line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(245, 197, 24, 0.3));
}

.brand-text {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #FFFFFF 0%, #CBD5E1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.brand-sub {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(56, 189, 248, 0.2);
    white-space: nowrap;
}

/* Top Nav (Detail, Profile, History, Actor pages) */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 14, 20, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-subtle);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-back,
.btn-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    background: var(--bg-surface);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    cursor: pointer;
}

.btn-back:hover,
.btn-nav:hover {
    background: var(--bg-card);
    border-color: var(--border-highlight);
    color: #FFFFFF;
    transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Button System
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    white-space: nowrap;
    line-height: 1.2;
}

.btn-primary {
    background: linear-gradient(135deg, #38BDF8 0%, #0284C7 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
    color: #FFFFFF;
}

.btn-outline {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-outline:hover {
    background: var(--bg-card);
    border-color: var(--border-highlight);
    color: #FFFFFF;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    border-radius: var(--radius-md);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

.btn-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Badges & Tags
   -------------------------------------------------------------------------- */
.rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.28rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 800;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.badge-imdb {
    background: rgba(18, 18, 18, 0.88);
    color: var(--imdb-gold);
    border: 1px solid rgba(245, 197, 24, 0.35);
}

.badge-rt {
    background: rgba(18, 18, 18, 0.88);
    color: #FFFFFF;
    border: 1px solid rgba(250, 50, 10, 0.35);
}

.badge-rt.fresh {
    border-color: rgba(0, 177, 64, 0.45);
}

.badge-popcorn {
    background: rgba(18, 18, 18, 0.88);
    color: var(--rt-popcorn);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.genre-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.08);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-xs);
    white-space: nowrap;
}

.genre-pill {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(56, 189, 248, 0.25);
    white-space: nowrap;
}

.count-badge {
    background: var(--bg-surface);
    color: var(--accent-blue);
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    font-size: 0.8rem;
}

.tab-count {
    font-size: 0.72rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    font-weight: 800;
}

/* --------------------------------------------------------------------------
   Spinners & Utilities
   -------------------------------------------------------------------------- */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

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

/* Global Native Dialog / Modal Base */
dialog {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 780px;
    width: 90vw;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    margin: auto;
}

dialog::backdrop {
    background: rgba(11, 14, 20, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

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

.modal-body {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
}

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

.modal-close-btn:hover {
    color: #FFFFFF;
}

/* --------------------------------------------------------------------------
   Scroll Fade Masks (Modern Web Guidance)
   Indicates horizontal scrollable content with subtle gradient fades
   -------------------------------------------------------------------------- */
.scroll-fade-mask {
    -webkit-mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
    mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
}

@media (max-width: 640px) {
    .scroll-fade-mask-mobile {
        -webkit-mask-image: linear-gradient(to right, transparent, black 12px, black calc(100% - 12px), transparent);
        mask-image: linear-gradient(to right, transparent, black 12px, black calc(100% - 12px), transparent);
    }
}

/* --------------------------------------------------------------------------
   Mobile Adaptivity for Header & Navigation (Phone <= 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .header-content {
        padding: 0.55rem 0.85rem;
        gap: 0.5rem;
    }

    .brand-icon {
        font-size: 1.35rem;
    }

    .brand-text {
        font-size: 1.15rem;
    }

    .brand-sub {
        display: none; /* Hide subtitle on small phones to save space */
    }

    .nav-btn-text {
        display: none; /* Icon-only compact navigation on mobile */
    }

    .btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.82rem;
        min-height: 38px;
    }

    .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
        min-height: 32px;
    }

    .btn-back,
    .btn-nav {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
        gap: 0.35rem;
        min-height: 36px;
        min-width: 36px;
        justify-content: center;
    }

    .nav-inner {
        gap: 0.4rem;
        flex-wrap: nowrap;
    }

    .modal-body {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }
}

@media (max-width: 420px) {
    .header-content {
        padding: 0.45rem 0.65rem;
    }
    .brand-text {
        font-size: 1.05rem;
    }
}
