/**
 * Premium Christmas-themed styles for Advent Calendar PHP application.
 * Ported from Angular version - designed for accessibility and elderly users.
 * Features: Large fonts, high contrast, festive animations, 3D effects.
 */

/* Christmas color palette */
/* ACCESSIBILITY IMPROVEMENT: Enhanced color contrast for better readability */
:root {
    --christmas-red: #b91c1c;
    --christmas-red-dark: #991b1b;
    --christmas-green: #166534;
    --christmas-green-dark: #14532d;
    --christmas-cream: #fef3c7;
    /* CONTRAST FIX: Brighter gold for better visibility on dark backgrounds */
    --christmas-gold: #fcd34d;
    --christmas-gold-bright: #fde68a; /* Even brighter for critical text */
    --christmas-white: #fefefe;
    --primary-color: #c41e3a;
    --secondary-color: #165b33;
    --background: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #dddddd;
    --locked-color: #999999;
    --unlocked-color: #4caf50;
    /* CONTRAST FIX: Enhanced status colors for better visibility */
    --status-published: #10b981; /* Brighter green */
    --status-draft: #fb923c; /* Brighter orange */
    --status-inactive: #ef4444; /* Brighter red */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Touch optimization for mobile devices */
* {
    -webkit-tap-highlight-color: rgba(251, 191, 36, 0.3);
    -webkit-touch-callout: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Smooth scrolling */
/* PERFORMANCE OPTIMIZATION: Improved rendering and animation performance */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* PERFORMANCE FIX: Use will-change for animated elements */
.floating-shape,
.calendar-door,
.btn,
nav a {
    will-change: transform;
}

/* PERFORMANCE FIX: GPU acceleration for animations */
.calendar-door,
.btn,
nav a,
.floating-shape {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ACCESSIBILITY: Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .floating-shape {
        display: none;
    }

    .calendar-door:hover {
        transform: none !important;
    }
}

/* Prevent overscroll bounce on iOS */
body {
    overscroll-behavior-y: none;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, #0d1b2a 0%, #1b263b 50%, #0d1b2a 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Christmas stars background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 80%, white, transparent),
        radial-gradient(1px 1px at 15% 60%, white, transparent);
    background-size: 200% 200%;
    background-position: 0% 0%;
    opacity: 0.4;
    animation: twinkle 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Better button touch targets */
button {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* Improve input focus on mobile */
input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* ==================== SNOWFALL DECORATION ==================== */
.background-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.floating-shape {
    position: absolute;
    border-radius: 50%;
    background: white;
    opacity: 0.6;
    animation: snowfall 15s linear infinite;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.floating-shape.shape-1 {
    width: 8px;
    height: 8px;
    left: 10%;
    animation-duration: 12s;
    filter: blur(1px);
}

.floating-shape.shape-2 {
    width: 6px;
    height: 6px;
    left: 50%;
    animation-duration: 15s;
    animation-delay: -5s;
}

.floating-shape.shape-3 {
    width: 10px;
    height: 10px;
    left: 80%;
    animation-duration: 18s;
    animation-delay: -10s;
    filter: blur(2px);
}

.floating-shape.shape-4 {
    width: 7px;
    height: 7px;
    left: 25%;
    animation-duration: 14s;
    animation-delay: -3s;
    filter: blur(1px);
}

.floating-shape.shape-5 {
    width: 9px;
    height: 9px;
    left: 65%;
    animation-duration: 16s;
    animation-delay: -7s;
}

.floating-shape.shape-6 {
    width: 5px;
    height: 5px;
    left: 90%;
    animation-duration: 13s;
    animation-delay: -11s;
}

@keyframes snowfall {
    0% {
        transform: translateY(-100px) translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(100vh) translateX(100px) rotate(360deg);
        opacity: 0;
    }
}

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

/* ==================== CONTAINER ==================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
    animation: pageEnter 0.5s ease-out;
}

/* ==================== HEADER ==================== */
header {
    background: transparent;
    padding: 20px 0;
    margin-bottom: 15px;
    position: relative;
    z-index: 10;
}

/* ACCESSIBILITY IMPROVEMENT: Breadcrumb navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-size: 1rem;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.8);
}

.breadcrumb-item a {
    color: var(--christmas-gold-bright);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    padding: 4px 8px;
    border-radius: 6px;
}

.breadcrumb-item a:hover {
    background: rgba(255, 215, 0, 0.2);
    text-decoration: underline;
}

.breadcrumb-item a:focus {
    outline: 3px solid var(--christmas-gold);
    outline-offset: 2px;
}

.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
    user-select: none;
}

.breadcrumb-current {
    color: white;
    font-weight: 700;
}

header .container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    animation: none; /* Disable page enter animation for header */
}

header > .container > div {
    text-align: center;
}

h1 {
    font-family: 'Georgia', serif;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(
        180deg,
        #fef3c7 0%,
        #fbbf24 50%,
        #f59e0b 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 3px;
    filter: drop-shadow(0 4px 8px rgba(251, 191, 36, 0.3));
    animation: titleShimmer 3s ease-in-out infinite;
    line-height: 1.2;
}

@keyframes titleShimmer {
    0%, 100% {
        filter: drop-shadow(0 4px 8px rgba(251, 191, 36, 0.3));
    }
    50% {
        filter: drop-shadow(0 6px 12px rgba(251, 191, 36, 0.6));
    }
}

/* CONTRAST FIX: Brighter subtitle for better readability */
.subtitle {
    font-size: 1rem;
    color: var(--christmas-gold-bright);
    margin-top: 5px;
    opacity: 1;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

header h2 {
    font-size: 1.5rem;
    color: #fbbf24 !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #fbbf24 !important;
    background-clip: initial !important;
    margin-top: 10px;
    margin-bottom: 0;
    font-weight: 700 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6) !important;
    letter-spacing: 1px;
    filter: none !important;
    opacity: 1 !important;
}

/* ==================== NAVIGATION ==================== */
/* ACCESSIBILITY IMPROVEMENT: Enhanced touch targets for elderly users */
nav {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    z-index: 1000;
    animation: none; /* Prevent any inherited animations */
    max-width: calc(100vw - 48px); /* Prevent overflow on small screens */
    justify-content: flex-end;
}

/* Mobile menu toggle button - hidden by default */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1001;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--christmas-green) 0%, var(--christmas-green-dark) 100%);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 4px 15px rgba(22, 101, 52, 0.4);
}

.mobile-menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--christmas-cream);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile menu backdrop overlay */
.mobile-menu-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-backdrop.active {
    display: block;
    opacity: 1;
}

nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* CRITICAL FIX: Increased minimum touch target to 48x48px for accessibility */
    min-width: 48px;
    min-height: 48px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--christmas-green) 0%, var(--christmas-green-dark) 100%);
    color: var(--christmas-cream);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem; /* Increased from 0.875rem for better readability */
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(22, 101, 52, 0.4);
    white-space: nowrap;
}

