/**
 * Huntarr Login — Premium Design v2
 * Deep glass card over rotating cinematic backdrop
 */

/* ═══════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

.login-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100vw;
    background: #0a0e1a;
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow: hidden;
}

/* Hide sidebar/nav elements that JS might inject */
.login-page #sidebar-wrapper,
.login-page #sidebar,
.login-page .sidebar-wrapper,
.login-page .sidebar,
.login-page .topbar,
.login-page .mobile-topbar,
.login-page .app-container {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* ═══════════════════════════════════════════════════
   Rotating Backdrop Layers
   ═══════════════════════════════════════════════════ */
.login-backdrop-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 2.5s ease-in-out;
    will-change: opacity;
    transform: scale(1.02);
}

.login-backdrop-layer.visible {
    opacity: 1;
}

/* Rich overlay with depth — navy vignette + subtle warm tint */
.login-backdrop-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background:
        /* Subtle warm center glow */
        radial-gradient(ellipse at center, rgba(245, 158, 11, 0.02) 0%, transparent 50%),
        /* Center darken for card readability */
        radial-gradient(ellipse at center, rgba(10, 14, 26, 0.65) 0%, rgba(10, 14, 26, 0.4) 50%, rgba(10, 14, 26, 0.55) 100%),
        /* Vignette */
        radial-gradient(ellipse at center, transparent 35%, rgba(10, 14, 26, 0.6) 100%);
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════ */
@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) translateY(0) scale(1);
    }
}

@keyframes loginShimmer {
    from {
        left: -100%;
    }

    to {
        left: 100%;
    }
}

@keyframes loginPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.9;
    }
}

@keyframes loginFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* ═══════════════════════════════════════════════════
   Login Card — deep glassmorphism
   ═══════════════════════════════════════════════════ */
.login-container {
    position: fixed;
    z-index: 2;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 430px;
    max-width: 92%;
    background: linear-gradient(168deg,
            rgba(16, 22, 36, 0.82) 0%,
            rgba(11, 15, 25, 0.88) 40%,
            rgba(8, 12, 22, 0.92) 100%);
    backdrop-filter: blur(32px) saturate(1.2);
    -webkit-backdrop-filter: blur(32px) saturate(1.2);
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.06);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 1px 0 0 rgba(255, 255, 255, 0.04) inset,
        0 40px 120px -16px rgba(0, 0, 0, 0.7),
        0 12px 40px -8px rgba(0, 0, 0, 0.35),
        0 0 100px -30px rgba(99, 102, 241, 0.08);
    overflow: hidden;
    animation: loginCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Top-edge accent — indigo-to-amber gradient highlight */
.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(99, 102, 241, 0.4) 15%,
            rgba(139, 92, 246, 0.5) 35%,
            rgba(245, 158, 11, 0.4) 50%,
            rgba(139, 92, 246, 0.5) 65%,
            rgba(99, 102, 241, 0.4) 85%,
            transparent 100%);
    z-index: 10;
}

/* Subtle ambient glow behind card */
.login-container::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -25%;
    right: -25%;
    bottom: -50%;
    background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.03) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
}

/* ── Header ─────────────────────────────────────── */
.login-header {
    padding: 36px 0 22px;
    text-align: center;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.03) 0%, transparent 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
    position: relative;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 12px;
    border-radius: 16px;
    filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.2));
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: loginFloat 4s ease-in-out infinite;
}

.login-logo:hover {
    transform: scale(1.08) translateY(-2px);
    filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.35));
}

.login-header h1 {
    margin: 0;
    color: #f8fafc;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

/* ── Form Area ────────────────────────────────────── */
.login-form {
    padding: 28px 30px 24px;
}

.login-form h2 {
    margin: 0 0 24px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(148, 163, 184, 0.6);
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════
   Form Inputs — frosted glass fields
   ═══════════════════════════════════════════════════ */
.form-group {
    margin-bottom: 18px;
    position: relative;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.55);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group label i {
    color: rgba(99, 102, 241, 0.65);
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
    width: 100%;
    padding: 13px 16px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-radius: 12px;
    color: #f1f5f9;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) inset;
}

.form-group input:hover {
    border-color: rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.55);
}

.form-group input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.45);
    background: rgba(15, 23, 42, 0.55);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.12) inset,
        0 0 0 3px rgba(99, 102, 241, 0.08),
        0 0 20px rgba(99, 102, 241, 0.05);
}

.form-group input::placeholder {
    color: rgba(71, 85, 105, 0.6);
}

/* Password toggle */
.toggle-password {
    position: absolute;
    right: 14px;
    top: 40px;
    cursor: pointer;
    color: rgba(148, 163, 184, 0.35);
    z-index: 10;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.toggle-password:hover {
    color: rgba(148, 163, 184, 0.7);
    transform: scale(1.1);
}

/* ── Form Actions (remember me) ─────────────────── */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0 6px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    accent-color: #6366f1;
    width: 16px;
    height: 16px;
    cursor: pointer;
    border-radius: 4px;
}

.form-check label {
    font-size: 0.82rem;
    color: rgba(148, 163, 184, 0.55);
    cursor: pointer;
    margin: 0;
    transition: color 0.15s;
}

.form-check label:hover {
    color: rgba(148, 163, 184, 0.8);
}

