﻿/* ======================================
   STATUS PAGES - MODERN MOBILE-FIRST DESIGN
   ====================================== */

/* Force light theme on status pages */
.error-page[data-theme="light"],
.error-page {
    color-scheme: light;
}

.error-page[data-theme="light"] *,
.error-page * {
    color-scheme: light;
}

/* Override any dark mode */
.error-page[data-theme="light"],
.error-page[data-theme="light"] * {
    --bg: 248, 249, 250;
    --white: 252, 252, 252;
    --text: 33, 37, 41;
    --l-text: 108, 117, 125;
    --border: 206, 212, 218;
}

/* Override body min-width for error pages */
body:has(.error-page),
body:has(main.error-page) {
    min-width: 0 !important;
    overflow-x: hidden !important;
    width: 100% !important;
}

/* Fallback for browsers without :has() support - add class to body via JS if needed */
body.error-page-body,
body.status-page-body {
    min-width: 0 !important;
    overflow-x: hidden !important;
    width: 100% !important;
}

/* ======================================
   PAGE LAYOUT
   ====================================== */
.error-page {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100svh;
    width: 100%;
    padding: clamp(16px, 4vw, 32px);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    background: rgb(var(--bg));
    isolation: isolate;
}

/* Animated Background */
.error-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.error-background::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 12px,
            rgba(var(--primary), 0.015) 12px,
            rgba(var(--primary), 0.015) 14px
        ),
        radial-gradient(
            ellipse at 20% 30%,
            rgba(var(--timeline-blue), 0.08) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 80% 70%,
            rgba(var(--render-purple), 0.06) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 40% 80%,
            rgba(var(--playback-green), 0.05) 0%,
            transparent 50%
        );
    animation: backgroundMorph 25s ease-in-out infinite;
    will-change: transform;
    transform: translateZ(0);
}

.error-background::after {
    content: '';
    position: absolute;
    top: -45%;
    left: -45%;
    width: 190%;
    height: 190%;
    background: 
        radial-gradient(ellipse at 70% 40%, rgba(var(--success), 0.06) 0%, transparent 40%),
        radial-gradient(ellipse at 30% 60%, rgba(var(--accent), 0.05) 0%, transparent 45%);
    animation: backgroundMorph 30s ease-in-out infinite reverse;
    will-change: transform;
    transform: translateZ(0);
}

@keyframes backgroundMorph {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(2%, 3%) rotate(1deg);
    }
    66% {
        transform: translate(-2%, -3%) rotate(-1deg);
    }
}

/* ======================================
   ERROR CARD
   ====================================== */