nav a:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(22, 101, 52, 0.5), 0 0 15px rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.6);
}

/* ACCESSIBILITY IMPROVEMENT: Stronger focus indicator */
nav a:focus {
    outline: 4px solid var(--christmas-gold);
    outline-offset: 3px;
    box-shadow: 0 0 0 8px rgba(255, 215, 0, 0.3);
}

/* ==================== MAIN CONTENT ==================== */
main {
    background: transparent;
    border-radius: 0;
    padding: 40px 20px;
    min-height: 500px;
    position: relative;
    z-index: 1;
}

/* ==================== CALENDAR GRID ==================== */
.calendar-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.calendar-content {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.calendar-info {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.info-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    color: var(--christmas-cream);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    padding: 24px;
    background: transparent;
    border-radius: 0;
    border: none;
    box-shadow: none;
    margin-top: 0;
}

/* ==================== CALENDAR DOOR (PREMIUM 3D TILES) ==================== */
.calendar-door {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    transform-style: preserve-3d;
    text-decoration: none;
    color: white;
    overflow: hidden;
    background: linear-gradient(
        135deg,
        rgba(220, 38, 38, 0.9) 0%,
        rgba(153, 27, 27, 0.95) 100%
    );
    border: 2px solid rgba(255, 215, 0, 0.6);
}

/* Inner glow on hover */
.calendar-door::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.3) 0%,
        transparent 70%
    );
    pointer-events: none;
}

