:root {
    --roermond-blue: #1B4F8A;
    --roermond-blue-light: #2D6BB3;
    --roermond-blue-dark: #143A66;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-400: #9CA3AF;
    --gray-600: #4B5563;
    --gray-900: #111827;
    --confetti-red: #E53935;
    --confetti-yellow: #FDD835;
    --confetti-green: #43A047;
    --red-500: #EF4444;
    --red-600: #DC2626;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[x-cloak] { display: none !important; }

body {
    font-family: 'Source Sans 3', sans-serif;
    background: linear-gradient(135deg, #e8f4fc, #c5dff8, #a8d0f0, #d4e8f9, #f0f7fc, #c5dff8, #e8f4fc);
    background-size: 400% 400%;
    background-attachment: fixed;
    animation: gradient-flow 20s ease infinite;
    color: var(--gray-900);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

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

/* ==========================================================================
   Shared components
   ========================================================================== */

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px 48px;
    position: relative;
    z-index: 1;
}

/* Buttons */
.btn,
.login-btn,
.logout-btn {
    font-family: inherit;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 15px;
}

.btn-primary,
.login-btn {
    background: var(--roermond-blue);
    color: var(--white);
}

.btn-primary:hover,
.login-btn:hover {
    background: var(--roermond-blue-dark);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-900);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.button-row {
    display: flex;
    gap: 12px;
}

/* Titles */
.header-title,
.login-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--roermond-blue);
}

.header-title {
    font-size: 42px;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* ==========================================================================
   Confetti animation
   ========================================================================== */

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    opacity: 0.8;
    border-radius: 50%;
    animation: confetti-fall linear infinite;
}

.confetti.red { background: var(--confetti-red); }
.confetti.yellow { background: var(--confetti-yellow); }
.confetti.green { background: var(--confetti-green); }

.confetti:nth-child(1) { left: 5%; animation-duration: 8s; animation-delay: 0s; width: 8px; height: 8px; }
.confetti:nth-child(2) { left: 15%; animation-duration: 10s; animation-delay: 1s; width: 12px; height: 12px; }
.confetti:nth-child(3) { left: 25%; animation-duration: 9s; animation-delay: 2s; width: 6px; height: 6px; }
.confetti:nth-child(4) { left: 35%; animation-duration: 11s; animation-delay: 0.5s; width: 10px; height: 10px; }
.confetti:nth-child(5) { left: 45%; animation-duration: 8.5s; animation-delay: 1.5s; width: 8px; height: 8px; }
.confetti:nth-child(6) { left: 55%; animation-duration: 9.5s; animation-delay: 2.5s; width: 14px; height: 14px; }
.confetti:nth-child(7) { left: 65%; animation-duration: 10.5s; animation-delay: 0.8s; width: 7px; height: 7px; }
.confetti:nth-child(8) { left: 75%; animation-duration: 8.8s; animation-delay: 1.8s; width: 11px; height: 11px; }
.confetti:nth-child(9) { left: 85%; animation-duration: 9.2s; animation-delay: 3s; width: 9px; height: 9px; }
.confetti:nth-child(10) { left: 95%; animation-duration: 10.2s; animation-delay: 0.3s; width: 8px; height: 8px; }
.confetti:nth-child(11) { left: 10%; animation-duration: 11.5s; animation-delay: 2.2s; width: 6px; height: 6px; }
.confetti:nth-child(12) { left: 20%; animation-duration: 8.2s; animation-delay: 3.5s; width: 13px; height: 13px; }
.confetti:nth-child(13) { left: 30%; animation-duration: 9.8s; animation-delay: 1.2s; width: 7px; height: 7px; }
.confetti:nth-child(14) { left: 40%; animation-duration: 10.8s; animation-delay: 2.8s; width: 10px; height: 10px; }
.confetti:nth-child(15) { left: 50%; animation-duration: 8.6s; animation-delay: 0.6s; width: 8px; height: 8px; }
.confetti:nth-child(16) { left: 60%; animation-duration: 9.4s; animation-delay: 1.9s; width: 12px; height: 12px; }
.confetti:nth-child(17) { left: 70%; animation-duration: 11.2s; animation-delay: 3.2s; width: 6px; height: 6px; }
.confetti:nth-child(18) { left: 80%; animation-duration: 8.4s; animation-delay: 0.9s; width: 9px; height: 9px; }
.confetti:nth-child(19) { left: 90%; animation-duration: 10.6s; animation-delay: 2.4s; width: 11px; height: 11px; }
.confetti:nth-child(20) { left: 3%; animation-duration: 9.6s; animation-delay: 1.6s; width: 7px; height: 7px; }
.confetti:nth-child(21) { left: 97%; animation-duration: 8.9s; animation-delay: 3.8s; width: 10px; height: 10px; }

@keyframes confetti-fall {
    0% {
        top: -20px;
        transform: rotate(0deg) translateX(0);
        opacity: 0.9;
    }
    25% { transform: rotate(90deg) translateX(15px); }
    50% { transform: rotate(180deg) translateX(-15px); }
    75% { transform: rotate(270deg) translateX(10px); }
    100% {
        top: 100vh;
        transform: rotate(360deg) translateX(-10px);
        opacity: 0.4;
    }
}

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

