/* ==========================================================
   Bestatter-Portal – Shared Stylesheet
   ========================================================== */

/* ── Ensure [hidden] always works regardless of display rules */
[hidden] { display: none !important; }

/* ── CSS Variables ──────────────────────────────────────── */

:root {
    --color-cream: #FDF8F3;
    --color-warm-white: #FFFBF7;
    --color-gold: #C9A86C;
    --color-gold-light: #E8D4B8;
    --color-gold-dark: #8B7355;
    --color-brown: #5D4E3A;
    --color-brown-light: #7A6B57;
    --color-text: #3D3426;
    --color-text-light: #6B5D4D;
    --color-success: #4CAF50;
    --color-error: #e74c3c;
    --color-info: #3498db;
    --color-warning: #f39c12;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 4px 20px rgba(93, 78, 58, 0.08);
    --shadow-medium: 0 8px 40px rgba(93, 78, 58, 0.12);
    --transition: all 0.3s ease;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Sans 3', -apple-system, sans-serif;
}

/* ── Reset & Base ───────────────────────────────────────── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-cream);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main, .portal-body, .upload-page {
    flex: 1;
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.3;
    color: var(--color-brown);
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem;  font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }

a {
    color: var(--color-gold-dark);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--color-gold);
}

img {
    max-width: 100%;
    display: block;
}

/* ── Container ──────────────────────────────────────────── */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-narrow {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn:focus-visible {
    outline: 2px solid var(--color-gold);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--color-gold);
    color: #fff;
    border-color: var(--color-gold);
}

.btn-primary:hover {
    background: var(--color-gold-dark);
    border-color: var(--color-gold-dark);
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--color-gold-dark);
    border-color: var(--color-gold-light);
}

.btn-secondary:hover {
    background: var(--color-gold-light);
    color: var(--color-brown);
}

.btn-danger {
    background: transparent;
    color: #c0392b;
    border-color: #e0aeaa;
}

.btn-danger:hover {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

.btn-large {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-inactive {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Form Elements ──────────────────────────────────────── */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--color-brown);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--color-gold-light);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--color-text);
    background: #fff;
    transition: var(--transition);
}

.form-input::placeholder {
    color: var(--color-text-light);
    opacity: 0.6;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 108, 0.15);
}

/* ── Card ───────────────────────────────────────────────── */

.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
}

/* ── Status Badges ──────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-created {
    background: #f0f0f0;
    color: #666;
}

.badge-email-sent {
    background: #e8f4fd;
    color: var(--color-info);
}

.badge-uploading {
    background: #fef9e7;
    color: var(--color-warning);
}

.badge-submitted {
    background: #e8f5e9;
    color: var(--color-success);
}

.badge-processing {
    background: #f3e8fd;
    color: #8e44ad;
}

.badge-done {
    background: #e8f5e9;
    color: var(--color-success);
}

/* ── Stepper ────────────────────────────────────────────── */

.stepper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 2rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    color: var(--color-text-light);
    font-size: 0.85rem;
    font-weight: 500;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--color-gold-light);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-light);
    flex-shrink: 0;
}

.step-item.active .step-number {
    background: var(--color-gold);
    border-color: var(--color-gold);
    color: #fff;
}

.step-item.active {
    color: var(--color-brown);
    font-weight: 600;
}

.step-item.completed .step-number {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}

.step-item.completed {
    color: var(--color-success);
}

.step-divider {
    width: 24px;
    height: 2px;
    background: var(--color-gold-light);
    flex-shrink: 0;
}

/* ── Toggle Switch ──────────────────────────────────────── */

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--color-gold-light);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch.active {
    background: var(--color-gold);
}

.toggle-switch.active::after {
    left: 25px;
}

/* ── Footer ─────────────────────────────────────────────── */

.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-text-light);
    font-size: 0.85rem;
}

.footer a {
    color: var(--color-text-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer a:hover {
    color: var(--color-gold);
}

/* ── Spinner ────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-gold-light);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Utility ────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted  { color: var(--color-text-light); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── Responsive (≤ 640px) ──────────────────────────────── */

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.05rem; }

    .container,
    .container-narrow {
        padding: 0 1rem;
    }

    .card {
        padding: 1.15rem;
    }

    .btn {
        padding: 0.55rem 1.15rem;
        font-size: 0.9rem;
    }

    .btn-large {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
    }

    .stepper {
        gap: 0.1rem;
    }

    .step-item {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
    }

    .step-number {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .step-divider {
        width: 12px;
    }
}