.calendar-door:not(.locked):hover::after {
    opacity: 1;
}

/* Animated border glow for available doors */
.calendar-door::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 215, 0, 0.5),
        transparent,
        rgba(255, 215, 0, 0.5)
    );
    border-radius: 18px;
    z-index: -1;
    animation: borderGlow 3s linear infinite;
    background-size: 400%;
}

@keyframes borderGlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.calendar-door:not(.locked):hover {
    transform: scale(1.12) rotateX(5deg) rotateY(-5deg);
    box-shadow:
        0 15px 35px rgba(220, 38, 38, 0.5),
        0 0 30px rgba(255, 215, 0, 0.4),
        0 5px 15px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(185, 28, 28, 0.95) 100%);
    border-color: rgba(255, 215, 0, 0.8);
}

.calendar-door:not(.locked):active {
    transform: scale(1.05) rotateX(0) rotateY(0);
}

.calendar-door:not(.locked):focus {
    outline: 3px solid var(--christmas-gold);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.3);
}

/* ACCESSIBILITY FIX: Enhanced locked state with better visual feedback */
.calendar-door.locked {
    background: #808080;
    border: 2px solid #999999;
    color: rgba(255, 255, 255, 0.8);
    cursor: not-allowed;
    position: relative;
    pointer-events: none;
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

/* No hover effect for locked doors - they remain static */

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

/* Empty state (no content, orange/amber) */
.calendar-door.day-empty {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.3) 0%, rgba(245, 158, 11, 0.3) 100%);
    border: 2px solid rgba(251, 191, 36, 0.4);
    color: var(--christmas-white);
}

.calendar-door.day-empty:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(251, 146, 60, 0.4);
}

.door-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 1;
}

/* ==================== LOADING SPINNER ==================== */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
}

.spinner-ring {
    position: absolute;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: spinMulti 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
    width: 100%;
    height: 100%;
    border-top-color: var(--christmas-gold);
    animation-delay: -0.45s;
}

.spinner-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-right-color: var(--christmas-green);
    animation-delay: -0.3s;
}

.spinner-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-bottom-color: var(--christmas-red);
    animation-delay: -0.15s;
}

.loading-spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: var(--christmas-gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
}

@keyframes spinMulti {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== CONTENT DISPLAY ==================== */
.content-wrapper {
    margin-top: 0px;
    padding-top: 0px;
    animation: pageEnter 0.5s ease-out;
}

.content-header {
    text-align: center;
    margin-bottom: 15px;
}

.content-header h2 {
    font-size: 3rem;
    font-family: 'Georgia', serif;
    font-weight: bold;
    color: #fbbf24;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(251, 191, 36, 0.8),
        0 0 40px rgba(251, 191, 36, 0.5);
    margin: 0;
    padding: 10px 0;
}

.content-body {
    max-width: 800px;
    margin: 0 auto;
}

.content-message {
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--christmas-cream);
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.content-media {
    text-align: center;
    margin: 30px 0;
}

.content-media img,
.content-media video {
    width: 100%;
    max-width: 100%;
    max-height: 70vh; /* Fit to 70% of viewport height */
    height: auto;
    object-fit: contain; /* Maintain aspect ratio while fitting */
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 215, 0, 0.3);
}

/* ==================== DOWNLOAD BUTTON ==================== */
.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 32px;
    margin: 20px auto 0;
    background: linear-gradient(135deg, var(--christmas-green) 0%, var(--christmas-green-dark) 100%);
    color: white;
    text-decoration: none;
    border: 2px solid var(--christmas-gold);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(22, 91, 51, 0.5);
    cursor: pointer;
}

