/**
 * CECP Keycloak Theme
 * Date: 2025-11-07
 * Author: LocatelliT
 */

/* ============================================
   Variables CSS
   ============================================ */
:root {
    /* Couleurs principales CECP */
    --cecp-primary: #007081;
    --cecp-primary-dark: #005a68;
    --cecp-primary-light: #008a9d;
    --cecp-secondary: #e0ecf0;
    --cecp-accent: rgb(245, 158, 11);
    
    /* Couleurs système */
    --cecp-success: rgb(34, 197, 94);
    --cecp-warning: rgb(251, 146, 60);
    --cecp-danger: rgb(239, 68, 68);
    --cecp-info: #007081;
    
    /* Couleurs de fond et texte - Mode clair */
    --cecp-bg-primary: rgb(248, 250, 252);
    --cecp-bg-secondary: #e0ecf0;
    --cecp-card-bg: rgb(255, 255, 255);
    --cecp-text-primary: rgb(15, 23, 42);
    --cecp-text-secondary: rgb(71, 85, 105);
    --cecp-text-muted: rgb(148, 163, 184);
    
    /* Bordures */
    --cecp-border-light: rgb(226, 232, 240);
    --cecp-border-medium: rgb(203, 213, 225);
    --cecp-border-dark: rgb(148, 163, 184);
    
    /* Gradient de fond */
    --cecp-gradient-start: #e0ecf0;
    --cecp-gradient-end: #b8d4db;
    
    /* Typographie */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;
    
    /* Espacements */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-5: 1.25rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-10: 2.5rem;
    --spacing-12: 3rem;
    
    /* Dimensions */
    --input-height: 44px;
    --button-height: 44px;
    --header-height: 80px;
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-theme="dark"] {
    --cecp-bg-primary: rgb(15, 23, 42);
    --cecp-bg-secondary: rgb(30, 41, 59);
    --cecp-card-bg: rgb(30, 41, 59);
    --cecp-text-primary: rgb(248, 250, 252);
    --cecp-text-secondary: rgb(203, 213, 225);
    --cecp-text-muted: rgb(148, 163, 184);
    --cecp-border-light: rgb(51, 65, 85);
    --cecp-border-medium: rgb(71, 85, 105);
    --cecp-gradient-start: rgb(30, 41, 59);
    --cecp-gradient-end: rgb(15, 23, 42);
}

/* ============================================
   Reset & Base
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--cecp-text-primary);
    background: linear-gradient(135deg, var(--cecp-gradient-start) 0%, var(--cecp-gradient-end) 100%);
    min-height: 100vh;
    transition: background var(--transition-base);
}

/* ============================================
   Container & Layout
   ============================================ */
.cecp-auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.cecp-auth-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================
   Header
   ============================================ */
.cecp-auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-4);
}

.cecp-logo-wrapper {
    display: flex;
    align-items: center;
}

.cecp-logo {
    height: 56px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.cecp-theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 112, 129, 0.15);
    border: none;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #007081;
}

.cecp-theme-toggle:hover {
    background: rgba(0, 112, 129, 0.25);
    transform: scale(1.05);
}

.cecp-theme-toggle svg {
    width: 20px;
    height: 20px;
}

.hidden {
    display: none !important;
}

/* ============================================
   Card Container Unifié
   ============================================ */
@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.cecp-auth-wrapper {
    display: flex;
    width: 100%;
    max-width: 1000px;
    background: var(--cecp-card-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transition: background var(--transition-base), box-shadow var(--transition-base);
}

/* ============================================
   Image décorative à gauche (55%)
   ============================================ */
.cecp-auth-image {
    display: none;
    width: 55%;
    min-height: 600px;
    position: relative;
    overflow: hidden;
}

.cecp-auth-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.cecp-auth-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(0, 112, 129, 0) 0%, 
        rgba(0, 112, 129, 0.15) 100%);
    pointer-events: none;
}

