/**
 * PANMR Suite -- Page de Connexion Admin -- CSS Premium
 *
 * Design institutionnel aligne sur le design system portail PANMR.
 * Charge exclusivement par my_login.php (override Perfex).
 *
 * Architecture :
 *   Split layout : panneau branding (gauche) + formulaire (droite)
 *   Mobile-first : empile en colonne sous 900px
 *   WCAG AA : contrastes verifies, focus visible, pas de couleur seule info
 *
 * Palette :
 *   Primaire   : bleu institutionnel (#0c2340 -> #eff6ff)
 *   Accent     : ambre/or (#d97706)
 *   Neutres    : gris (#111827 -> #f9fafb)
 *
 * Typographie :
 *   Display    : DM Sans (Google Fonts)
 *   Mono       : DM Mono (NIF, codes)
 *
 * @package    PANMR Suite
 * @subpackage Assets/CSS
 * @author     Ir. Roland MANTAMA -- https://rolandmantama.ch
 * @version    1.0.0
 * @since      1.7.1
 */

/* ======================================================================
   1. RESET & BASE
   ====================================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body.panmr-admin-login {
    height: 100%;
    font-family: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1f2937;
    background: #f0f4f8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ======================================================================
   2. LAYOUT SPLIT
   ====================================================================== */

.panmr-login-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Panneau branding (gauche) --------------------------------------- */

.panmr-login-branding {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 45%;
    min-height: 100vh;
    padding: 48px 40px;
    background: linear-gradient(160deg, #0c2340 0%, #12305a 40%, #1a4175 100%);
    overflow: hidden;
    color: #ffffff;
    text-align: center;
}

/* Motif geometrique decoratif (losanges / Kasai) */
.panmr-login-branding::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(43, 108, 176, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(217, 119, 6, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

/* Losanges SVG en arriere-plan */
.panmr-login-branding::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5 L55 30 L30 55 L5 30 Z' fill='none' stroke='%23ffffff' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 60px 60px;
    pointer-events: none;
}

.panmr-login-branding__content {
    position: relative;
    z-index: 1;
    max-width: 380px;
}

/* Logo branding (image blanche sur fond sombre) */
.panmr-login-branding__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 28px;
}

.panmr-login-branding__logo img {
    max-width: 220px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
}

.panmr-login-branding__title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
    margin-bottom: 8px;
    color: #ffffff;
}

.panmr-login-branding__subtitle {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(251, 191, 36, 0.85);
    margin-bottom: 20px;
}

.panmr-login-branding__desc {
    font-size: 14px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.6);
    max-width: 320px;
    margin: 0 auto;
}

.panmr-login-branding__separator {
    display: block;
    width: 40px;
    height: 2px;
    margin: 24px auto;
    background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.5), transparent);
    border: none;
}

.panmr-login-branding__version {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    text-transform: uppercase;
}

/* --- Panneau formulaire (droite) ------------------------------------- */

.panmr-login-form-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 48px 40px;
    background: #f0f4f8;
    position: relative;
}

/* Bande decorative haute (accent ambre) */
.panmr-login-form-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #d97706, #f59e0b, #fbbf24);
}

/* ======================================================================
   3. CARTE FORMULAIRE
   ====================================================================== */

.panmr-login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 36px 36px;
    box-shadow:
        0 8px 32px rgba(12, 35, 64, 0.06),
        0 2px 8px rgba(12, 35, 64, 0.03);
    border: 1px solid rgba(229, 231, 235, 0.6);
}

.panmr-login-card__header {
    text-align: center;
    margin-bottom: 32px;
}

.panmr-login-card__title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: -0.2px;
    margin-bottom: 6px;
}

