/* Styles pour le clavier virtuel Glass Moderne */
:root {
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-key-bg: rgba(255, 255, 255, 0.2);
    --glass-key-hover: rgba(255, 255, 255, 0.3);
    --glass-key-active: rgba(255, 255, 255, 0.4);
    --modern-primary: #667eea;
    --modern-secondary: #764ba2;
    --modern-accent: #f093fb;
    --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    --glass-backdrop: blur(8px);
    --form-gradient: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    --key-gradient: linear-gradient(145deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.1));
}

/* Messages de validation */
.invalid-feedback {
    color: #ff6b6b;
    font-weight: 500;
}

.form-control.is-invalid {
    border-color: #ff6b6b;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

/* Container du clavier avec effet glass moderne - centré verticalement */
.android-keyboard-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1050;
    align-items: center;
    /* Centrage vertical */
    justify-content: center;
    /* Centrage horizontal */
    touch-action: none;
    backdrop-filter: blur(10px);
}

.android-keyboard-popup {
    width: 90vw;
    /* Réduire la largeur pour un meilleur centrage */
    max-width: 600px;
    /* Largeur maximale */
    max-height: 70vh;
    /* Hauteur maximale plus généreuse */
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    /* Bordures arrondies sur tous les côtés */
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: popUpCenter 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.android-keyboard-popup.numeric {
    max-height: 45vh;
    /* Réduction de la hauteur */
    max-width: 350px;
    /* Largeur maximale réduite */
    min-width: 300px;
    /* Largeur minimale */
}

@keyframes popUpCenter {
    from {
        transform: scale(0.8);
        opacity: 0;
        backdrop-filter: blur(0px);
    }

    to {
        transform: scale(1);
        opacity: 1;
        backdrop-filter: var(--glass-backdrop);
    }
}

/* Header du clavier avec glass effect */
.android-keyboard-header {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid var(--glass-border);
    min-height: 10vh;
    backdrop-filter: blur(12px);
}

.keyboard-preview-container {
    flex-grow: 1;
    margin-right: 3rem;
}

.keyboard-preview-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    background: var(--key-gradient);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: white;
    text-align: left;
    outline: none;
    backdrop-filter: blur(8px);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.keyboard-preview-input:focus {
    border-color: var(--modern-accent);
    box-shadow: 0 0 20px rgba(240, 147, 251, 0.4);
}

.keyboard-preview-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.clear-keyboard {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid var(--glass-border);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.75rem 1rem;
    color: white;
    border-radius: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.clear-keyboard:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.03);
}

/* Contenu du clavier */
.android-keyboard-content {
    padding: 1rem;
    flex-grow: 1;
    overflow-y: auto;
}

/* Padding réduit pour le clavier numérique */
.android-keyboard-popup.numeric .android-keyboard-content {
    padding: 0.75rem;
}