/* ============================================
   Card Formulaire (45%)
   ============================================ */
.cecp-auth-card {
    flex: 1;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ============================================
   Info Banner
   ============================================ */
.cecp-info-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-3);
    padding: var(--spacing-4);
    background-color: rgba(0, 112, 129, 0.1);
    border: 1px solid rgba(0, 112, 129, 0.2);
    border-radius: 8px;
    color: var(--cecp-primary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

[data-theme="dark"] .cecp-info-banner {
    background-color: rgba(0, 112, 129, 0.2);
    border-color: rgba(0, 112, 129, 0.3);
}

.cecp-info-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.cecp-info-banner-desktop {
    width: 100%;
    max-width: 1000px;
    margin-bottom: var(--spacing-6);
}

.cecp-info-banner-mobile {
    display: none;
    margin-bottom: var(--spacing-6);
}

/* ============================================
   Title & Subtitle
   ============================================ */
.cecp-auth-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--cecp-text-primary);
    line-height: 1.25;
    letter-spacing: -0.025em;
    text-align: center;
    margin-bottom: var(--spacing-2);
}

.cecp-auth-subtitle {
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--cecp-text-secondary);
    line-height: 1.5;
    text-align: center;
    margin-bottom: var(--spacing-8);
}

/* ============================================
   Alerts
   ============================================ */
@keyframes slideDown {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.cecp-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: var(--spacing-6);
    font-size: 0.9375rem;
    line-height: 1.5;
    animation: slideDown 0.3s ease-out;
}

.cecp-alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.cecp-alert-success {
    background: rgb(240, 253, 244);
    color: rgb(21, 128, 61);
    border: 1px solid rgb(134, 239, 172);
}

.cecp-alert-error {
    background: rgb(254, 242, 242);
    color: rgb(153, 27, 27);
    border: 1px solid rgb(252, 165, 165);
}

.cecp-alert-warning {
    background: rgb(254, 252, 232);
    color: rgb(146, 64, 14);
    border: 1px solid rgb(253, 224, 71);
}

.cecp-alert-info {
    background: #e0f2f5;
    color: #005a68;
    border: 1px solid #b8d4db;
}

/* ============================================
   Forms
   ============================================ */
.cecp-form-group {
    margin-bottom: var(--spacing-6);
}

/* Aligner le label et l'astérisque sur la même ligne */
.cecp-label-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.cecp-label-row .required {
    color: var(--cecp-danger);
    font-weight: var(--font-weight-semibold);
}

.cecp-label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--cecp-text-primary);
    margin-bottom: var(--spacing-2);
}

.cecp-input-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-2);
}

.cecp-input-icon {
    position: absolute;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--cecp-text-muted);
    pointer-events: none;
    z-index: 1;
}

.cecp-input {
    width: 100%;
    height: var(--input-height);
    padding: 12px 16px 12px 48px;
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--cecp-text-primary);
    background: var(--cecp-bg-primary);
    border: 2px solid var(--cecp-border-light);
    border-radius: 8px;
    outline: none;
    transition: all var(--transition-fast);
}

.cecp-input:focus {
    border-color: var(--cecp-primary);
    background: var(--cecp-card-bg);
    box-shadow: 0 0 0 3px rgba(0, 112, 129, 0.1);
}

.cecp-input:focus ~ .cecp-input-icon {
    color: var(--cecp-primary);
}

.cecp-input-error {
    border-color: var(--cecp-danger);
}

.cecp-input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.cecp-input-password {
    padding-right: 48px;
}

.cecp-password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--cecp-text-muted);
    transition: color var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

.cecp-password-toggle:hover {
    color: var(--cecp-text-primary);
}

.cecp-password-toggle svg {
    width: 20px;
    height: 20px;
}

.cecp-error-text {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--cecp-danger);
    margin-top: var(--spacing-2);
}

.cecp-helper-text {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--cecp-text-muted);
    margin-top: var(--spacing-1);
}