.content-media {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.btn-download svg {
    stroke: var(--christmas-gold);
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

/* Button group for download and back buttons */
.button-group {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 20px;
    width: 100%;
}

.button-group .btn-download {
    margin: 0;
    flex: 1 1 auto;
    min-width: 200px;
    max-width: 300px;
}

.button-group .btn-download:hover {
    background: linear-gradient(135deg, var(--christmas-green) 0%, #0a5c2e 100%);
    border-color: var(--christmas-gold-bright);
}

/* Mobile optimization */
@media (max-width: 768px) {
    .button-group {
        gap: 12px;
    }

    .button-group .btn-download,
    .button-group .btn {
        min-width: 150px;
        font-size: 0.95rem;
        padding: 12px 20px;
    }
}

@media (max-width: 480px) {
    .button-group {
        flex-direction: column;
        gap: 12px;
    }

    .button-group .btn-download,
    .button-group .btn {
        width: 100%;
        max-width: 100%;
    }
}

.btn-download span {
    color: var(--christmas-gold);
    font-weight: 700;
    text-transform: uppercase;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22, 91, 51, 0.7);
    background: linear-gradient(135deg, var(--christmas-green) 0%, #0a5c2e 100%);
    border-color: var(--christmas-gold-bright);
}

.btn-download:hover svg {
    transform: translateY(2px);
}

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

.btn-download:focus-visible {
    outline: 3px solid var(--christmas-gold);
    outline-offset: 2px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .btn-download {
        font-size: 0.95rem;
        padding: 12px 24px;
    }
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 24px;
    position: relative; /* VALIDATION FIX: For positioning error messages */
}

label {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--christmas-white);
    margin-bottom: 12px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ACCESSIBILITY IMPROVEMENT: Required field indicator */
label.required::after {
    content: ' *';
    color: var(--status-inactive);
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 16px;
    font-size: 1.125rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 10px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    color: #333;
}

/* ACCESSIBILITY IMPROVEMENT: Stronger focus states */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--christmas-gold);
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.4);
    background: white;
}

/* VALIDATION FIX: Error state styling */
input.error,
textarea.error,
select.error {
    border-color: var(--status-inactive);
    background: rgba(255, 240, 240, 0.95);
}

input.error:focus,
textarea.error:focus,
select.error:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3);
}

/* VALIDATION FIX: Success state styling */
input.success,
textarea.success,
select.success {
    border-color: var(--status-published);
    background: rgba(240, 255, 244, 0.95);
}

/* VALIDATION FIX: Inline error message */
.error-message {
    display: block;
    margin-top: 8px;
    color: var(--status-inactive);
    font-size: 1rem;
    font-weight: 600;
    background: rgba(254, 226, 226, 0.95);
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 4px solid var(--status-inactive);
    animation: slideDown 0.3s ease;
}

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

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: #666;
    opacity: 1;
}

input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
textarea:disabled,
select:disabled {
    background-color: rgba(245, 245, 245, 0.8);
    cursor: not-allowed;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-block;
    padding: 18px 30px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    /* ACCESSIBILITY FIX: Minimum touch target size */
    min-height: 56px;
    min-width: 56px;
    position: relative;
}

/* LOADING STATE FIX: Loading spinner for buttons */
.btn.loading {
    color: transparent;
    pointer-events: none;
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    top: 50%;
    left: 50%;
    margin-left: -12px;
    margin-top: -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.btn-primary {
    background: linear-gradient(135deg, var(--christmas-red) 0%, var(--christmas-red-dark) 100%);
    color: white;
    border: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 4px 15px rgba(196, 30, 58, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(196, 30, 58, 0.6);
    background: linear-gradient(135deg, #d4223f 0%, #a00000 100%);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary:focus {
    outline: 3px solid var(--christmas-gold);
    outline-offset: 2px;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--christmas-green) 0%, var(--christmas-green-dark) 100%);
    color: white;
    border: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 4px 15px rgba(22, 101, 52, 0.4);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #14532d 0%, #0f4426 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(22, 101, 52, 0.6);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(231, 76, 60, 0.6);
}

.btn-block {
    width: 100%;
    display: block;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 1.1rem;
    backdrop-filter: blur(10px);
    border: 2px solid;
}

.alert-success {
    background: rgba(212, 237, 218, 0.95);
    color: #155724;
    border-color: #c3e6cb;
}

.alert-error {
    background: rgba(248, 215, 218, 0.95);
    color: #721c24;
    border-color: #f5c6cb;
}

.alert-info {
    background: rgba(209, 236, 241, 0.95);
    color: #0c5460;
    border-color: #bee5eb;
}

/* ==================== TABLES ==================== */
/* CONTRAST FIX: Improved table readability for elderly users */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 2px solid #e5e5e5; /* Stronger border for better visibility */
    font-size: 1.0625rem; /* Slightly larger text */
}

