/**
 * PANMR Suite -- Portail Contribuable -- CSS Base Partage
 *
 * Design system premium pour le portail public.
 * Ce fichier contient uniquement les styles partages :
 *   - Tokens (variables CSS)
 *   - Reset minimal
 *   - Typographie
 *   - Header / Footer
 *   - Carte (portal-card)
 *   - Formulaire (inputs, labels, boutons)
 *   - Alertes
 *   - Liens
 *   - Spinner / loading
 *   - Skip link (a11y)
 *   - Utilitaires responsive
 *
 * Les styles specifiques par page sont dans :
 *   panmr_portal_login.css
 *   panmr_portal_register.css
 *   etc.
 *
 * @package    PANMR Suite
 * @subpackage Assets/CSS
 * @author     Ir. Roland MANTAMA -- https://rolandmantama.ch
 * @version    1.7.0
 * @since      1.7.0
 */

/* ======================================================================
   1. DESIGN TOKENS
   ====================================================================== */

:root {
    /* -- Palette primaire (bleu institutionnel) ------------------------ */
    --portal-primary-900: #0c2340;
    --portal-primary-800: #12305a;
    --portal-primary-700: #1a4175;
    --portal-primary-600: #22538f;
    --portal-primary-500: #2b6cb0;
    --portal-primary-400: #4a90d9;
    --portal-primary-300: #7fb3ea;
    --portal-primary-200: #b3d4f5;
    --portal-primary-100: #dbeafe;
    --portal-primary-50:  #eff6ff;

    /* -- Accent (ambre / or -- autorite + confiance) ------------------- */
    --portal-accent-700: #92400e;
    --portal-accent-600: #b45309;
    --portal-accent-500: #d97706;
    --portal-accent-400: #f59e0b;
    --portal-accent-300: #fbbf24;
    --portal-accent-200: #fde68a;
    --portal-accent-100: #fef3c7;
    --portal-accent-50:  #fffbeb;

    /* -- Semantique ---------------------------------------------------- */
    --portal-success-600: #16a34a;
    --portal-success-100: #dcfce7;
    --portal-success-text: #15803d;

    --portal-danger-600: #dc2626;
    --portal-danger-100: #fee2e2;
    --portal-danger-text: #b91c1c;

    --portal-warning-600: #ca8a04;
    --portal-warning-100: #fef9c3;
    --portal-warning-text: #a16207;

    --portal-info-600: #2563eb;
    --portal-info-100: #dbeafe;
    --portal-info-text: #1d4ed8;

    /* -- Neutres ------------------------------------------------------- */
    --portal-gray-900: #111827;
    --portal-gray-800: #1f2937;
    --portal-gray-700: #374151;
    --portal-gray-600: #4b5563;
    --portal-gray-500: #6b7280;
    --portal-gray-400: #9ca3af;
    --portal-gray-300: #d1d5db;
    --portal-gray-200: #e5e7eb;
    --portal-gray-100: #f3f4f6;
    --portal-gray-50:  #f9fafb;

    /* -- Aliases fonctionnels ------------------------------------------ */
    --portal-text: var(--portal-gray-800);
    --portal-text-muted: var(--portal-gray-500);
    --portal-text-light: var(--portal-gray-400);
    --portal-bg: #f0f4f8;
    --portal-card-bg: #ffffff;
    --portal-border: var(--portal-gray-200);
    --portal-border-focus: var(--portal-primary-400);
    --portal-link: var(--portal-primary-600);
    --portal-link-hover: var(--portal-primary-800);

    /* -- Ombres -------------------------------------------------------- */
    --portal-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --portal-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07),
                        0 1px 3px rgba(0, 0, 0, 0.04);
    --portal-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08),
                        0 2px 8px rgba(0, 0, 0, 0.04);
    --portal-shadow-card: 0 8px 32px rgba(12, 35, 64, 0.06),
                          0 2px 8px rgba(12, 35, 64, 0.03);

    /* -- Rayons -------------------------------------------------------- */
    --portal-radius-sm: 6px;
    --portal-radius-md: 10px;
    --portal-radius-lg: 16px;
    --portal-radius-full: 9999px;

    /* -- Typographie --------------------------------------------------- */
    --portal-font-display: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --portal-font-body: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
    --portal-font-mono: 'DM Mono', 'Consolas', monospace;

    /* -- Transitions --------------------------------------------------- */
    --portal-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --portal-duration: 200ms;

    /* -- Dimensions layout --------------------------------------------- */
    --portal-header-h: 60px;
    --portal-card-max-w: 440px;
    --portal-card-padding: 36px;
}

