/* ============================================================
   NexiCompta — Design System
   ============================================================ */

:root {
    --primary:       #4F46E5;
    --primary-dark:  #3730A3;
    --primary-light: #818CF8;
    --accent:        #06B6D4;
    --success:       #10B981;
    --warning:       #F59E0B;
    --danger:        #EF4444;
    --bg:            #F1F5F9;
    --surface:       #FFFFFF;
    --text:          #1E293B;
    --text-muted:    #64748B;
    --border:        #E2E8F0;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:     0 20px 40px rgba(0,0,0,.12);
    --radius:        12px;
    --radius-sm:     8px;
    --transition:    .2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Login layout ─────────────────────────────────────────── */

.login-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

/* Left panel — branding */
.login-brand {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.brand-logo {
    position: relative;
    text-align: center;
    color: #fff;
    margin-bottom: 2.5rem;
}

.brand-logo svg {
    width: 72px;
    height: 72px;
    margin-bottom: 1.25rem;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.25));
}

.brand-logo h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: .25rem;
}

.brand-logo p {
    font-size: .95rem;
    opacity: .8;
    font-weight: 400;
}

.brand-features {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 320px;
}

.brand-feature {
    display: flex;
    align-items: center;
    gap: .875rem;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--radius-sm);
    padding: .875rem 1rem;
    color: #fff;
    backdrop-filter: blur(4px);
}

.brand-feature svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: .9;
}

.brand-feature span {
    font-size: .875rem;
    font-weight: 500;
}

/* Right panel — form */
.login-form-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
    background: var(--surface);
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-card__header {
    margin-bottom: 2rem;
}

.login-card__header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .375rem;
}

.login-card__header p {
    color: var(--text-muted);
    font-size: .9rem;
}

/* Form elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .4rem;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: .875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition);
}

.input-icon svg { width: 18px; height: 18px; display: block; }

.form-input {
    width: 100%;
    padding: .75rem 1rem .75rem 2.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.form-input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

/* Password toggle */
.input-toggle {
    position: absolute;
    right: .875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.input-toggle:hover { color: var(--primary); }
.input-toggle svg { width: 18px; height: 18px; }

/* Form extras */
.form-extras {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.forgot-link {
    font-size: .875rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.forgot-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* Submit button */
.btn-submit {
    width: 100%;
    padding: .875rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    box-shadow: 0 4px 14px rgba(79,70,229,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    position: relative;
    overflow: hidden;
}

.btn-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background var(--transition);
}

.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,.4); }
.btn-submit:hover::after { background: rgba(255,255,255,.06); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { opacity: .65; cursor: not-allowed; transform: none; }

.btn-submit .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.btn-submit.loading .spinner { display: block; }
.btn-submit.loading .btn-text { opacity: .7; }

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

/* Alert */
.alert {
    display: none;
    align-items: flex-start;
    gap: .625rem;
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1.25rem;
    animation: fadeIn .25s ease;
}

.alert.show { display: flex; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: .05rem; }

.alert-error   { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* Divider */
.login-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: .8125rem;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Footer */
.login-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: .8125rem;
    color: var(--text-muted);
}

/* Bouton Microsoft SSO */
.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    width: 100%;
    padding: .8rem 1rem;
    background: #fff;
    color: #1e293b;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    box-shadow: var(--shadow-sm);
}
.btn-microsoft:hover {
    border-color: #0078d4;
    box-shadow: 0 0 0 3px rgba(0,120,212,.12);
    background: #f0f9ff;
}

/* Responsive */
@media (max-width: 768px) {
    .login-wrapper { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-form-panel { padding: 2rem 1.25rem; }
}

/* ── Double authentification (TOTP) ──────────────────────── */

.totp-card {
    max-width: 440px;
}

.totp-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(79,70,229,.08);
    color: var(--color-primary);
    font-size: .8rem;
    font-weight: 600;
    padding: .3rem .75rem;
    border-radius: 99px;
    margin-bottom: .75rem;
    border: 1px solid rgba(79,70,229,.2);
}
.totp-badge--verify {
    background: rgba(5,150,105,.08);
    color: #059669;
    border-color: rgba(5,150,105,.2);
}

.totp-steps {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin: 1.25rem 0;
}
.totp-step {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
}
.totp-step-num {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.totp-step-body {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    font-size: .875rem;
    line-height: 1.45;
}
.totp-step-body strong { color: var(--color-text); }
.totp-step-body span   { color: var(--color-text-muted); }

.totp-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 1.25rem 0;
}
.totp-qr-wrap img {
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    padding: .5rem;
    background: #fff;
}
.totp-qr-fallback {
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    color: var(--color-text-muted);
    padding: 2rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
}

.totp-manual {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    font-size: .8rem;
    color: var(--color-text-muted);
}
.totp-secret-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
}
.totp-secret-wrap code {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: .85rem;
    letter-spacing: .1em;
    color: var(--color-text);
    word-break: break-all;
}
.totp-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: .2rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    transition: color var(--transition);
    flex-shrink: 0;
}
.totp-copy-btn:hover { color: var(--color-primary); }

.totp-code-wrap {
    display: flex;
    justify-content: center;
}
.totp-code-input {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: .35em;
    max-width: 220px;
    padding: .75rem 1rem;
}

.totp-timer-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin: 1rem 0;
    position: relative;
}
.totp-timer-ring { flex-shrink: 0; }
.totp-timer-sec {
    position: absolute;
    font-size: .85rem;
    font-weight: 700;
    color: var(--color-text);
}