.error-card {
    position: relative;
    background: rgba(var(--white), 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(var(--border), 0.2);
    border-radius: clamp(20px, 5vw, 32px);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.08),
        0 8px 32px rgba(var(--primary), 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    padding: clamp(32px, 8vw, 48px);
    max-width: 640px;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    z-index: 1;
    animation: cardFadeIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@supports not (backdrop-filter: blur(20px)) {
    .error-card {
        background: rgb(var(--white));
    }
}

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

/* ======================================
   ERROR ICON
   ====================================== */
.error-icon-container {
    margin-bottom: clamp(24px, 6vw, 32px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.error-icon {
    position: relative;
    width: clamp(80px, 20vw, 120px);
    height: clamp(80px, 20vw, 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    animation: iconFloat 3s ease-in-out infinite;
}

.error-icon i {
    font-size: clamp(48px, 12vw, 72px);
    color: rgb(var(--primary));
    z-index: 1;
    position: relative;
}

.error-icon::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: linear-gradient(135deg, 
        rgba(var(--primary), 0.1), 
        rgba(var(--accent), 0.05));
    opacity: 0.5;
    animation: iconPulse 2s ease-in-out infinite;
}

.error-icon--401 {
    background: linear-gradient(135deg, 
        rgba(var(--warning-amber), 0.1), 
        rgba(var(--warning-amber), 0.05));
}

.error-icon--401 i {
    color: rgb(var(--warning-amber));
}

.error-icon--403 {
    background: linear-gradient(135deg, 
        rgba(var(--error), 0.1), 
        rgba(var(--error), 0.05));
}

.error-icon--403 i {
    color: rgb(var(--error));
    animation: lockShake 0.5s ease;
}

.error-icon--404 {
    background: linear-gradient(135deg, 
        rgba(var(--primary), 0.1), 
        rgba(var(--primary), 0.05));
}

.error-icon--404 i {
    color: rgb(var(--primary));
}

.error-icon--loading {
    background: linear-gradient(135deg, 
        rgba(var(--primary), 0.1), 
        rgba(var(--accent), 0.05));
}

.error-icon--loading i {
    color: rgb(var(--primary));
}

.error-icon--success {
    background: linear-gradient(135deg, 
        rgba(var(--success), 0.1), 
        rgba(var(--success), 0.05));
}

.error-icon--success i {
    color: rgb(var(--success));
}

.error-icon--error {
    background: linear-gradient(135deg, 
        rgba(var(--error), 0.1), 
        rgba(var(--error), 0.05));
}

.error-icon--error i {
    color: rgb(var(--error));
}

@keyframes iconFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
}

@keyframes lockShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* Loading spinner animation */
.la-spin {
    animation: spin 1s linear infinite;
}

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

/* Confetti animation for success state */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.confetti-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confettiFall 2s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* ======================================
   ERROR CODE
   ====================================== */
.error-code {
    font-size: clamp(72px, 15vw, 120px);
    font-weight: var(--font-weight-black);
    line-height: 1;
    margin: 0 0 clamp(16px, 4vw, 24px) 0;
    background: var(--l-g-regular);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    animation: fadeInScale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

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

/* ======================================
   ERROR TITLE
   ====================================== */
.error-title {
    font-size: clamp(24px, 6vw, 36px);
    font-weight: var(--font-weight-bold);
    color: rgb(var(--text));
    margin: 0 0 clamp(12px, 3vw, 16px) 0;
    line-height: 1.2;
    animation: fadeInScale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

/* ======================================
   ERROR DESCRIPTION
   ====================================== */
.error-description {
    font-size: clamp(15px, 3.75vw, 18px);
    color: rgb(var(--l-text));
    line-height: 1.6;
    margin: 0 0 clamp(32px, 8vw, 40px) 0;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeInScale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s both;
}

/* ======================================
   ERROR ACTIONS
   ====================================== */
.error-actions {
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 3vw, 16px);
    margin-bottom: clamp(32px, 8vw, 40px);
    animation: fadeInScale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}

@media (min-width: 480px) {
    .error-actions {
        flex-direction: row;
        justify-content: center;
    }
}

.error-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 3.5vw, 18px) clamp(24px, 6vw, 32px);
    border-radius: clamp(12px, 3vw, 16px);
    font-size: clamp(15px, 3.75vw, 17px);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    min-height: clamp(48px, 12vw, 52px);
    box-sizing: border-box;
    overflow: hidden;
}

.error-btn--primary {
    background: var(--l-g-regular);
    color: rgb(var(--white));
    box-shadow: 
        0 4px 12px rgba(var(--primary), 0.3),
        0 2px 4px rgba(var(--primary), 0.2);
}

.error-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(var(--primary), 0.4),
        0 4px 8px rgba(var(--primary), 0.3);
}

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

.error-btn--secondary {
    background: rgba(var(--white), 0.9);
    color: rgb(var(--text));
    border: 2px solid rgba(var(--border), 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.error-btn--secondary:hover {
    background: rgb(var(--white));
    border-color: rgba(var(--primary), 0.5);
    color: rgb(var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

/* ======================================
   ERROR HELP SECTION
   ====================================== */
.error-help {
    margin-top: clamp(24px, 6vw, 32px);
    padding-top: clamp(24px, 6vw, 32px);
    border-top: 1px solid rgba(var(--border), 0.2);
    text-align: left;
    animation: fadeInScale 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s both;
}

.error-help__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    padding: clamp(12px, 3vw, 16px);
    border-radius: clamp(10px, 2.5vw, 12px);
    transition: all 0.3s ease;
    user-select: none;
}

.error-help__summary::-webkit-details-marker {
    display: none;
}

.error-help__summary:hover {
    background: rgba(var(--primary), 0.05);
}

.error-help__title {
    font-size: clamp(14px, 3.5vw, 16px);
    font-weight: var(--font-weight-semibold);
    color: rgb(var(--text));
}

.error-help__icon {
    width: 20px;
    height: 20px;
    color: rgb(var(--l-text));
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.error-help[open] .error-help__icon {
    transform: rotate(180deg);
}

.error-help__content {
    padding: clamp(16px, 4vw, 24px);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-help__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 3vw, 16px);
}

.error-help__item {
    display: flex;
    align-items: flex-start;
    gap: clamp(12px, 3vw, 16px);
    font-size: clamp(14px, 3.5vw, 15px);
    color: rgb(var(--l-text));
    line-height: 1.6;
}

.error-help__item-icon {
    width: 18px;
    height: 18px;
    color: rgb(var(--primary));
    flex-shrink: 0;
    margin-top: 2px;
}

.error-help__item span {
    flex: 1;
}

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

/* Small Mobile (320px - 374px) */
@media (max-width: 374px) {
    .error-card {
        padding: 24px;
    }
    
    .error-actions {
        flex-direction: column;
    }
    
    .error-btn {
        width: 100%;
    }
}

/* Mobile (375px - 767px) */
@media (min-width: 375px) and (max-width: 767px) {
    .error-card {
        padding: clamp(32px, 8vw, 40px);
    }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) {
    .error-card {
        padding: 48px;
        max-width: 680px;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .error-card {
        max-width: 720px;
    }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .error-card {
        max-width: 800px;
        padding: 56px;
    }
}

/* ======================================
   ACCESSIBILITY
   ====================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .error-background::before,
    .error-background::after {
        animation: none;
    }
    
    .error-icon {
        animation: none;
    }
    
    .la-spin {
        animation: none;
    }
    
    .confetti-particle {
        display: none;
    }
}

/* Focus visible for keyboard navigation */
.error-btn:focus-visible,
.error-help__summary:focus-visible {
    outline: 3px solid rgba(var(--primary), 0.5);
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .error-card {
        border-width: 2px;
        border-color: rgb(var(--text));
    }
    
    .error-btn--secondary {
        border-width: 2px;
    }
}