.panmr-login-card__hint {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

/* ======================================================================
   4. ALERTES
   ====================================================================== */

.panmr-login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.panmr-login-alert--danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.panmr-login-alert--success {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.panmr-login-alert--info {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.panmr-login-alert__icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

/* ======================================================================
   5. CHAMPS FORMULAIRE
   ====================================================================== */

.panmr-login-field {
    margin-bottom: 20px;
}

.panmr-login-field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    letter-spacing: 0.1px;
}

.panmr-login-field__input {
    display: block;
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 14px;
    color: #1f2937;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    transition: border-color 200ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
                background-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.panmr-login-field__input::placeholder {
    color: #9ca3af;
}

.panmr-login-field__input:hover {
    border-color: #d1d5db;
}

.panmr-login-field__input:focus {
    border-color: #4a90d9;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

/* Champ mot de passe avec toggle visibilite */
.panmr-login-field__password-wrap {
    position: relative;
}

.panmr-login-field__password-wrap .panmr-login-field__input {
    padding-right: 46px;
}

.panmr-login-field__toggle-pw {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 6px;
    transition: color 200ms, background 200ms;
}

.panmr-login-field__toggle-pw:hover {
    color: #4b5563;
    background: rgba(0, 0, 0, 0.04);
}

.panmr-login-field__toggle-pw:focus-visible {
    outline: 2px solid #4a90d9;
    outline-offset: 2px;
}

.panmr-login-field__toggle-pw svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
    fill: none;
    stroke: currentColor;
}

/* ======================================================================
   6. LIGNE OPTIONS (remember me + forgot password)
   ====================================================================== */

.panmr-login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

.panmr-login-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.panmr-login-remember__checkbox {
    width: 16px;
    height: 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 4px;
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 200ms, background 200ms;
    position: relative;
}

.panmr-login-remember__checkbox:checked {
    background: #22538f;
    border-color: #22538f;
}

.panmr-login-remember__checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.panmr-login-remember__checkbox:focus-visible {
    outline: 2px solid #4a90d9;
    outline-offset: 2px;
}

.panmr-login-remember__text {
    font-size: 13px;
    color: #4b5563;
    user-select: none;
}

.panmr-login-forgot {
    font-size: 13px;
    font-weight: 600;
    color: #22538f;
    text-decoration: none;
    transition: color 200ms;
}

.panmr-login-forgot:hover {
    color: #0c2340;
    text-decoration: underline;
}

/* ======================================================================
   7. BOUTON CONNEXION
   ====================================================================== */

.panmr-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 48px;
    padding: 0 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #12305a 0%, #22538f 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 0.2px;
    position: relative;
    overflow: hidden;
    transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.panmr-login-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.panmr-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(18, 48, 90, 0.25);
}

.panmr-login-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(18, 48, 90, 0.2);
}

.panmr-login-btn:focus-visible {
    outline: 2px solid #4a90d9;
    outline-offset: 3px;
}

.panmr-login-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Icone fleche dans le bouton */
.panmr-login-btn__icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 200ms;
}

.panmr-login-btn:hover .panmr-login-btn__icon {
    transform: translateX(3px);
}

/* Spinner de chargement */
.panmr-login-btn__spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: panmr-spin 0.7s linear infinite;
}

.panmr-login-btn--loading .panmr-login-btn__spinner {
    display: block;
}

.panmr-login-btn--loading .panmr-login-btn__text,
.panmr-login-btn--loading .panmr-login-btn__icon {
    display: none;
}

@keyframes panmr-spin {
    to { transform: rotate(360deg); }
}

/* ======================================================================
   8. SELECTEUR DE LANGUE
   ====================================================================== */

.panmr-login-lang {
    margin-top: 20px;
    text-align: center;
}

.panmr-login-lang__select {
    display: inline-block;
    padding: 6px 32px 6px 12px;
    font-family: inherit;
    font-size: 12px;
    color: #6b7280;
    background-color: #f3f4f6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color 200ms;
}

.panmr-login-lang__select:hover {
    border-color: #d1d5db;
}

.panmr-login-lang__select:focus-visible {
    outline: 2px solid #4a90d9;
    outline-offset: 2px;
}

/* ======================================================================
   9. FOOTER
   ====================================================================== */

.panmr-login-footer {
    margin-top: 32px;
    text-align: center;
}

.panmr-login-footer__text {
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.6;
}

.panmr-login-footer__link {
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    transition: color 200ms;
}

.panmr-login-footer__link:hover {
    color: #22538f;
}

/* ======================================================================
   10. ANIMATIONS D'ENTREE
   ====================================================================== */

