/**
 * Styles CSS pour le système de réinitialisation de mot de passe DELPAA
 * Design responsive avec contraintes spécifiées
 */

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: #efefef;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Container principal */
.container {
    background-color: white;
    max-width: 500px;
    width: 100%;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Logo */
.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo img {
    max-width: 300px;
    height: auto;
    max-height: 128px;
}

/* Titres */
h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 600;
}

h2 {
    color: #555;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 500;
}

/* Formulaires */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Boutons */
.btn {
    display: inline-block;
    background-color: #007bff;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.btn:hover {
    background-color: #0056b3;
}

.btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #545b62;
}

/* Messages */
.message {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message-error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

.message-success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.message-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
}

.message-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
}

/* Indicateur de force du mot de passe */
.password-strength {
    margin-top: 10px;
}

.strength-bar {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.strength-fill {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 4px;
}

.strength-text {
    font-size: 14px;
    font-weight: 500;
}

/* CAPTCHA */
.captcha-container {
    margin: 20px 0;
    text-align: center;
}

/* Indications de mot de passe */
.password-requirements {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.password-requirements ul {
    margin-left: 20px;
}

.password-requirements li {
    margin-bottom: 5px;
}

/* Toggle visibilité mot de passe */
.password-toggle {
    position: relative;
}

.password-toggle input {
    padding-right: 50px;
}

.toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    color: #333;
}

/* Liens */
a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px;
        margin: 0;
    }
    
    .logo img {
        max-width: 250px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"] {
        font-size: 16px; /* Évite le zoom sur iOS */
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .logo img {
        max-width: 200px;
    }
    
    h1 {
        font-size: 18px;
    }
    
    .btn {
        padding: 14px 20px;
        font-size: 16px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: fadeIn 0.5s ease-out;
}

/* États de validation */
.form-group.error input {
    border-color: #dc3545;
}

.form-group.success input {
    border-color: #28a745;
}

.form-group .error-message {
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
}

.form-group .success-message {
    color: #28a745;
    font-size: 14px;
    margin-top: 5px;
}

/* Loading state */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Dark mode support */

/* 1. Based on user's system preference */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode-forced) {
        background-color: #1a1a1a;
        color: #e9ecef;
    }
    
    .container {
        background-color: #2d2d2d;
        color: #e9ecef;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"] {
        background-color: #3d3d3d;
        border-color: #555;
        color: #e9ecef;
    }
    
    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="password"]:focus {
        border-color: #007bff;
    }
    
    .password-requirements {
        background-color: #3d3d3d;
        color: #adb5bd;
    }
    
    .strength-bar {
        background-color: #555;
    }
}

/* 2. Based on manual toggle (.dark-mode class on body) */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e9ecef;
}

body.dark-mode .container {
    background-color: #2d2d2d;
    color: #e9ecef;
}

body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"] {
    background-color: #3d3d3d;
    border-color: #555;
    color: #e9ecef;
}

body.dark-mode input[type="text"]:focus,
body.dark-mode input[type="email"]:focus,
body.dark-mode input[type="password"]:focus {
    border-color: #007bff;
}

body.dark-mode .password-requirements {
    background-color: #3d3d3d;
    color: #adb5bd;
}

body.dark-mode .strength-bar {
    background-color: #555;
}

/* Bouton Dark Mode */
.dark-mode-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #ccc;
    color: #333;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 999; /* Pour s'assurer qu'il est au-dessus des autres éléments */
    box-shadow: 0 2px 5px rgba(0,0,0,0.15); /* Ombre pour la visibilité */
}

.dark-mode-toggle:hover {
    background-color: #f0f0f0;
    border-color: #bbb;
}

body.dark-mode .dark-mode-toggle {
    background: #3d3d3d;
    border-color: #555;
    color: #e9ecef;
}

body.dark-mode .dark-mode-toggle:hover {
    background-color: #555;
}


/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible pour navigation clavier */
.btn:focus-visible,
input:focus-visible,
.toggle-btn:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Overlay de chargement */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

#loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#loading-overlay p {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

/* Ajout pour positionner l'overlay */
.container {
    position: relative;
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .btn {
        background: white;
        color: black;
        border: 1px solid #ccc;
    }
}