/* ==========================================================================
   Header
   ========================================================================== */

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0 40px;
    margin-bottom: 32px;
}

.header-logo {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.header-text {
    text-align: center;
}

.header-subtitle {
    font-size: 16px;
    color: var(--gray-600);
    margin-top: 6px;
}

.header-subtitle a {
    color: inherit;
    text-decoration: underline;
}

/* ==========================================================================
   Upload area
   ========================================================================== */

.upload-area {
    display: block;
    background: var(--white);
    border: 3px dashed var(--gray-200);
    padding: 64px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--roermond-blue);
    background: var(--gray-50);
    transform: scale(1.01);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--roermond-blue);
}

.upload-text {
    font-size: 18px;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.upload-text strong {
    color: var(--roermond-blue);
    font-weight: 600;
}

.upload-hint {
    font-size: 14px;
    color: var(--gray-400);
}

/* ==========================================================================
   Editor
   ========================================================================== */

.editor-wrapper {
    background: var(--white);
    border: 1px solid var(--gray-200);
    margin-bottom: 20px;
}

.canvas-container {
    position: relative;
    touch-action: none;
    user-select: none;
}

.canvas-container canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* Watermark overlay */
.watermark-overlay {
    position: absolute;
    cursor: move;
    user-select: none;
}

.watermark-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.watermark-border {
    position: absolute;
    inset: 0;
    border: 2px dashed var(--roermond-blue);
    opacity: 0.6;
}

.watermark-handle {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 14px;
    height: 14px;
    background: var(--roermond-blue);
    border-radius: 50%;
    cursor: nwse-resize;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Scale slider */
.scale-control {
    background: var(--gray-50);
    padding: 16px 20px;
    border: 1px solid var(--gray-200);
    margin-bottom: 16px;
}

.scale-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.scale-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-900);
}

.scale-value {
    font-size: 13px;
    color: var(--gray-600);
    font-variant-numeric: tabular-nums;
}

.scale-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-200);
    outline: none;
    cursor: pointer;
}

.scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--roermond-blue);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
}

.scale-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.scale-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--roermond-blue);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Warning message */
.warning-box {
    background: #FEF9E7;
    border: 1px solid #F4D03F;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #7D6608;
}

/* ==========================================================================
   Loading overlay
   ========================================================================== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--roermond-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loading-text {
    font-size: 15px;
    color: var(--gray-600);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer-tagline {
    text-align: center;
    padding: 24px 0;
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-style: italic;
    color: var(--gray-600);
    margin-top: 32px;
}

/* ==========================================================================
   Admin styles
   ========================================================================== */

body.admin {
    background: var(--gray-50);
    overflow-x: auto;
}

body.admin .container {
    max-width: 1200px;
    padding: 24px;
}

body.admin .header {
    flex-direction: row;
    justify-content: space-between;
    padding: 24px 0;
    border-bottom: 1px solid var(--gray-200);
}

body.admin .header-title {
    font-size: 28px;
}

.logout-btn {
    padding: 8px 16px;
    background: var(--gray-200);
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
}

.logout-btn:hover {
    background: var(--gray-400);
    color: var(--white);
}

/* Login */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
}

.login-box {
    background: var(--white);
    padding: 48px;
    border: 1px solid var(--gray-200);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-title {
    font-size: 24px;
    margin-bottom: 24px;
}

.login-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--gray-200);
    margin-bottom: 16px;
}

.login-input:focus {
    outline: none;
    border-color: var(--roermond-blue);
}

.login-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
}

/* Date sections */
.date-section {
    margin-bottom: 48px;
}

.date-header {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--roermond-blue);
    margin-bottom: 20px;
}

.date-count {
    font-weight: 400;
    color: var(--gray-400);
    font-size: 16px;
}

/* Image grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.image-card {
    position: relative;
    aspect-ratio: 1;
    background: var(--gray-100);
}

.image-link {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.image-card:hover .image-link {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--red-500);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
}

.image-card:hover .delete-btn,
.delete-btn:focus {
    opacity: 1;
}

.delete-btn:hover,
.delete-btn:active {
    background: var(--red-600);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--gray-400);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
    .image-grid { grid-template-columns: repeat(4, 1fr); }
}

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

@media (max-width: 600px) {
    .header {
        padding: 24px 0 20px;
        margin-bottom: 16px;
        gap: 8px;
    }

    .header-logo {
        width: 64px;
        height: 64px;
    }

    .header-title { font-size: 24px; }
    .header-subtitle { font-size: 13px; margin-top: 2px; }

    .container { padding: 0 16px 32px; }

    .upload-area {
        padding: 32px 20px;
        margin-bottom: 16px;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 12px;
    }

    .upload-text { font-size: 16px; }

    .editor-wrapper {
        background: transparent;
        border: none;
    }

    .scale-control {
        padding: 12px 16px;
        margin-bottom: 12px;
    }

    .button-row { gap: 8px; }
    .btn { padding: 12px 16px; font-size: 14px; }
}

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

@media (hover: none) {
    .delete-btn { opacity: 1; }
}