/* ═══════════════════════════════════════════════════
   Login Button — rich gradient with shimmer
   ═══════════════════════════════════════════════════ */
.login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 40%, #4f46e5 100%);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 10px;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 2px 8px rgba(99, 102, 241, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.02em;
}

/* Shimmer sweep */
.login-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    transition: left 0.5s ease;
}

.login-button:hover::after {
    left: 100%;
}

.login-button:hover {
    box-shadow:
        0 8px 28px rgba(99, 102, 241, 0.4),
        0 0 60px rgba(99, 102, 241, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    transform: translateY(-2px);
}

.login-button:active {
    transform: translateY(0);
    box-shadow:
        0 2px 8px rgba(99, 102, 241, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.login-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    filter: saturate(0.6);
}

/* Forgot password */
.forgot-password-section {
    text-align: center;
    margin-top: 16px;
}

.forgot-password-link {
    color: rgba(100, 116, 139, 0.6);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.forgot-password-link:hover {
    color: #a5b4fc;
}

.forgot-password-link i {
    margin-right: 5px;
    font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════
   Plex Login Section
   ═══════════════════════════════════════════════════ */
.plex-login-section {
    padding: 0 30px 26px;
    text-align: center;
}

.auth-divider {
    text-align: center;
    color: rgba(71, 85, 105, 0.5);
    margin: 0 0 18px;
    position: relative;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(71, 85, 105, 0.2), transparent);
}

.auth-divider span {
    background: rgba(10, 14, 24, 0.9);
    padding: 0 16px;
    position: relative;
    border-radius: 8px;
}

.plex-login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 24px;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.06);
    color: #fbbf24;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
}

.plex-login-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.06), transparent);
    transition: left 0.5s ease;
}

.plex-login-button:hover::after {
    left: 100%;
}

.plex-login-button:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow:
        0 6px 20px rgba(245, 158, 11, 0.12),
        0 0 40px rgba(245, 158, 11, 0.04);
    transform: translateY(-1px);
}

.plex-login-button:active {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════
   Error Message
   ═══════════════════════════════════════════════════ */
.error-message {
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-left: 3px solid rgba(239, 68, 68, 0.6);
    margin-bottom: 18px;
    text-align: center;
    display: none;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.04) inset;
}

/* ═══════════════════════════════════════════════════
   Modals (Plex + Recovery)
   ═══════════════════════════════════════════════════ */
.plex-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.75);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.plex-modal[style*="display: block"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.plex-modal-content {
    position: relative;
    background: linear-gradient(168deg,
            rgba(16, 22, 36, 0.92) 0%,
            rgba(11, 15, 25, 0.95) 100%);
    backdrop-filter: blur(24px) saturate(1.1);
    -webkit-backdrop-filter: blur(24px) saturate(1.1);
    border: 1px solid rgba(148, 163, 184, 0.06);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 18px;
    padding: 32px;
    width: 430px;
    max-width: 92%;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 40px 120px -16px rgba(0, 0, 0, 0.65),
        0 12px 40px -8px rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
}

.plex-modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.plex-modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #f8fafc;
}

.plex-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
}

.plex-pin-display {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.18);
    border-radius: 14px;
    padding: 18px;
    text-align: center;
    margin: 16px 0;
}

.plex-pin-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: #f0ad4e;
    letter-spacing: 2px;
    margin: 8px 0;
    word-break: break-all;
    line-height: 1.4;
}

.plex-status {
    margin: 14px 0;
    padding: 11px 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.5;
    font-weight: 500;
}

.plex-status.waiting {
    background: rgba(59, 130, 246, 0.06);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.12);
}

.plex-status.success {
    background: rgba(34, 197, 94, 0.06);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.12);
}

.plex-status.error {
    background: rgba(239, 68, 68, 0.06);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.12);
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: rgba(148, 163, 184, 0.5);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.5);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fff;
    transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════
   Recovery Form (inside modal)
   ═══════════════════════════════════════════════════ */
.recovery-form .form-group {
    margin-bottom: 16px;
}

.recovery-form .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.55);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.recovery-form .form-group label i {
    color: rgba(99, 102, 241, 0.6);
}

.recovery-form .form-group input {
    width: 100%;
    padding: 13px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-radius: 12px;
    color: #f1f5f9;
    font-size: 0.95rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) inset;
}

.recovery-form .form-group input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.12) inset,
        0 0 0 3px rgba(99, 102, 241, 0.08),
        0 0 20px rgba(99, 102, 241, 0.05);
}

.recovery-form .login-button {
    margin-bottom: 8px;
}

.recovery-form .login-button[style*="background: linear-gradient(135deg, #22c55e"] {
    background: linear-gradient(135deg, #22c55e, #16a34a) !important;
}

/* ═══════════════════════════════════════════════════
   Spinner
   ═══════════════════════════════════════════════════ */
.spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ═══════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .login-container {
        max-width: 96%;
        border-radius: 18px;
    }

    .login-form {
        padding: 22px 22px 18px;
    }

    .login-header {
        padding: 28px 0 18px;
    }

    .login-logo {
        width: 58px;
        height: 58px;
    }

    .login-header h1 {
        font-size: 1.3rem;
    }

    .plex-login-section {
        padding: 0 22px 20px;
    }

    /* Prevent iOS zoom on input focus */
    .form-group input {
        font-size: 16px !important;
    }
}