@keyframes panmr-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes panmr-fade-in-left {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.panmr-login-branding__content {
    animation: panmr-fade-in-left 600ms cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: 100ms;
}

.panmr-login-card {
    animation: panmr-fade-in-up 500ms cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: 200ms;
}

.panmr-login-footer {
    animation: panmr-fade-in-up 500ms cubic-bezier(0.4, 0, 0.2, 1) both;
    animation-delay: 350ms;
}

/* ======================================================================
   11. SKIP LINK (a11y)
   ====================================================================== */

.panmr-login-skip {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 1000;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    background: #0c2340;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    transition: top 200ms;
}

.panmr-login-skip:focus {
    top: 0;
}

/* ======================================================================
   12. RESPONSIVE
   ====================================================================== */

/* Tablette portrait et mobile */
@media (max-width: 900px) {
    .panmr-login-wrapper {
        flex-direction: column;
    }

    .panmr-login-branding {
        width: 100%;
        min-height: auto;
        padding: 36px 24px 32px;
    }

    .panmr-login-branding__logo {
        margin-bottom: 20px;
    }

    .panmr-login-branding__logo img {
        max-width: 180px;
        max-height: 80px;
    }

    .panmr-login-branding__title {
        font-size: 22px;
    }

    .panmr-login-branding__desc {
        display: none;
    }

    .panmr-login-branding__separator {
        margin: 16px auto;
    }

    .panmr-login-form-panel {
        padding: 32px 20px;
    }

    .panmr-login-card {
        padding: 28px 24px 24px;
        border-radius: 14px;
    }
}

/* Petit mobile */
@media (max-width: 480px) {
    .panmr-login-branding {
        padding: 28px 20px 24px;
    }

    .panmr-login-branding__title {
        font-size: 20px;
    }

    .panmr-login-branding__subtitle {
        font-size: 12px;
        letter-spacing: 1.5px;
    }

    .panmr-login-branding__version {
        display: none;
    }

    .panmr-login-card__title {
        font-size: 20px;
    }

    .panmr-login-field__input {
        height: 44px;
        font-size: 16px; /* Empeche le zoom iOS */
    }

    .panmr-login-btn {
        height: 46px;
    }

    .panmr-login-options {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Grand ecran */
@media (min-width: 1400px) {
    .panmr-login-branding {
        width: 42%;
    }

    .panmr-login-branding__title {
        font-size: 32px;
    }

    .panmr-login-card {
        max-width: 440px;
        padding: 44px 40px 40px;
    }
}

/* Preference mouvement reduit */
@media (prefers-reduced-motion: reduce) {
    .panmr-login-branding__content,
    .panmr-login-card,
    .panmr-login-footer {
        animation: none;
    }

    .panmr-login-btn:hover {
        transform: none;
    }

    .panmr-login-btn:hover .panmr-login-btn__icon {
        transform: none;
    }
}

/* Mode sombre (respecte preference OS) */
@media (prefers-color-scheme: dark) {
    body.panmr-admin-login {
        background: #111827;
    }

    .panmr-login-form-panel {
        background: #111827;
    }

    .panmr-login-card {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    }

    .panmr-login-card__title {
        color: #f3f4f6;
    }

    .panmr-login-card__hint {
        color: #9ca3af;
    }

    .panmr-login-field__label {
        color: #d1d5db;
    }

    .panmr-login-field__input {
        background: #111827;
        border-color: #374151;
        color: #f3f4f6;
    }

    .panmr-login-field__input::placeholder {
        color: #6b7280;
    }

    .panmr-login-field__input:focus {
        background: #1a2332;
        border-color: #4a90d9;
    }

    .panmr-login-remember__text {
        color: #9ca3af;
    }

    .panmr-login-remember__checkbox {
        background: #111827;
        border-color: #4b5563;
    }

    .panmr-login-forgot {
        color: #7fb3ea;
    }

    .panmr-login-forgot:hover {
        color: #b3d4f5;
    }

    .panmr-login-lang__select {
        background-color: #1f2937;
        border-color: #374151;
        color: #9ca3af;
    }

    .panmr-login-footer__text {
        color: #6b7280;
    }

    .panmr-login-footer__link {
        color: #9ca3af;
    }
}