th {
    background: rgba(251, 191, 36, 0.25); /* Slightly darker for better contrast */
    font-weight: 700;
    font-size: 1.125rem;
    color: #1a1a1a; /* Darker text for better contrast */
    border-bottom: 3px solid #d4a855;
}

tr:hover {
    background: rgba(251, 191, 36, 0.15); /* Slightly more visible hover */
    transition: background-color 0.2s ease;
}

/* ACCESSIBILITY FIX: Action links styling in tables */
table a {
    color: #0066cc; /* High contrast blue */
    text-decoration: underline;
    font-weight: 600;
    transition: all 0.2s ease;
    /* TOUCH TARGET FIX: Better spacing between action links */
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 4px;
}

table a:hover {
    color: #004999;
    background: rgba(0, 102, 204, 0.1);
}

table a:focus {
    outline: 3px solid var(--christmas-gold);
    outline-offset: 2px;
}

/* Special styling for danger actions (delete) */
table a[style*="color: red"],
table a[onclick*="confirm"] {
    color: #dc2626 !important;
    font-weight: 700;
}

table a[style*="color: red"]:hover,
table a[onclick*="confirm"]:hover {
    color: #991b1b !important;
    background: rgba(220, 38, 38, 0.1);
}

/* Status indicators with better contrast */
table span[style*="color: green"] {
    color: var(--status-published) !important;
    font-weight: 700;
}

table span[style*="color: orange"] {
    color: var(--status-draft) !important;
    font-weight: 700;
}

table span[style*="color: red"] {
    color: var(--status-inactive) !important;
    font-weight: 700;
}

/* Code elements in tables (for tokens) */
table code {
    font-size: 0.95em;
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    font-family: 'Courier New', monospace;
}

/* Copy button styling */
table button {
    margin-left: 8px;
    padding: 4px 12px;
    font-size: 0.9375rem;
    cursor: pointer;
    background: var(--christmas-green);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 32px;
}

table button:hover {
    background: var(--christmas-green-dark);
    transform: translateY(-1px);
}

table button:focus {
    outline: 3px solid var(--christmas-gold);
    outline-offset: 2px;
}

/* ==================== LOGIN PAGE ==================== */
.login-container {
    max-width: 500px;
    margin: 100px auto;
    padding: 48px;
    background: linear-gradient(135deg, rgba(196, 30, 58, 0.15) 0%, rgba(22, 91, 51, 0.15) 100%);
    backdrop-filter: blur(20px);
    border: 3px solid;
    border-image: linear-gradient(
        45deg,
        var(--christmas-red) 0%,
        var(--christmas-gold) 25%,
        var(--christmas-green) 50%,
        var(--christmas-gold) 75%,
        var(--christmas-red) 100%
    ) 1;
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 40px rgba(255, 215, 0, 0.1),
        inset 0 0 60px rgba(255, 215, 0, 0.05);
    position: relative;
    z-index: 10;
    animation: pageEnter 0.5s ease-out;
}

.login-container h2 {
    text-align: center;
    font-family: 'Georgia', serif;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--christmas-gold) 0%, #fff 50%, var(--christmas-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 8px 0;
    filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.5));
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% {
        filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.5)) brightness(1);
    }
    50% {
        filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.8)) brightness(1.2);
    }
}

