/* ============================================================
   CFCAL-Banque — Charte graphique contemporaine
   Rouge : #CE1717 | Blanc : #FFFFFF | Surface : #F8F9FB
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --c-red:         #CE1717;
    --c-red-dark:    #a81212;
    --c-red-light:   #fef2f2;
    --c-red-subtle:  rgba(206, 23, 23, 0.08);
    --c-white:       #ffffff;
    --c-surface:     #F8F9FB;
    --c-border:      #E4E7EC;
    --c-text:        #111827;
    --c-text-muted:  #6B7280;
    --c-success:     #16a34a;
    --c-warning:     #d97706;
    --radius:        10px;
    --radius-sm:     6px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:     0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
    --transition:    0.18s ease;
}

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: var(--c-surface);
    color: var(--c-text);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--c-red); text-decoration: none; }
a:hover { color: var(--c-red-dark); text-decoration: underline; }

/* ── Layout principal ────────────────────────────────────── */
.cfcal-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.cfcal-content {
    flex: 1;
    padding: 2.5rem 0 4rem;
}

/* ── Header ──────────────────────────────────────────────── */
.cfcal-header {
    background: var(--c-white);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.cfcal-header-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cfcal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none !important;
}

.cfcal-brand-name {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--c-text);
    letter-spacing: -0.02em;
}

.cfcal-brand-sub {
    font-size: 0.65rem;
    color: var(--c-text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1;
}

/* ── Footer ──────────────────────────────────────────────── */
.cfcal-footer {
    background: var(--c-white);
    border-top: 1px solid var(--c-border);
    padding: 1.25rem 1.5rem;
}

.cfcal-footer-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: .8rem;
    color: var(--c-text-muted);
}

.cfcal-footer-badges {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cfcal-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    font-weight: 500;
    color: var(--c-text-muted);
}

.cfcal-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-border);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
    font-size: .9rem;
}

.card-body { padding: 1.5rem 1.25rem; }
.card-footer {
    padding: .875rem 1.25rem;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
}

/* ── Formulaires ─────────────────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: .8rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--c-text-muted);
    margin-bottom: .375rem;
}

.form-control, .form-select {
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: .6rem .875rem;
    font-size: .9rem;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-white);
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--c-red);
    box-shadow: 0 0 0 3px rgba(206, 23, 23, 0.12);
}

.form-text {
    font-size: .78rem;
    color: var(--c-text-muted);
    margin-top: .3rem;
}

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

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
    padding: .6rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), box-shadow var(--transition),
                transform var(--transition);
    text-decoration: none !important;
}

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

.btn-primary {
    background: var(--c-red);
    border-color: var(--c-red);
    color: var(--c-white);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--c-red-dark);
    border-color: var(--c-red-dark);
    color: var(--c-white);
    box-shadow: 0 4px 12px rgba(206,23,23,.3);
}
.btn-primary:disabled {
    background: var(--c-red);
    border-color: var(--c-red);
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

.btn-outline-primary {
    background: transparent;
    border-color: var(--c-red);
    color: var(--c-red);
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--c-red);
    color: var(--c-white);
}

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

.btn-sm {
    padding: .4rem .9rem;
    font-size: .8rem;
}

.btn-lg {
    padding: .8rem 1.75rem;
    font-size: .95rem;
    border-radius: var(--radius);
}

.w-100 { width: 100%; }

/* ── Toggle type de contenu ──────────────────────────────── */
.type-toggle {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.type-toggle-option {
    flex: 1;
    position: relative;
}

.type-toggle-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
}

.type-toggle-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem .875rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--c-text-muted);
    background: var(--c-white);
    border: none;
    transition: background var(--transition), color var(--transition);
    user-select: none;
}

.type-toggle-option + .type-toggle-option label {
    border-left: 1.5px solid var(--c-border);
}

.type-toggle-option input:checked + label {
    background: var(--c-red-subtle);
    color: var(--c-red);
}

