/* 
    Futuristic Antigravity Glassmorphism Design System
    Created for: Watch Later Web App
*/

:root {
    --bg: #050508;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-heavy: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.12);
    --text: #f0f0f5;
    --text-dim: #9ca3af;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --neon-purple: #8b5cf6;
    --neon-blue: #06b6d4;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    --radius: 16px;
    --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    box-sizing: border-box;
}

html {
    background-color: #050508; /* Ultra fallback */
}

body {
    background-color: #050508; /* Solid fallback */
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    overflow-x: hidden;
    min-height: 100vh;
    background-image: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #050508 100%);
    background-attachment: fixed;
}

/* --- Background Orbs --- */
.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: drift 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--neon-purple);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent);
    bottom: -150px;
    right: -150px;
    animation-duration: 25s;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--neon-blue);
    top: 40%;
    left: 60%;
    animation-duration: 30s;
    animation-delay: -10s;
}

@keyframes drift {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(100px, 50px) scale(1.2); }
}

/* --- Layout --- */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 40px;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-name {
    font-weight: 600;
    margin-right: 10px;
    font-size: 14px;
    opacity: 0.8;
}

h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Glassmorphism Cards --- */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    transition: var(--transition);
}

.glass-card:hover {
    background: var(--glass-heavy);
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9);
}

/* --- Buttons (Condensed Light / Neon) --- */
button {
    cursor: pointer;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
}

#login-btn, #add-btn, #save-edit-btn, #add-tier-btn, #add-person-btn, #save-batch-people-btn, #batch-move-btn, #batch-people-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--neon-purple) 100%);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

#login-btn:hover, #add-btn:hover, #save-edit-btn:hover, #add-tier-btn:hover, #add-person-btn:hover, #save-batch-people-btn:hover, #batch-move-btn:hover, #batch-people-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

#logout-btn, #delete-entry-btn, .delete-btn {
    background: rgba(239, 68, 68, 0.8);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: white;
}

#logout-btn:hover, #delete-entry-btn:hover, .delete-btn:hover {
    background: rgba(239, 68, 68, 0.8);
    color: white;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

#edit-tiers-btn, #edit-people-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

#edit-tiers-btn:hover, #edit-people-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* --- Mode Selector --- */
.mode-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.mode-toggle {
    background: var(--glass);
    padding: 6px;
    border-radius: 40px;
    display: flex;
    gap: 4px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.mode-btn {
    padding: 10px 24px;
    font-size: 15px;
    border-radius: 30px;
    background: transparent;
    color: var(--text-dim);
}

.mode-btn.active {
    background: white;
    color: black;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    transition: var(--transition);
}

.filter-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.filter-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

/* --- Input Rows --- */
.input-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

input[type="text"], textarea, select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    transition: var(--transition);
    flex: 1;
}

input[type="text"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

/* --- Media Cards (Antigravity) --- */
#tier-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.tier {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tier-label {
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-word;
}

.tier-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    min-height: 80px;
    flex: 1;
    padding: 10px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
}

.media-card {
    width: 160px;
    background: var(--glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
}

.media-card:hover {
    transform: translateY(-8px) scale(1.03);
    background: var(--glass-heavy);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow);
}

.media-card img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-bottom: 1px solid var(--border);
}

.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.card-info {
    padding: 10px;
}

.card-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 25px var(--accent-glow);
}

.media-card.selected::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--accent);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    z-index: 10;
}

/* --- People Pills --- */
.person-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.person-pill:hover {
    background: rgba(255, 255, 255, 0.1);
}

.person-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

/* --- Batch Bar --- */
.batch-bar {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 18, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 12px 32px;
    display: flex;
    align-items: center;
    gap: 32px;
    z-index: 1000;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.batch-btns {
    display: flex;
    gap: 12px;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000; /* Highest priority */
    animation: fadeIn 0.3s ease-out;
}

.confirm-card {
    max-width: 360px;
    text-align: center;
    padding: 40px 30px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.1);
}

.confirm-icon {
    width: 60px;
    height: 60px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin: 0 auto 20px auto;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.confirm-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.confirm-card p {
    margin: 0 0 30px 0;
    font-size: 14px;
    opacity: 0.7;
    line-height: 1.5;
}

.confirm-btns {
    display: flex;
    gap: 12px;
}

.confirm-btns button {
    flex: 1;
}

#confirm-yes-btn {
    background: #ef4444;
}

#confirm-yes-btn:hover {
    background: #dc2626;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4);
}

#confirm-no-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

#confirm-no-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: 90%;
    max-width: 440px;
    animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(25, 25, 30, 0.95);
    padding: 30px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#close-edit-modal, #close-manager-btn, #close-people-btn, .close-modal-btn {
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
}

#close-edit-modal:hover, #close-manager-btn:hover, #close-people-btn:hover, .close-modal-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

#toggle-batch {
    color: var(--accent);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

#toggle-batch:hover {
    background: var(--accent-glow);
    color: white;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--glass-heavy);
    border-radius: 10px;
}

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