/* CONTRAST FIX: Brighter year text for login page */
.login-container .year {
    display: block;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--christmas-gold-bright);
    margin-bottom: 16px;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.login-container p {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ==================== ADMIN DASHBOARD ==================== */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.9) 0%, rgba(22, 101, 52, 0.9) 100%);
    backdrop-filter: blur(10px);
    color: white;
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.3);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 215, 0, 0.6);
}

.stat-card h3 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.stat-card p {
    font-size: 1.1rem;
    opacity: 0.9;
}

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

/* Tablet */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    h1 {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    header .container {
        flex-direction: row;
        justify-content: center;
    }

    /* MOBILE FIX: Allow navigation to wrap on tablets */
    nav {
        flex-wrap: wrap;
        justify-content: flex-end;
        max-width: calc(100vw - 48px);
        gap: 10px;
    }

    nav a {
        padding: 10px 18px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    main {
        padding: 20px;
        padding-top: 60px; /* Add space for wrapped navigation */
    }

    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
        padding: 20px;
    }

    .door-number {
        font-size: 1.75rem;
    }

    .login-container {
        margin: 50px 20px;
        padding: 32px 24px;
    }

    .login-container h2 {
        font-size: 2rem;
    }
}

/* Mobile optimized for smartphone */
/* ACCESSIBILITY FIX: Maintain larger text size on mobile for elderly users */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    header {
        background: transparent;
        position: relative;
        padding: 12px 0;
        margin-bottom: 20px;
    }

    header .container {
        padding: 0 12px;
    }

    /* MOBILE FIX: Show hamburger menu, hide regular nav */
    .mobile-menu-toggle {
        display: flex;
    }

    nav {
        position: fixed;
        top: 72px;
        right: 12px;
        left: auto;
        flex-direction: column;
        width: calc(100% - 24px);
        max-width: 300px;
        background: rgba(13, 27, 42, 0.98);
        backdrop-filter: blur(20px);
        border: 2px solid rgba(255, 215, 0, 0.4);
        border-radius: 16px;
        padding: 12px;
        gap: 8px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
        /* Hide by default */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s ease;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }

    nav.mobile-menu-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    nav a {
        width: 100%;
        padding: 14px 20px;
        font-size: 1rem;
        min-width: auto;
        min-height: 52px;
        justify-content: flex-start;
        text-align: left;
        border-radius: 10px;
    }

    nav a:hover {
        transform: translateX(5px);
    }

    main {
        margin-top: 0;
        padding-top: 20px;
    }

    h1 {
        font-size: 1.75rem;
        letter-spacing: 1.5px;
        margin-top: 0;
        padding-right: 0;
        text-align: center;
    }

    header .container > div {
        width: 100%;
        text-align: center;
    }

    .calendar-content {
        max-width: 100%;
    }

    .calendar-info {
        margin-bottom: 20px;
    }

    .info-badge {
        padding: 12px 24px;
        font-size: 1rem;
    }

    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
        padding: 16px;
    }

    .calendar-door {
        min-height: 70px;
        border-width: 2px;
    }

    .door-number {
        font-size: 1.75rem;
    }

    .calendar-door:active {
        transform: scale(0.95);
    }

    .content-header h2 {
        font-size: 2rem;
    }

    .content-message {
        font-size: 1.125rem;
        padding: 20px;
    }

    /* MOBILE FIX: Better breadcrumb wrapping on small screens */
    .breadcrumb {
        font-size: 0.9rem;
        padding: 10px 16px;
        margin-top: 10px;
    }
}

/* Extra small smartphones */
@media (max-width: 400px) {
    .container {
        padding: 8px;
        padding-top: 8px;
    }

    .mobile-menu-toggle {
        width: 46px;
        height: 46px;
    }

    nav {
        top: 68px;
        right: 8px;
        width: calc(100% - 16px);
    }

    nav a {
        padding: 12px 16px;
        font-size: 0.95rem;
        min-height: 48px;
    }

    h1 {
        font-size: 1.5rem;
        letter-spacing: 1px;
    }

    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 12px;
    }

    .calendar-door {
        min-height: 60px;
    }

    .door-number {
        font-size: 1.5rem;
    }
}