/* ── Séparateur de section ───────────────────────────────── */
.section-divider {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 1.5rem 0;
}

/* ── Alertes ─────────────────────────────────────────────── */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    border: 1px solid transparent;
}

.alert-danger {
    background: var(--c-red-light);
    border-color: #fecaca;
    color: #7f1d1d;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #78350f;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 999px;
}

.badge-red   { background: var(--c-red-light); color: var(--c-red); }
.badge-gray  { background: var(--c-surface); color: var(--c-text-muted); border: 1px solid var(--c-border); }
.badge-green { background: #f0fdf4; color: var(--c-success); }

/* ── Input group ─────────────────────────────────────────── */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    flex: 1;
}

.input-group .btn {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}

/* ── Monospace ───────────────────────────────────────────── */
.font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: .875rem;
    background: var(--c-surface);
    letter-spacing: 0.02em;
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner-border {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .65s linear infinite;
}

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

/* ── Utilitaires layout ──────────────────────────────────── */
.container-narrow {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.stack { display: flex; flex-direction: column; }
.stack-sm { gap: .75rem; }
.stack-md { gap: 1.25rem; }
.stack-lg { gap: 2rem; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.text-muted { color: var(--c-text-muted) !important; }
.text-danger { color: var(--c-red) !important; }
.small { font-size: .8rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Validation Blazor ───────────────────────────────────── */
.valid.modified:not([type=checkbox]) { border-color: var(--c-success); }
.invalid { border-color: var(--c-red) !important; }
.validation-message { font-size: .78rem; color: var(--c-red); margin-top: .25rem; }

/* ── Erreur Blazor ───────────────────────────────────────── */
#blazor-error-ui {
    background: var(--c-red);
    color: white;
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: .75rem 1.25rem;
    font-size: .875rem;
    z-index: 9999;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12);
}

#blazor-error-ui .reload { color: white; font-weight: 700; margin-left: .5rem; }
#blazor-error-ui .dismiss { position: absolute; right: 1rem; top: .75rem; cursor: pointer; color: white; }

/* ── Pre (contenu brut) ──────────────────────────────────── */
pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: .85rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: var(--c-text);
}

/* ── Lien d'accès copié ──────────────────────────────────── */
.copy-success {
    color: var(--c-success);
    font-size: .8rem;
    font-weight: 600;
}

/* ── Page title ──────────────────────────────────────────── */
.page-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--c-text);
    margin: 0 0 .25rem;
}

.page-subtitle {
    font-size: .875rem;
    color: var(--c-text-muted);
    margin: 0 0 2rem;
}

/* ── État vide / erreur page ─────────────────────────────── */
.state-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
}

.state-icon-error { background: var(--c-red-light); }
.state-icon-success { background: #f0fdf4; }
.state-icon-lock { background: #fffbeb; }

/* ── Panneau d'aide ──────────────────────────────────────── */
.help-panel {
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--c-white);
}

.help-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .875rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    color: var(--c-text-muted);
    text-align: left;
    transition: background var(--transition), color var(--transition);
}

.help-toggle:hover { background: var(--c-surface); color: var(--c-text); }

.help-toggle span { flex: 1; }

.help-chevron { transition: transform .2s ease; }
.help-chevron.open { transform: rotate(180deg); }

.help-body {
    border-top: 1px solid var(--c-border);
    padding: 1.25rem;
    background: var(--c-surface);
}

.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.help-item {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}

.help-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: .1rem;
}

.help-item strong {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    color: var(--c-text);
    margin-bottom: .2rem;
}

.help-item p {
    font-size: .78rem;
    color: var(--c-text-muted);
    margin: 0;
    line-height: 1.5;
}

@media (max-width: 500px) {
    .help-grid { grid-template-columns: 1fr; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
    .cfcal-footer-badges { display: none; }
    .container-narrow { padding: 0 1rem; }
    .cfcal-content { padding: 1.5rem 0 3rem; }
}