/* ======================================================================
   2. RESET MINIMAL
   ====================================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--portal-font-body);
    color: var(--portal-text);
    background: var(--portal-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }

a {
    color: var(--portal-link);
    text-decoration: none;
    transition: color var(--portal-duration) var(--portal-ease);
}

a:hover  { color: var(--portal-link-hover); }
a:focus-visible {
    outline: 2px solid var(--portal-primary-400);
    outline-offset: 2px;
    border-radius: 2px;
}

button { cursor: pointer; font-family: inherit; }

/* ======================================================================
   3. BACKGROUND PATTERN
   ====================================================================== */

body.portal-page {
    background:
        linear-gradient(135deg, #e8eef6 0%, #f0f4f8 40%, #f5f0e8 100%);
    background-attachment: fixed;
}

body.portal-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.025;
    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%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230c2340'%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");
    pointer-events: none;
}

/* ======================================================================
   4. SKIP LINK (a11y)
   ====================================================================== */

.portal-skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: 10000;
    padding: 8px 16px;
    background: var(--portal-primary-900);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--portal-radius-sm);
}

.portal-skip-link:focus {
    top: 8px;
    color: #fff;
    outline: 2px solid var(--portal-accent-400);
    outline-offset: 2px;
}

/* ======================================================================
   5. HEADER
   ====================================================================== */

.portal-header {
    background: linear-gradient(135deg, var(--portal-primary-900) 0%, var(--portal-primary-800) 100%);
    color: #fff;
    height: var(--portal-header-h);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(12, 35, 64, 0.25);
}

.portal-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.portal-header__brand:hover { color: #fff; opacity: 0.9; }

.portal-header__logo {
    height: 34px;
    width: auto;
    flex-shrink: 0;
}

.portal-header__title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

/* -- Badge doree a gauche du titre ------------------------------------ */
.portal-header__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--portal-radius-sm);
    background: linear-gradient(135deg, var(--portal-accent-400) 0%, var(--portal-accent-500) 100%);
    flex-shrink: 0;
}

.portal-header__badge-icon {
    width: 18px;
    height: 18px;
    fill: var(--portal-primary-900);
}

/* -- Navigation header ------------------------------------------------ */
.portal-header__nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.portal-header__link {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--portal-radius-full);
    transition: all var(--portal-duration) var(--portal-ease);
    white-space: nowrap;
}

.portal-header__link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.portal-header__link:focus-visible {
    color: #fff;
    outline: 2px solid var(--portal-accent-400);
    outline-offset: 2px;
}

.portal-header__link--logout {
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.portal-header__link--logout:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

/* ======================================================================
   6. MAIN CONTENT
   ====================================================================== */

.portal-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 60px;
    min-height: calc(100vh - var(--portal-header-h) - 60px);
}

.portal-main--top {
    align-items: flex-start;
    padding-top: 40px;
}

/* ======================================================================
   7. CARD
   ====================================================================== */

.portal-card {
    background: var(--portal-card-bg);
    border-radius: var(--portal-radius-lg);
    box-shadow: var(--portal-shadow-card);
    padding: var(--portal-card-padding);
    width: 100%;
    max-width: var(--portal-card-max-w);
    position: relative;
    overflow: hidden;
    animation: portalCardIn 0.4s var(--portal-ease) both;
}