/* Masquer un éventuel icône d'aide PatternFly à côté des messages */
.cecp-input-wrapper .pf-c-form__helper-text-icon,
.cecp-input-wrapper .kc-feedback-icon,
.cecp-input-wrapper [class*="helper-text-icon"] {
    display: none;
}

/* Optionnel : masquer d'éventuels icônes d'erreur qui se superposent au champ */
.cecp-input-wrapper .pf-c-form__helper-text-icon {
    display: none;
}

/* ============================================
   Checkbox & Form Options
   ============================================ */
.cecp-form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-6);
    gap: var(--spacing-4);
    flex-wrap: wrap;
}

.cecp-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.cecp-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--cecp-border-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    accent-color: var(--cecp-primary);
}

.cecp-checkbox-label {
    font-size: 0.9375rem;
    color: var(--cecp-text-primary);
    cursor: pointer;
    user-select: none;
}

/* ============================================
   Buttons
   ============================================ */
.cecp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    min-height: var(--button-height);
    padding: 12px 24px;
    font-size: var(--font-size-base);
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    outline: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.cecp-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cecp-btn-primary {
    background: var(--cecp-primary);
    color: rgb(255, 255, 255);
}

.cecp-btn-primary:hover:not(:disabled) {
    background: var(--cecp-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 112, 129, 0.3);
}

.cecp-btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 112, 129, 0.2);
}

.cecp-btn-block {
    width: 100%;
}

.cecp-form-actions {
    margin-top: var(--spacing-8);
}

/* ============================================
   Links
   ============================================ */
.cecp-link {
    color: var(--cecp-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-base);
    font-size: 0.9375rem;
}

.cecp-link:hover {
    color: var(--cecp-primary-dark);
    text-decoration: underline;
}

/* ============================================
   Alternative Actions
   ============================================ */
.cecp-auth-alternative {
    text-align: center;
    padding-top: var(--spacing-6);
    border-top: 1px solid var(--cecp-border-light);
    margin-top: var(--spacing-6);
}

.cecp-text-muted {
    color: var(--cecp-text-muted);
    margin-right: var(--spacing-2);
}

/* ============================================
   Footer
   ============================================ */
.cecp-auth-footer {
    max-width: 1400px;
    width: 100%;
    margin: 2rem auto 0;
    padding: var(--spacing-6) var(--spacing-4);
    text-align: center;
    color: #007081;
}

.cecp-footer-copyright {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

/* ============================================
   Loading Overlay
   ============================================ */
.cecp-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-base);
}

.cecp-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.cecp-spinner {
    position: relative;
    width: 80px;
    height: 80px;
}

.cecp-spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #007081;
    border-radius: 50%;
    animation: spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.cecp-spinner-ring:nth-child(1) {
    animation-delay: -0.45s;
}

.cecp-spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
}

.cecp-spinner-ring:nth-child(3) {
    animation-delay: -0.15s;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Focus Visible (Accessibilité)
   ============================================ */
*:focus-visible {
    outline: 2px solid var(--cecp-primary);
    outline-offset: 2px;
}

/* ============================================
   Instruction & Info Messages
   ============================================ */
#kc-info-message, #kc-error-message {
    margin: var(--spacing-6) 0;
}

#kc-info-message .instruction, 
#kc-error-message .instruction {
    font-size: var(--font-size-base);
    color: var(--cecp-text-secondary);
    line-height: 1.6;
    text-align: center;
}

/* ============================================
   Social Providers
   ============================================ */
#kc-social-providers {
    margin-top: var(--spacing-8);
    padding-top: var(--spacing-6);
    border-top: 1px solid var(--cecp-border-light);
}

#kc-social-providers h4 {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--cecp-text-muted);
    font-weight: 500;
    margin-bottom: var(--spacing-4);
}

#kc-social-providers ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-3);
}

#kc-social-providers li {
    margin: 0;
}

