/* Page de connexion — MDET Diligences (charte Lovable / layout 50-50) */

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

html {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html,
body {
    height: 100%;
}

body.login-page {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    color: var(--foreground);
    background: var(--background);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Portail ── */

.login-portal {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.tricolore-bar {
    flex-shrink: 0;
    height: 4px;
    background: linear-gradient(
        to right,
        var(--carrot) 0%,
        var(--carrot) 33.33%,
        #ffffff 33.33%,
        #ffffff 66.66%,
        var(--pearl-aqua) 66.66%,
        var(--pearl-aqua) 100%
    );
}

/* Layout 50 / 50 */
.login-split {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: calc(100vh - 4px);
}

/* Panneau gauche — identité */
.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    background: linear-gradient(160deg, var(--sidebar-bg) 0%, oklch(0.94 0.04 155) 100%);
    border-right: 1px solid var(--border);
}

.login-brand-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.75rem;
    width: 100%;
    max-width: 22rem;
}

.login-brand-logo {
    width: min(100%, 17.5rem);
    height: auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.login-brand-republique {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--foreground);
}

.login-brand-ministere {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    line-height: 1.45;
}

/* Panneau droit — formulaire */
.login-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2rem 1.5rem;
    background: var(--background);
}

.login-panel-toolbar {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
}

.login-card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-md);
}

.login-panel-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.login-panel-footer p {
    margin: 0;
    font-size: 0.6875rem;
    color: var(--muted-foreground);
}

.card-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.3;
    color: var(--foreground);
}

.card-subtitle {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
}

.card-desc {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    line-height: 1.5;
}

.card-notice {
    margin: 1.5rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    line-height: 1.5;
}

/* Bascule thème */
.login-theme-btn {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.login-theme-btn:hover {
    background: var(--secondary);
}

.login-theme-icon {
    width: 1.125rem;
    height: 1.125rem;
}

.login-theme-icon--sun {
    display: none;
}

html[data-theme="dark"] .login-theme-icon--moon {
    display: none;
}

html[data-theme="dark"] .login-theme-icon--sun {
    display: block;
}

/* Alertes */

.alert {
    padding: 0.75rem 0.875rem;
    margin-bottom: 1.25rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
}

.alert-error {
    color: var(--destructive);
    background: oklch(0.97 0.04 25);
    border-color: oklch(0.9 0.06 25);
}

.alert-warning {
    color: oklch(0.45 0.1 75);
    background: oklch(0.98 0.04 85);
    border-color: oklch(0.92 0.07 85);
}

/* Formulaire */

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
}

.form-input {
    width: 100%;
    padding: 0.6875rem 0.875rem;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--foreground);
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

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

.form-input:hover {
    border-color: oklch(0.75 0.04 155);
    background: var(--card);
}

.form-input:focus {
    outline: none;
    border-color: var(--ring);
    background: var(--card);
    box-shadow: 0 0 0 3px oklch(0.72 0.12 55 / 0.18);
}

.field-error {
    font-size: 0.75rem;
    color: var(--destructive);
}

/* Bouton */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.25;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color 0.15s ease, filter 0.15s ease;
}

.btn-primary {
    color: var(--accent-foreground);
    background: var(--accent);
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-primary:active {
    filter: brightness(0.96);
}

.btn-block {
    width: 100%;
    margin-top: 0.25rem;
    padding-top: 0.8125rem;
    padding-bottom: 0.8125rem;
}

.logout-cancel {
    margin: 1.25rem 0 0;
    text-align: center;
    font-size: 0.8125rem;
}

.logout-cancel a {
    color: oklch(0.45 0.12 155);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.logout-cancel a:hover {
    color: var(--accent);
}

/* ── Mode sombre ── */

html[data-theme="dark"] .tricolore-bar {
    background: linear-gradient(
        to right,
        var(--carrot) 0%,
        var(--carrot) 33.33%,
        var(--secondary) 33.33%,
        var(--secondary) 66.66%,
        var(--pearl-aqua) 66.66%,
        var(--pearl-aqua) 100%
    );
}

html[data-theme="dark"] .login-brand {
    background: linear-gradient(160deg, var(--sidebar-bg) 0%, oklch(0.22 0.03 155) 100%);
}

html[data-theme="dark"] .alert-error {
    color: oklch(0.82 0.12 25);
    background: oklch(0.3 0.05 25);
    border-color: oklch(0.38 0.07 25);
}

html[data-theme="dark"] .alert-warning {
    color: oklch(0.82 0.1 85);
    background: oklch(0.32 0.05 85);
    border-color: oklch(0.4 0.07 85);
}

html[data-theme="dark"] .form-input:focus {
    box-shadow: 0 0 0 3px oklch(0.55 0.12 55 / 0.25);
}

html[data-theme="dark"] .logout-cancel a {
    color: oklch(0.78 0.1 155);
}

/* Responsive — empilement vertical */

@media (max-width: 900px) {
    .login-split {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .login-brand {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 2rem 1.5rem;
    }

    .login-brand-inner {
        flex-direction: row;
        text-align: left;
        align-items: center;
        max-width: 32rem;
        gap: 1.25rem;
    }

    .login-brand-logo {
        width: 5.5rem;
        flex-shrink: 0;
        box-shadow: var(--shadow-sm);
    }

    .login-brand-ministere {
        margin-top: 0.25rem;
    }

    .login-panel {
        padding: 1.5rem 1rem 1.25rem;
        justify-content: flex-start;
    }

    .login-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .login-brand-inner {
        flex-direction: column;
        text-align: center;
    }

    .login-brand-logo {
        width: 7rem;
    }

    .card-header h1 {
        font-size: 1.125rem;
    }
}