/* Grille du clavier */
#android-keyboard {
    display: flex;
    flex-wrap: wrap;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#android-numeric-keyboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    /* Réduction du gap */
    margin-bottom: 1rem;
    max-width: 300px;
    /* Largeur maximale réduite */
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Touches du clavier avec effet glass */
.android-key {
    flex-grow: 1;
    min-height: 6vh;
    background: var(--key-gradient);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    user-select: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.android-key:hover {
    background: var(--glass-key-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    border-color: var(--modern-accent);
}

.android-key:active {
    background: var(--glass-key-active);
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.android-key.numeric {
    min-height: 6vh;
    /* Réduction de la hauteur */
    max-height: 60px;
    /* Hauteur maximale */
    font-size: 1.4rem;
    /* Réduction de la taille de police */
    font-weight: 700;
    background: linear-gradient(145deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    min-width: 0;
    /* Permettre aux touches d'être plus petites */
}

/* Touches spéciales */
.android-key.wide {
    grid-column: span 2;
    flex-grow: 2;
}

.android-key.extra-wide {
    grid-column: span 3;
    flex-grow: 3;
}

.android-key.space {
    grid-column: span 5;
    font-size: 0.9rem;
    flex-grow: 5;
}

.android-key-linebreak {
    flex-basis: 100%;
    height: 0;
}

/* Touches spéciales avec gradient moderne */
.android-key.backspace,
.android-key.enter,
.android-key.shift {
    background: linear-gradient(135deg, var(--modern-primary), var(--modern-secondary));
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.android-key.backspace:hover,
.android-key.enter:hover,
.android-key.shift:hover {
    background: linear-gradient(135deg, #5a6fd8, #6b4d93);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.6);
}

/* Sélecteur de layout avec style glass */
.keyboard-layout-switcher {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.layout-switch {
    min-width: 4rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid var(--glass-border);
    color: white;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.layout-switch:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.layout-switch.active {
    background: linear-gradient(45deg, var(--modern-primary), var(--modern-secondary));
    color: white;
    border-color: var(--modern-accent);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

/* Boutons d'action avec effet glass moderne */
.keyboard-action-buttons {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.keyboard-action-buttons .btn {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 16px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
}

.cancel-keyboard {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.8), rgba(211, 47, 47, 0.8));
    color: white;
}

.cancel-keyboard:hover {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(244, 67, 54, 0.4);
}

.validate-keyboard {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.8), rgba(56, 142, 60, 0.8));
    color: white;
}

.validate-keyboard:hover {
    background: linear-gradient(135deg, #4caf50, #388e3c);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(76, 175, 80, 0.4);
}

/* Styles responsifs */
@media (orientation: landscape) {
    .android-keyboard-popup {
        max-height: 60vh;
    }

    .android-key {
        min-height: 5vh;
        font-size: 0.9rem;
    }

    #android-keyboard {
        grid-template-columns: repeat(12, 1fr);
        gap: 0.4rem;
    }
}

@media (max-width: 768px) {
    .android-keyboard-header {
        padding: 0.75rem;
        min-height: 8vh;
    }

    .keyboard-preview-input {
        font-size: 1rem;
        padding: 0.6rem;
    }

    .android-key {
        min-height: 7vh;
        font-size: 0.9rem;
    }

    #android-keyboard {
        gap: 0.4rem;
    }

    /* Clavier centré adapté pour mobile */
    .android-keyboard-popup {
        width: 95vw;
        max-height: 60vh;
    }

    .android-keyboard-popup.numeric {
        max-height: 40vh;
        /* Hauteur réduite pour tablette */
        max-width: 320px;
        min-width: 280px;
    }

    .android-key.numeric {
        min-height: 5.5vh;
        /* Hauteur réduite pour tablette */
        max-height: 50px;
        font-size: 1.3rem;
    }

    #android-numeric-keyboard {
        gap: 0.4rem;
        max-width: 280px;
    }

    /* Icônes plus petites sur mobile - à gauche */
    .input-icon {
        width: 2.25rem;
        height: 2.25rem;
        left: 0.5rem;
        /* Position à gauche */
        padding: 0.4rem;
    }

    .form-control {
        padding-left: 2.75rem;
        /* Padding gauche pour l'icône */
        padding-right: 1rem;
    }
}

@media (max-width: 576px) {
    .android-keyboard-content {
        padding: 0.75rem;
    }

    .android-key {
        min-height: 6vh;
        font-size: 0.85rem;
    }

    #android-keyboard {
        gap: 0.3rem;
    }

    #android-numeric-keyboard {
        gap: 0.4rem;
        /* Gap réduit pour mobile */
        max-width: 250px;
        /* Largeur plus petite sur mobile */
    }

    /* Clavier centré pour très petits écrans */
    .android-keyboard-popup {
        width: 98vw;
        max-height: 55vh;
    }

    .android-keyboard-popup.numeric {
        max-height: 35vh;
        /* Hauteur réduite pour mobile */
        max-width: 280px;
        min-width: 250px;
    }

    /* Icônes encore plus petites sur très petit écran - à gauche */
    .input-icon {
        width: 2rem;
        height: 2rem;
        left: 0.5rem;
        /* Position à gauche */
        padding: 0.3rem;
    }

    .keyboard-icon {
        font-size: 0.9rem;
    }

    .form-control {
        padding-left: 2.5rem;
        /* Padding gauche pour l'icône */
        padding-right: 1rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 320px) {
    .android-key {
        min-height: 5vh;
        font-size: 0.8rem;
    }

    .android-key.numeric {
        min-height: 5vh;
        /* Plus petit sur très petits écrans */
        max-height: 45px;
        font-size: 1.1rem;
        /* Taille de police réduite */
    }

    #android-numeric-keyboard {
        gap: 0.3rem;
        /* Gap très petit */
        max-width: 220px;
    }

    .android-keyboard-popup.numeric {
        max-height: 30vh;
        max-width: 250px;
        min-width: 220px;
    }
}

/* Effet de ripple pour les touches avec glassmorphism */
.android-key::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(240, 147, 251, 0.4) 100%);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.android-key:active::before {
    width: 100px;
    height: 100px;
    opacity: 1;
}

/* Animation d'apparition du formulaire */
.form-container {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Effet de particules flottantes */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(240, 147, 251, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}