/* ============================================================
   eGovPH Registration Booth — Design System
   All legacy class names are preserved (JS/PHP depend on them);
   new components are additive (brand-bar, steps, toast, etc.).
   ============================================================ */

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

:root {
    /* Brand — civic blue */
    --primary: #0b4da3;
    --primary-hover: #083d82;
    --primary-700: #0a3671;
    --primary-500: #1c66d4;
    --primary-light: #eaf1fc;
    --primary-soft: #f4f8fe;
    --accent: #2563eb;

    /* Flag-inspired accents (used sparingly) */
    --gold: #f5b301;
    --crimson: #ce1126;

    /* Semantic */
    --success: #047857;
    --success-bg: #ecfdf5;
    --success-border: #6ee7b7;
    --warning: #b45309;
    --warning-bg: #fffbeb;
    --warning-border: #fcd34d;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    --info: #0369a1;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;

    /* Neutrals */
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --bg: #eef2f7;
    --bg-subtle: #f8fafc;
    --card-bg: #ffffff;

    /* Radius */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    /* Shadow */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.14), 0 6px 12px rgba(15, 23, 42, 0.05);

    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --focus-ring: 0 0 0 4px rgba(11, 77, 163, 0.18);
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background:
        radial-gradient(1200px 400px at 50% -120px, rgba(11, 77, 163, 0.10), transparent 70%),
        var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 28px 16px 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-top: 6px;
}

main {
    flex: 1;
}

footer {
    text-align: center;
    padding: 28px 0 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== Brand bar ===== */
.brand-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 22px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.brand-bar.center {
    justify-content: center;
    text-align: center;
}

.brand-emblem {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(150deg, var(--primary-500), var(--primary-hover));
    box-shadow: 0 6px 14px rgba(11, 77, 163, 0.35);
    display: grid;
    place-items: center;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.brand-emblem::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 55%);
}

.brand-emblem svg {
    width: 26px;
    height: 26px;
    position: relative;
    z-index: 1;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-name {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.brand-name b {
    color: var(--primary);
}

.brand-tagline {
    font-size: 0.74rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-weight: 600;
}

/* ===== Step indicator ===== */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 auto 22px;
    max-width: 420px;
    padding: 0 4px;
}

.step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.step:last-child {
    flex: 0 0 auto;
}

.step:not(:last-child)::after {
    content: "";
    flex: 1;
    height: 2px;
    background: var(--border-strong);
    border-radius: 2px;
    min-width: 14px;
}

.step.done:not(:last-child)::after,
.step.active:not(:last-child)::after {
    background: var(--primary);
}

.step-circle {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-pill);
    background: var(--card-bg);
    border: 2px solid var(--border-strong);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    flex: 0 0 auto;
    transition: all var(--transition);
}

.step.active .step-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(11, 77, 163, 0.18);
}

.step.done .step-circle {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.step-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.step.active .step-label {
    color: var(--text);
}

.step.done .step-label {
    color: var(--text-secondary);
}

/* ===== Cards ===== */
.upload-card,
.success-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px 24px;
}

/* ===== Helper card ===== */
.helper-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--primary-soft);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.helper-card .helper-icon {
    flex: 0 0 auto;
    color: var(--primary);
    margin-top: 1px;
}

.helper-card b {
    color: var(--text);
    display: block;
    margin-bottom: 2px;
    font-size: 0.88rem;
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
    background: var(--bg-subtle);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area:active {
    transform: scale(0.99);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 14px;
    display: inline-flex;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-pill);
    background: var(--primary-light);
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.upload-area:hover .upload-icon,
.upload-area.dragover .upload-icon {
    background: #fff;
    transform: translateY(-2px);
}

.upload-text {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text);
}