/* -- Ligne decorative superieure (accent dore) ------------------------ */
.portal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        var(--portal-primary-600) 0%,
        var(--portal-accent-400) 50%,
        var(--portal-primary-600) 100%);
}

.portal-card__title {
    font-family: var(--portal-font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--portal-primary-900);
    text-align: center;
    margin-bottom: 6px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.portal-card__subtitle {
    font-size: 14px;
    color: var(--portal-text-muted);
    text-align: center;
    margin-bottom: 28px;
    line-height: 1.5;
}

/* ======================================================================
   8. FORMULAIRE -- Composants
   ====================================================================== */

.portal-form__group {
    margin-bottom: 20px;
}

.portal-form__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-gray-700);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.portal-form__input {
    display: block;
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font-family: var(--portal-font-body);
    font-size: 15px;
    color: var(--portal-text);
    background: var(--portal-gray-50);
    border: 1.5px solid var(--portal-gray-300);
    border-radius: var(--portal-radius-md);
    transition: all var(--portal-duration) var(--portal-ease);
    -webkit-appearance: none;
    appearance: none;
}

.portal-form__input::placeholder {
    color: var(--portal-text-light);
}

.portal-form__input:hover {
    border-color: var(--portal-gray-400);
}

.portal-form__input:focus {
    outline: none;
    border-color: var(--portal-primary-500);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.12);
    background: #fff;
}

.portal-form__input:focus:invalid {
    border-color: var(--portal-danger-600);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.portal-form__hint {
    display: block;
    font-size: 12px;
    color: var(--portal-text-muted);
    margin-top: 5px;
    line-height: 1.4;
}

/* -- Wrapper password avec toggle ------------------------------------- */
.portal-form__password-wrapper {
    position: relative;
}

.portal-form__password-wrapper .portal-form__input {
    padding-right: 48px;
}

.portal-form__toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--portal-radius-sm);
    color: var(--portal-gray-500);
    transition: all var(--portal-duration) var(--portal-ease);
}

.portal-form__toggle-password:hover {
    color: var(--portal-gray-700);
    background: var(--portal-gray-100);
}

.portal-form__toggle-password:focus-visible {
    outline: 2px solid var(--portal-primary-400);
    outline-offset: -2px;
}

.portal-form__eye-icon {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* -- Checkbox --------------------------------------------------------- */
.portal-form__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

.portal-form__checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--portal-primary-600);
    flex-shrink: 0;
    cursor: pointer;
}

.portal-form__checkbox label {
    font-size: 13px;
    color: var(--portal-gray-600);
    line-height: 1.5;
    cursor: pointer;
}

/* ======================================================================
   9. BOUTONS
   ====================================================================== */

.portal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    padding: 0 24px;
    font-family: var(--portal-font-body);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: none;
    border-radius: var(--portal-radius-md);
    transition: all var(--portal-duration) var(--portal-ease);
    position: relative;
    overflow: hidden;
}

