/**
 * C-ESN (City Eco-System Network) Universal Design System
 * Mobile-First, Modern, High-Performance Vanilla CSS
 */

:root {
    --primary-hue: 158;
    --primary-color: hsl(var(--primary-hue), 84%, 39%);
    --primary-hover: hsl(var(--primary-hue), 84%, 32%);
    --primary-light: hsl(var(--primary-hue), 80%, 94%);
    --primary-glow: hsla(var(--primary-hue), 84%, 39%, 0.25);

    --accent-blue: #2563eb;
    --accent-indigo: #4f46e5;
    --accent-amber: #d97706;
    --accent-rose: #e11d48;

    --surface-bg: #f8fafc;
    --surface-card: #ffffff;
    --surface-ground: #f1f5f9;
    --surface-muted: #e2e8f0;

    --text-color: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-white: #ffffff;

    --border-color: #e2e8f0;
    --border-focus: #10b981;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px var(--primary-glow);

    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --surface-bg: #090d16;
        --surface-card: #111827;
        --surface-ground: #1a2234;
        --surface-muted: #243048;

        --text-color: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;

        --border-color: #243048;
        --border-focus: #10b981;

        --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 30px rgba(0, 0, 0, 0.6);
    }
}

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

body.cesn-body {
    font-family: var(--font-main);
    background-color: var(--surface-bg);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.cesn-container {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.cesn-header {
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background-color: hsla(0, 0%, 100%, 0.85);
}
@media (prefers-color-scheme: dark) {
    .cesn-header {
        background-color: hsla(222, 47%, 11%, 0.85);
    }
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.cesn-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.logo-badge {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #10b981, #047857);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    box-shadow: 0 4px 10px var(--primary-glow);
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons (Touch Targets >= 44px) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    min-height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    user-select: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-secondary {
    background: var(--surface-ground);
    color: var(--text-color);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--surface-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover {
    color: var(--text-color);
    background: var(--surface-ground);
}

.btn-sm {
    padding: 6px 12px;
    min-height: 36px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    min-height: 52px;
    font-size: 16px;
    font-weight: 700;
}

.btn-block {
    width: 100%;
}

/* Stepper Progress Bar */
.stepper-wrap {
    margin: 24px 0 28px;
}

.stepper-list {
    display: flex;
    justify-content: space-between;
    list-style: none;
    position: relative;
    padding: 0 10px;
}

.stepper-list::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 40px;
    right: 40px;
    height: 3px;
    background: var(--border-color);
    z-index: 1;
}

.stepper-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.stepper-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-card);
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.stepper-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    transition: var(--transition);
}

.stepper-item.active .stepper-circle {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 0 12px var(--primary-glow);
}

.stepper-item.active .stepper-label {
    color: var(--text-color);
    font-weight: 700;
}

.stepper-item.completed .stepper-circle {
    background: #059669;
    border-color: #059669;
    color: #ffffff;
}

.stepper-item.completed .stepper-label {
    color: #059669;
}

/* Main Form Card */
.form-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 24px 20px;
    margin-bottom: 32px;
}

@media (min-width: 640px) {
    .form-card {
        padding: 36px 32px;
    }
}

/* Agreement Type Selection Cards */
.agreement-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 16px;
}

@media (min-width: 640px) {
    .agreement-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 960px) {
    .agreement-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.agreement-card {
    background: var(--surface-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    user-select: none;
}

.agreement-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.agreement-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px var(--primary-glow);
}
@media (prefers-color-scheme: dark) {
    .agreement-card.selected {
        background: rgba(16, 185, 129, 0.12);
    }
}

.agreement-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--surface-ground);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.agreement-card.selected .agreement-icon-wrap {
    background: var(--primary-color);
    color: #ffffff;
}

.agreement-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.3;
}

.agreement-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 16px;
    flex-grow: 1;
}

.agreement-fee-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}

.fee-amount {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary-color);
}

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

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

.form-label .required-star {
    color: var(--accent-rose);
    margin-left: 3px;
}

.form-control {
    width: 100%;
    font-family: inherit;
    font-size: 15px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-card);
    color: var(--text-color);
    transition: var(--transition);
    outline: none;
    min-height: 46px;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Party Validation Card */
.party-input-wrap {
    position: relative;
    display: flex;
    gap: 8px;
}

.party-status-indicator {
    margin-top: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    display: none;
    animation: fadeIn 0.2s ease;
}

.party-status-indicator.valid {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #059669;
}

.party-status-indicator.invalid {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

/* WebAuthn Biometric Card */
.biometric-box {
    background: var(--surface-ground);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    margin: 20px 0;
}

.biometric-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.biometric-status {
    margin-top: 16px;
    font-weight: 600;
    font-size: 14px;
}

/* Official Service Fee Banner */
.official-fee-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.fee-banner-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.fee-banner-amount {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-color);
    font-family: var(--font-mono);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
}
.badge-success { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-danger { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge-neutral { background: var(--surface-ground); color: var(--text-muted); }

/* Modals */
.cesn-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.cesn-modal-backdrop.active {
    display: flex;
}

.cesn-modal {
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    overflow: hidden;
    animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title {
    font-size: 17px;
    font-weight: 700;
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-ground);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Footer */
.cesn-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--surface-card);
}