.cecp-btn-social {
    width: 100%;
    background: var(--cecp-bg-primary);
    color: var(--cecp-text-primary);
    border: 2px solid var(--cecp-border-light);
}

.cecp-btn-social:hover {
    background: var(--cecp-card-bg);
    border-color: var(--cecp-primary);
    transform: translateY(-1px);
}

/* ============================================
   Responsive - Mobile First
   ============================================ */

/* Desktop (> 1200px) - Afficher l'image */
@media (min-width: 1200px) {
    .cecp-auth-image {
        display: block;
    }

    .cecp-auth-main {
        max-width: 1400px;
        margin: 0 auto;
        width: 100%;
        padding: 2rem;
    }
}

/* Tablet horizontal (1025px - 1199px) */
@media (min-width: 1025px) and (max-width: 1199px) {
    .cecp-auth-wrapper {
        max-width: 560px;
    }

    .cecp-auth-card {
        padding: 40px 32px;
    }
}

/* Tablet (641px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    .cecp-auth-wrapper {
        max-width: 480px;
    }

    .cecp-auth-card {
        padding: 40px 32px;
    }
}

/* Mobile (< 640px) */
@media (max-width: 640px) {
    .cecp-auth-container {
        padding: 0.5rem;
    }

    .cecp-auth-header {
        height: 64px;
        padding: 0 var(--spacing-4);
    }

    .cecp-logo {
        height: 40px;
    }

    .cecp-theme-toggle {
        width: 36px;
        height: 36px;
    }

    .cecp-auth-main {
        padding: 0.5rem 0;
    }

    .cecp-auth-wrapper {
        border-radius: 12px;
    }

    /* Info banner: masquer desktop, afficher mobile */
    .cecp-info-banner-desktop {
        display: none;
    }

    .cecp-info-banner-mobile {
        display: flex;
    }

    .cecp-auth-card {
        padding: 28px 20px;
    }

    .cecp-auth-title {
        font-size: var(--font-size-2xl);
        margin-bottom: var(--spacing-2);
    }

    .cecp-auth-subtitle {
        font-size: 0.9375rem;
        margin-bottom: var(--spacing-6);
    }

    .cecp-form-group {
        margin-bottom: var(--spacing-5);
    }

    .cecp-label {
        font-size: 0.875rem;
    }

    .cecp-input {
        font-size: 1rem;
        height: 48px;
    }

    .cecp-btn {
        min-height: 48px;
        font-size: 1rem;
    }

    .cecp-form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-3);
    }

    .cecp-checkbox-label {
        font-size: 0.875rem;
    }

    .cecp-link {
        font-size: 0.875rem;
    }

    .cecp-auth-alternative {
        padding-top: var(--spacing-5);
        margin-top: var(--spacing-5);
    }

    .cecp-text-muted {
        font-size: 0.875rem;
    }

    .cecp-auth-footer {
        margin-top: 1rem;
        padding: var(--spacing-5) var(--spacing-3);
    }

    .cecp-footer-copyright {
        font-size: 0.8125rem;
    }
}

/* Très petits smartphones (< 375px) */
@media (max-width: 374px) {
    .cecp-auth-card {
        padding: 24px 16px;
    }

    .cecp-auth-title {
        font-size: 1.375rem;
    }

    .cecp-logo {
        height: 36px;
    }
}

/* Landscape mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .cecp-auth-container {
        padding: 0.5rem;
    }

    .cecp-auth-header {
        height: 56px;
    }

    .cecp-auth-main {
        padding: 0.5rem 0;
    }

    .cecp-auth-card {
        padding: 20px 24px;
    }

    .cecp-auth-title {
        font-size: 1.5rem;
        margin-bottom: var(--spacing-1);
    }

    .cecp-auth-subtitle {
        font-size: 0.875rem;
        margin-bottom: var(--spacing-4);
    }

    .cecp-form-group {
        margin-bottom: var(--spacing-4);
    }
}
