/* ===== CSS Variables ===== */
:root {
    --primary-color: #c41e3a;
    --primary-dark: #8b0000;
    --secondary-color: #228b22;
    --secondary-dark: #006400;
    --gold: #ffd700;
    --snow: #fffafa;
    --bg-dark: #1a1a2e;
    --bg-darker: #0f0f1a;
    --text-light: #ffffff;
    --text-dark: #333333;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    min-height: 100vh;
    color: var(--text-light);
}

/* ===== Snowflakes Animation ===== */
.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: white;
    font-size: 1.5rem;
    opacity: 0.8;
    animation: fall linear infinite;
}

.snowflake:nth-child(1) { left: 5%; animation-duration: 10s; animation-delay: 0s; font-size: 1rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 12s; animation-delay: 2s; font-size: 1.5rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 8s; animation-delay: 4s; font-size: 1.2rem; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 1s; font-size: 1.8rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 11s; animation-delay: 3s; font-size: 1rem; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 9s; animation-delay: 5s; font-size: 1.4rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 13s; animation-delay: 0s; font-size: 1.6rem; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 10s; animation-delay: 2s; font-size: 1.1rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 15s; animation-delay: 4s; font-size: 1.3rem; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 11s; animation-delay: 1s; font-size: 1.7rem; }

@keyframes fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.2;
    }
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* ===== Header ===== */
header {
    text-align: center;
    padding: 30px 0;
}

header h1 {
    font-size: 3rem;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
}

.welcome {
    color: var(--snow);
    font-size: 1.1rem;
}

.welcome a {
    color: var(--gold);
    text-decoration: none;
    margin-left: 10px;
}

.welcome a:hover {
    text-decoration: underline;
}

/* Current DateTime Display */
.current-datetime {
    color: var(--snow);
    font-size: 1rem;
    margin-bottom: 8px;
    opacity: 0.9;
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 20px;
    border-radius: 20px;
    display: inline-block;
}

/* Admin Mode Banner */
.admin-mode-banner {
    background: linear-gradient(145deg, #ff6b00, #cc5500);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.admin-mode-banner a {
    background: white;
    color: #cc5500;
    padding: 5px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
}

.admin-mode-banner a:hover {
    background: #f0f0f0;
}

/* Admin preview door styling */
.door.admin-preview.no-content .door-front {
    background: linear-gradient(145deg, #333, #222);
    border-color: #444;
}

.door.admin-preview.no-content .door-status {
    color: #ff6b6b;
}

/* ===== Calendar Grid ===== */
.calendar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    padding: 20px;
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.3), rgba(34, 139, 34, 0.2));
    border-radius: var(--border-radius);
    border: 3px solid var(--secondary-color);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
    .calendar {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
}

@media (max-width: 500px) {
    .calendar {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== Door Styles ===== */
.door {
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.door-front,
.door-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    backface-visibility: hidden;
    transition: transform 0.6s ease;
    box-shadow: var(--shadow);
}

.door-front {
    background: linear-gradient(145deg, var(--primary-color), var(--primary-dark));
    border: 3px solid var(--gold);
}

.door-back {
    background: linear-gradient(145deg, var(--secondary-color), var(--secondary-dark));
    border: 3px solid var(--gold);
    transform: rotateY(180deg);
}

/* Locked doors - gray with lock icon */
.door:not(.can-open):not(.opened) .door-front {
    background: linear-gradient(145deg, #555, #333);
    border-color: #666;
    cursor: not-allowed;
    opacity: 0.7;
}

.door:not(.can-open):not(.opened) .day-number {
    color: #888;
}

.door:not(.can-open):not(.opened) .door-status {
    color: #888;
}

/* Can open - glowing red/gold */
.door.can-open .door-front {
    animation: glow 2s ease-in-out infinite;
    border-width: 4px;
}

.door.can-open .door-status {
    color: var(--gold);
}

/* Opened doors - show green back */
.door.opened .door-front {
    transform: rotateY(-180deg);
}

.door.opened .door-back {
    transform: rotateY(0deg);
}

.door.opening .door-front {
    animation: doorOpen 0.6s ease forwards;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px var(--gold), 0 0 20px var(--gold); }
    50% { box-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold); }
}

@keyframes doorOpen {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(-180deg); }
}

.day-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.door-status {
    font-size: 1.2rem;
    margin-top: 4px;
}

.gift-icon {
    font-size: 2rem;
}

.opened-check {
    font-size: 1.2rem;
    color: white;
    margin-top: 5px;
}