.upload-hint {
    font-size: 0.86rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.upload-formats {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}

/* ===== Preview ===== */
.preview-area {
    margin-top: 4px;
    text-align: center;
}

.preview-area img {
    max-width: 100%;
    max-height: 320px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    object-fit: contain;
    background: var(--bg-subtle);
}

.preview-area .btn {
    margin-top: 14px;
}

/* ===== Progress ===== */
.progress-area {
    margin-top: 4px;
    text-align: center;
    padding: 8px 0;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--accent));
    border-radius: var(--radius-pill);
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.progress-text {
    margin-top: 12px;
    font-size: 0.86rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.progress-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Spinner used inside buttons (white on primary) */
.btn .progress-spinner {
    width: 16px;
    height: 16px;
    border-color: rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    flex: 0 0 auto;
}

/* ===== Error ===== */
.error-area {
    margin-top: 4px;
    text-align: center;
    padding: 8px 0;
}

.error-text {
    color: var(--error);
    font-size: 0.9rem;
    margin-bottom: 14px;
    font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    width: 100%;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.2;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

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

.btn-primary {
    background: linear-gradient(180deg, var(--primary-500), var(--primary));
    color: #fff;
    box-shadow: 0 4px 12px rgba(11, 77, 163, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--primary), var(--primary-hover));
    box-shadow: 0 6px 16px rgba(11, 77, 163, 0.32);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-subtle);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ===== Form ===== */
.form-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px 20px 8px;
    margin-bottom: 16px;
}

.form-section h2 {
    font-size: 1.02rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section h2::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 18px;
    background: linear-gradient(180deg, var(--gold), var(--primary));
    border-radius: 2px;
}

.form-section h2 + p,
.form-section .section-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 16px 14px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.required {
    color: var(--error);
    margin-left: 2px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 0.94rem;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    font-family: inherit;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:hover,
.form-group select:hover {
    border-color: var(--primary-500);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-group select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

.form-group input.error,
.form-group select.error {
    border-color: var(--error);
    background: var(--error-bg);
}

.form-group input.error:focus,
.form-group select.error:focus {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16);
}

.field-error {
    display: block;
    font-size: 0.78rem;
    color: var(--error);
    margin-top: 5px;
    min-height: 0;
    font-weight: 500;
}

/* ===== Form Actions ===== */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* ===== Notice ===== */
.notice {
    padding: 13px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.86rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border: 1px solid;
}

.notice p {
    margin: 0;
}

.notice-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning-border);
}

.notice-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
}

.notice-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: var(--info-border);
}

.notice-icon {
    flex: 0 0 auto;
    margin-top: 1px;
}

/* ===== Success Card ===== */
.success-card {
    text-align: center;
    padding: 44px 24px;
    animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
    0% { opacity: 0; transform: scale(0.94) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.success-icon {
    color: var(--success);
    margin-bottom: 16px;
    width: 72px;
    height: 72px;
    margin-inline: auto;
    border-radius: var(--radius-pill);
    background: var(--success-bg);
    border: 2px solid var(--success-border);
    display: grid;
    place-items: center;
}

.success-card h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: var(--text);
}

.success-card p {
    color: var(--text-secondary);
    margin-bottom: 26px;
    font-size: 0.92rem;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: calc(100% - 32px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 13px 16px;
    font-size: 0.88rem;
    color: var(--text);
    animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.toast-out {
    animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
    0% { opacity: 0; transform: translateY(16px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(12px); }
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }
.toast-info { border-left-color: var(--info); }
.toast-warning { border-left-color: var(--warning); }

.toast-icon {
    flex: 0 0 auto;
    margin-top: 1px;
}
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-info .toast-icon { color: var(--info); }
.toast-warning .toast-icon { color: var(--warning); }

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

.toast-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0 0 4px;
}

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

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .container {
        padding: 20px 12px 16px;
    }

    .upload-area {
        padding: 36px 16px;
    }

    .form-section {
        padding: 18px 16px 4px;
    }

    .upload-card,
    .success-card {
        padding: 22px 18px;
    }

    .success-card {
        padding: 34px 18px;
    }

    .step-label {
        display: none;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