/* --- Utilities --- */
.hidden {
    display: none !important;
}

/* --- Sliders & File Inputs --- */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 15px 0;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 0 4px; /* Padding for handle space */
}

input[type="range"]::-webkit-slider-thumb {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: 1px; /* Align within track */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: var(--transition);
}

input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.5);
    box-shadow: 0 0 15px white;
}

input[type="file"] {
    background: var(--glass);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 12px;
    color: var(--text-dim);
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    background: var(--accent);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    margin-right: 15px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        margin-bottom: 10px;
    }

    .mode-container {
        margin-bottom: 10px;
    }

    #input-section {
        margin-bottom: 15px;
    }
    
    #user-info {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        gap: 8px;
    }

    #user-name {
        width: 100%;
        margin-right: 0;
        margin-bottom: 5px;
        font-size: 13px;
    }

    /* Keep header buttons smaller but horizontal */
    #edit-tiers-btn, #edit-people-btn, #logout-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .media-card {
        width: calc(50% - 8px);
        flex-shrink: 0;
    }

    .batch-bar {
        width: 90%;
        flex-direction: column;
        border-radius: 20px;
        padding: 15px;
        gap: 15px;
        bottom: 20px;
    }

    .batch-btns {
        width: 100%;
        justify-content: center;
    }

    /* Main input section stacks on mobile */
    #input-section .input-row {
        flex-direction: column;
    }

    /* Modal input rows with delete buttons MUST stay horizontal */
    .modal-content .input-row, .tier-edit-row, .people-edit-row {
        flex-direction: row !important;
        display: flex !important;
        align-items: center;
        gap: 10px;
        width: 100%;
        margin-bottom: 10px;
    }

    .modal-content .input-row input, .tier-edit-row input, .people-edit-row input {
        flex: 1;
    }

    .mode-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Edit Rows Utility */
.tier-edit-row, .people-edit-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.tier-edit-row input[type="text"], .people-edit-row input[type="text"] {
    flex: 1;
}

.tier-edit-row input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    cursor: pointer;
    background: none;
}

@media (min-width: 769px) {
    .tier {
        flex-direction: row;
        gap: 20px;
        align-items: flex-start;
    }

    .tier-label {
        min-width: 80px;
        min-height: 80px;
        max-width: 120px;
        font-size: 1.4rem;
        flex-shrink: 0;
    }
}

/* iOS Standalone Mode Optimization */
@media (display-mode: standalone) {
    #main-nav-placeholder {
        display: none !important;
    }

    body {
        padding-top: env(safe-area-inset-top);
    }

    .app-container {
        padding-top: 10px; /* Small extra buffer below status bar */
    }
}

/* --- LOGIN OVERLAY (Synced with To-Do List) --- */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #050508 100%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    box-sizing: border-box;
}

#login-overlay h1 {
    font-size: 3.5rem;
    margin: 0;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

#google-login-btn {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, background 0.3s ease;
    animation: fancyGlowPulse 3s infinite alternate;
}

#google-login-btn:hover {
    transform: scale(1.05) translateY(-2px);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 40px rgba(59, 130, 246, 0.5);
}

@keyframes fancyGlowPulse {
    from {
        box-shadow: 0 0 15px rgba(59, 130, 246, 0.25);
    }
    to {
        box-shadow: 0 0 35px rgba(59, 130, 246, 0.5);
    }
}

/* --- PREMIUM LOADER (Synced with To-Do List) --- */
:root {
    --loader-duration: 2s;
    --loader-path-length: 157px;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.premium-loader {
    overflow: visible;
    width: 100px;
    height: 150px;
}

.premium-loader g {
    animation: loader-slide var(--loader-duration) linear infinite;
}

.premium-loader g:nth-child(2) {
    animation-delay: calc(var(--loader-duration) / 4);
}

.premium-loader g:nth-child(2) path {
    animation-delay: calc(var(--loader-duration) / 4);
    stroke-dasharray: 0px calc(var(--loader-path-length) + 1px);
    stroke-dashoffset: 1px;
}

.premium-loader path {
    stroke: url(#loader-gradient);
    stroke-width: 20px;
    stroke-linecap: round;
    fill: none;
    stroke-dasharray: 0 var(--loader-path-length);
    stroke-dashoffset: 0;
    animation: loader-escalade var(--loader-duration) cubic-bezier(0.8, 0, 0.2, 1) infinite;
}

.login-loader {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    opacity: 0.8;
}

.login-loader .premium-loader {
    width: 60px;
    height: 90px;
}

@keyframes loader-slide {
    0% { transform: translateY(-50px); }
    100% { transform: translateY(50px); }
}

@keyframes loader-escalade {
    0% {
        stroke-dasharray: 0 var(--loader-path-length);
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: var(--loader-path-length) var(--loader-path-length);
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dasharray: var(--loader-path-length) var(--loader-path-length);
        stroke-dashoffset: calc(-1 * (var(--loader-path-length) - 1px));
    }
}