/* Mobile adjustments */
@media (max-width: 500px) {
    .day-number {
        font-size: 1.4rem;
    }
    .door-status {
        font-size: 1rem;
    }
    .gift-icon {
        font-size: 1.5rem;
    }
    .opened-check {
        font-size: 1rem;
    }
}

/* ===== Legend ===== */
.legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

@media (max-width: 500px) {
    .legend {
        gap: 10px;
    }
    .legend-item {
        font-size: 0.95rem;
        padding: 6px 10px;
    }
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-dark);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 800px;
    width: 100%;
    position: relative;
    border: 2px solid var(--gold);
    margin: auto;
}

.modal-content.small {
    max-width: 400px;
}

.modal-content h2,
.modal-content h3 {
    color: var(--gold);
    margin-bottom: 20px;
    text-align: center;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: var(--primary-color);
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.95), rgba(15, 15, 26, 0.95));
    padding: 40px;
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.tree-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.login-header h1 {
    color: var(--gold);
    font-size: 2rem;
}

.login-header p {
    color: var(--snow);
    opacity: 0.8;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--snow);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #444;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.form-group input::placeholder {
    color: #888;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-row .flex-grow {
    flex: 3;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(145deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(196, 30, 58, 0.4);
}

.btn-secondary {
    background: linear-gradient(145deg, var(--secondary-color), var(--secondary-dark));
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 139, 34, 0.4);
}

.btn-danger {
    background: linear-gradient(145deg, var(--danger), #a71d2a);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ===== Messages ===== */
.error-message,
.success-message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.error-message {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid var(--danger);
    color: #ff6b6b;
}

.success-message {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid var(--success);
    color: #51cf66;
}

/* ===== Admin Styles ===== */
.admin-page {
    background: #1a1a2e;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius);
    margin-bottom: 30px;
}

.admin-header h1 {
    color: var(--gold);
    font-size: 1.5rem;
}

.admin-header nav {
    display: flex;
    gap: 20px;
}

.admin-header nav a {
    color: var(--snow);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s;
}

.admin-header nav a:hover,
.admin-header nav a.active {
    background: var(--primary-color);
}

.admin-main h2 {
    color: var(--gold);
    margin-bottom: 25px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.admin-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 25px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-card.full-width {
    grid-column: 1 / -1;
}

.admin-card h3 {
    color: var(--gold);
    margin-bottom: 20px;
    font-size: 1.2rem;
}

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

.stat-card {
    background: linear-gradient(145deg, rgba(196, 30, 58, 0.2), rgba(139, 0, 0, 0.2));
    padding: 25px;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--primary-color);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--gold);
}

.stat-label {
    color: var(--snow);
    opacity: 0.8;
    margin-top: 5px;
}

/* ===== Tables ===== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--gold);
    font-weight: 600;
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.admin-table .actions {
    display: flex;
    gap: 8px;
}

.credentials-table {
    width: 100%;
    margin: 15px 0;
}

.credentials-table td,
.credentials-table th {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.credentials-table code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
}

.generated-users-box {
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid var(--success);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
}

.generated-users-box h3 {
    color: var(--success);
    margin-bottom: 15px;
}

/* ===== Door Status Grid ===== */
.door-status-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.door-status {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
}

.door-status.configured {
    background: rgba(40, 167, 69, 0.3);
    border: 2px solid var(--success);
}

.door-status.missing {
    background: rgba(220, 53, 69, 0.3);
    border: 2px solid var(--danger);
}

.door-status .day {
    font-size: 1.2rem;
}

.door-status .status {
    font-size: 0.8rem;
}

.door-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.door-legend .dot.configured {
    background: var(--success);
}

.door-legend .dot.missing {
    background: var(--danger);
}

/* ===== View Tabs ===== */
.view-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--snow);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover,
.tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ===== Doors Table ===== */
.doors-table input {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
}

.doors-table .day-cell {
    font-weight: bold;
    color: var(--gold);
    width: 50px;
}

.doors-table .status-cell {
    width: 60px;
    text-align: center;
}

.doors-table tr.configured {
    background: rgba(40, 167, 69, 0.1);
}

.status-configured {
    color: var(--success);
    font-size: 1.2rem;
}

.status-missing {
    color: var(--danger);
    font-size: 1.2rem;
}

/* ===== Quick Actions ===== */
.quick-actions {
    margin-bottom: 30px;
}

.quick-actions h3 {
    color: var(--gold);
    margin-bottom: 15px;
}

.quick-actions .btn {
    margin-right: 10px;
}

/* ===== Video Preview ===== */
.video-preview {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 15px;
    }

    .admin-header nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .form-row {
        flex-direction: column;
    }

    .door-status-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    header h1 {
        font-size: 2rem;
    }

    .legend {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}