.portal-btn--primary {
    background: linear-gradient(135deg,
        var(--portal-primary-700) 0%,
        var(--portal-primary-600) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(12, 35, 64, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.portal-btn--primary:hover {
    background: linear-gradient(135deg,
        var(--portal-primary-800) 0%,
        var(--portal-primary-700) 100%);
    box-shadow: 0 4px 14px rgba(12, 35, 64, 0.28);
    transform: translateY(-1px);
}

.portal-btn--primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(12, 35, 64, 0.2);
}

.portal-btn--primary:focus-visible {
    outline: 2px solid var(--portal-accent-400);
    outline-offset: 2px;
}

.portal-btn:disabled,
.portal-btn[disabled] {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.portal-btn__text {
    display: inline-flex;
    align-items: center;
}

/* ======================================================================
   10. SPINNER (soumission formulaire)
   ====================================================================== */

.portal-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: portalSpin 0.6s linear infinite;
}

@keyframes portalSpin {
    to { transform: rotate(360deg); }
}

/* ======================================================================
   11. ALERTES
   ====================================================================== */

.portal-alert {
    padding: 12px 16px;
    border-radius: var(--portal-radius-md);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
    border: 1px solid transparent;
    animation: portalAlertIn 0.3s var(--portal-ease) both;
}

.portal-alert--success {
    background: var(--portal-success-100);
    color: var(--portal-success-text);
    border-color: rgba(22, 163, 74, 0.15);
}

.portal-alert--error {
    background: var(--portal-danger-100);
    color: var(--portal-danger-text);
    border-color: rgba(220, 38, 38, 0.15);
}

.portal-alert--warning {
    background: var(--portal-warning-100);
    color: var(--portal-warning-text);
    border-color: rgba(202, 138, 4, 0.15);
}

.portal-alert--info {
    background: var(--portal-info-100);
    color: var(--portal-info-text);
    border-color: rgba(37, 99, 235, 0.15);
}

/* ======================================================================
   12. LIENS (footer de carte)
   ====================================================================== */

.portal-links {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--portal-gray-100);
}

.portal-links a {
    font-size: 13px;
    font-weight: 600;
    color: var(--portal-primary-600);
}

.portal-links a:hover {
    color: var(--portal-primary-800);
    text-decoration: underline;
}

.portal-links__separator {
    display: inline-block;
    width: 1px;
    height: 12px;
    background: var(--portal-gray-300);
    margin: 0 12px;
    vertical-align: middle;
}

/* ======================================================================
   13. FOOTER
   ====================================================================== */

.portal-footer {
    text-align: center;
    padding: 20px 24px;
    font-size: 12px;
    color: var(--portal-text-muted);
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    background: rgba(255, 255, 255, 0.5);
}

/* ======================================================================
   14. PASSWORD STRENGTH BAR
   ====================================================================== */

.portal-password-strength {
    height: 4px;
    background: var(--portal-gray-200);
    border-radius: var(--portal-radius-full);
    margin-top: 8px;
    overflow: hidden;
}

.portal-password-strength__bar {
    height: 100%;
    width: 0;
    border-radius: var(--portal-radius-full);
    transition: width 0.3s var(--portal-ease),
                background 0.3s var(--portal-ease);
}

/* ======================================================================
   15. HINT VARIANTS (match / mismatch)
   ====================================================================== */

.portal-form__hint--match {
    color: var(--portal-success-text);
    font-weight: 600;
}

.portal-form__hint--mismatch {
    color: var(--portal-danger-text);
    font-weight: 600;
}

/* ======================================================================
   16. ANIMATIONS
   ====================================================================== */

@keyframes portalCardIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes portalAlertIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======================================================================
   17. RESPONSIVE
   ====================================================================== */

@media (max-width: 480px) {
    :root {
        --portal-card-padding: 24px;
        --portal-card-max-w: 100%;
    }

    .portal-header {
        padding: 0 16px;
    }

    .portal-header__title {
        font-size: 13px;
        max-width: 180px;
    }

    .portal-header__link {
        font-size: 12px;
        padding: 5px 10px;
    }

    .portal-main {
        padding: 24px 12px 40px;
    }

    .portal-card {
        border-radius: var(--portal-radius-md);
    }

    .portal-card__title {
        font-size: 20px;
    }

    .portal-btn {
        height: 46px;
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    :root {
        --portal-card-padding: 20px;
    }

    .portal-header__title {
        max-width: 140px;
        font-size: 12px;
    }

    .portal-card__title {
        font-size: 18px;
    }
}

/* ======================================================================
   18. REDUCED MOTION
   ====================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms;
        transition-duration: 0.01ms;
    }
}

/* ======================================================================
   19. PRINT
   ====================================================================== */

@media print {
    .portal-header,
    .portal-footer,
    .portal-skip-link {
        display: none;
    }

    body.portal-page {
        background: #fff;
    }

    .portal-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}