/* Very small screens - reduce to 3 columns for better touch targets */
@media (max-width: 340px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .calendar-door {
        min-height: 70px;
    }

    .door-number {
        font-size: 1.75rem;
    }
}

/* ==================== EMPTY STATES ==================== */
/* ACCESSIBILITY IMPROVEMENT: Helpful empty state messages */
.empty-state {
    text-align: center;
    padding: 60px 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 2px dashed rgba(255, 215, 0, 0.4);
    margin: 40px 0;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-state-title {
    font-size: 1.75rem;
    color: var(--christmas-gold-bright);
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.empty-state-message {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    margin-bottom: 24px;
}

.empty-state-action {
    margin-top: 20px;
}

/* ==================== ACCESSIBILITY ==================== */
.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;
}

/* ACCESSIBILITY IMPROVEMENT: Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--christmas-red);
    color: white;
    padding: 12px 20px;
    text-decoration: none;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    z-index: 10000;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 4px solid var(--christmas-gold);
    outline-offset: 0;
}

/* ACCESSIBILITY FIX: Enhanced keyboard navigation indicators */
/* Show focus indicator only for keyboard navigation, not mouse clicks */
:focus-visible {
    outline: 4px solid var(--christmas-gold) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 8px rgba(255, 215, 0, 0.3) !important;
}

/* Remove focus outline for mouse clicks */
:focus:not(:focus-visible) {
    outline: none;
}

/* Keyboard navigation helper - shows current focus area */
body.user-is-tabbing *:focus {
    outline: 4px solid var(--christmas-gold) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 8px rgba(255, 215, 0, 0.3) !important;
}

/* Visual indicator for interactive elements when tabbing */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    position: relative;
}

a:focus-visible::after,
button:focus-visible::after {
    content: '??';
    position: absolute;
    top: -24px;
    right: -24px;
    font-size: 1.25rem;
    opacity: 0.8;
    pointer-events: none;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* ==================== TOAST NOTIFICATIONS ==================== */
/* ACCESSIBILITY IMPROVEMENT: Non-intrusive feedback for user actions */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    background: white;
    color: #333;
    padding: 16px 24px;
    margin-bottom: 12px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.0625rem;
    font-weight: 600;
    border-left: 5px solid;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 4.7s;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

.toast.toast-success {
    border-left-color: var(--status-published);
    background: rgba(240, 255, 244, 0.98);
}

.toast.toast-error {
    border-left-color: var(--status-inactive);
    background: rgba(254, 226, 226, 0.98);
}

.toast.toast-info {
    border-left-color: #3b82f6;
    background: rgba(219, 234, 254, 0.98);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .toast-container {
        top: 60px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ==================== LANDSCAPE MOBILE OPTIMIZATION ==================== */
/* Handle landscape orientation on mobile devices */
@media (max-width: 900px) and (max-height: 600px) and (orientation: landscape) {
    nav {
        top: 8px;
        right: 8px;
        gap: 6px;
    }

    nav a {
        padding: 6px 12px;
        font-size: 0.75rem;
        min-height: 36px;
    }

    main {
        padding-top: 50px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .calendar-grid {
        padding: 12px;
        gap: 10px;
    }
}

/* ==================== MOBILE BACK BUTTON ==================== */
/* Prominent back button for navigation on day pages */
.mobile-back-button {
    display: block;
    margin: 40px auto 20px auto;
    max-width: 600px;
}

.mobile-back-button a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.125rem;
    min-height: 56px;
}

@media (max-width: 768px) {
    .mobile-back-button {
        position: sticky;
        bottom: 20px;
        z-index: 100;
        margin: 30px 0;
        padding: 0 12px;
    }

    .mobile-back-button a {
        box-shadow: 0 8px 32px rgba(22, 101, 52, 0.6);
    }

    .mobile-back-button a:active {
        transform: scale(0.98);
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    header nav,
    .background-decoration,
    body::before {
        display: none !important;
    }

    body {
        background: white;
    }

    .calendar-door {
        border: 1px solid #333;
        color: #333;
    }

    table {
        box-shadow: none;
    }
}
