body, html {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    font-family: 'EB Garamond', serif;
    color: #fffbe7;
}

#background-glow, #particles-container, #mystic-veil {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    pointer-events: none;
    z-index: 0;
}

#background-glow {
    background: radial-gradient(ellipse at center, rgba(70,130,180,0.1) 0%, rgba(70,130,180,0) 70%);
    animation: pulseGlow 10s infinite alternate;
    z-index: 0;
}
@keyframes pulseGlow {
    from { transform: scale(1); opacity: 0.2; }
    to { transform: scale(1.1); opacity: 0.4; }
}

#mystic-veil {
    background: radial-gradient(ellipse at 60% 40%, rgba(110,226,245,0.13) 0%, rgba(40,60,110,0.22) 60%, rgba(10,10,30,0.55) 100%);
    mix-blend-mode: lighten;
    opacity: 0.85;
    z-index: 1;
}

header.bg-dark {
    background: linear-gradient(90deg, rgba(10,20,45,0.98) 0%, rgba(30,60,110,0.92) 100%);
    border-bottom: 2px solid #7fd8ff;
    box-shadow: 0 2px 18px 0 rgba(127,216,255,0.10), 0 0 24px #7fd8ff33;
}

h1, h2, h4 {
    color: #b2eaff;
    text-shadow: 0 0 8px #7fd8ff, 0 0 5px #0a223a;
    text-align: center;
}

main.container {
    position: relative;
    z-index: 10;
    background: rgba(10, 20, 45, 0.88);
    border-radius: 15px;
    border: 1px solid rgba(127, 216, 255, 0.3);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(127, 216, 255, 0.2) inset;
    margin-top: 40px;
    margin-bottom: 40px;
    padding: 30px 20px;
}

/* Ajout : main prend toute la hauteur de la page */
.full-height-container {
    min-height: calc(100vh - 120px); /* Ajustez selon la hauteur du header/footer */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.card.bg-dark {
    background: rgba(20, 35, 60, 0.85) !important;
    border: 1px solid rgba(127, 216, 255, 0.18);
    border-radius: 12px;
    box-shadow: 0 0 18px rgba(127,216,255,0.08);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.card.bg-dark:hover {
    box-shadow: 0 0 32px #7fd8ff44, 0 0 12px #b2eaff33;
    border-color: #7fd8ff;
}

.card-title {
    color: #b2eaff;
    text-shadow: 0 0 6px #7fd8ff44;
}

.character-avatar {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 10px 10px 0 0;
    border-bottom: 2px solid #7fd8ff44;
    box-shadow: 0 2px 10px #7fd8ff22;
    background: #0a223a;
}

.btn-danger, .btn-warning, .btn-success {
    font-family: 'EB Garamond', serif;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    box-shadow: 0 0 10px #7fd8ff22;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn-danger {
    background: linear-gradient(90deg, #7fd8ff 0%, #b2eaff 100%);
    color: #0a223a;
}
.btn-danger:hover {
    background: #b2eaff;
    color: #0a223a;
    box-shadow: 0 0 18px #7fd8ff88;
}
.btn-warning {
    background: linear-gradient(90deg, #ffe082 0%, #ffb300 100%);
    color: #0a223a;
}
.btn-warning:hover {
    background: #ffe082;
    color: #0a223a;
}
.btn-success {
    background: linear-gradient(90deg, #7fffd4 0%, #7fd8ff 100%);
    color: #0a223a;
}
.btn-success:hover {
    background: #7fd8ff;
    color: #0a223a;
}

.form-control, .form-control-file, .form-control:focus {
    background: rgba(20, 35, 60, 0.9);
    color: #fffbe7;
    border: 1px solid #7fd8ff88;
    border-radius: 6px;
    box-shadow: 0 0 6px #7fd8ff22;
}
.form-control:focus {
    border-color: #b2eaff;
    box-shadow: 0 0 12px #b2eaff44;
}

label {
    color: #b2eaff;
    font-weight: 500;
}

.bg-dark.text-light.p-3.rounded {
    background: rgba(10, 20, 45, 0.92) !important;
    border: 1px solid rgba(127, 216, 255, 0.18);
    border-radius: 10px;
    box-shadow: 0 0 10px #7fd8ff22;
}

.alert-info {
    background: rgba(127, 216, 255, 0.18);
    color: #0a223a;
    border: 1px solid #7fd8ff;
    border-radius: 8px;
    text-align: center;
    font-family: 'EB Garamond', serif;
    font-size: 1.1em;
    margin-bottom: 20px;
}

footer.bg-dark {
    background: linear-gradient(90deg, rgba(10,20,45,0.98) 0%, rgba(30,60,110,0.92) 100%);
    border-top: 2px solid #7fd8ff;
    color: #b2eaff;
    text-shadow: 0 0 8px #7fd8ff44;
    margin-top: 40px;
}

/* Style pour la barre de recherche des personnages */
#character-search {
    background: rgba(20, 35, 60, 0.92);
    color: #b2eaff;
    border: 1.5px solid #7fd8ff;
    border-radius: 8px;
    box-shadow: 0 0 10px #7fd8ff22;
    width: 350px;
    max-width: 90%;
    margin: 0 auto 24px auto;
    display: block;
    font-size: 1.1em;
    padding: 10px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#character-search:focus {
    border-color: #b2eaff;
    box-shadow: 0 0 18px #7fd8ff44;
    outline: none;
}

/* Style unifié pour tous les inputs et textarea (même ton que la barre de recherche) */
.search-bar-custom,
.search-bar-custom:focus,
.form-control.search-bar-custom,
.form-control-file.search-bar-custom,
textarea.search-bar-custom,
select.search-bar-custom {
    background: rgba(20, 35, 60, 0.92) !important;
    color: #b2eaff !important;
    border: 1.5px solid #7fd8ff !important;
    border-radius: 8px !important;
    box-shadow: 0 0 10px #7fd8ff22;
    font-size: 1.1em;
    padding: 10px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar-custom:focus {
    border-color: #b2eaff !important;
    box-shadow: 0 0 18px #7fd8ff44 !important;
    outline: none !important;
}

/* Pour éviter que la barre de recherche prenne toute la largeur dans le flex */
#character-search.search-bar-custom {
    width: 350px;
    max-width: 90%;
    margin: 0;
    display: block;
}

/* Ajout pour CKEditor 5 et tous les textarea/inputs de type texte */
textarea,
input[type="text"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
    background: rgba(20, 35, 60, 0.92) !important;
    color: #b2eaff !important;
    border: 1.5px solid #7fd8ff !important;
    border-radius: 8px !important;
    box-shadow: 0 0 10px #7fd8ff22;
    font-size: 1.1em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus,
input[type="text"]:focus,
input[type="date"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
select:focus {
    border-color: #b2eaff !important;
    box-shadow: 0 0 18px #7fd8ff44 !important;
    outline: none !important;
}

/* CKEditor 5 background */
.ck-editor__editable_inline {
    background: rgba(20, 35, 60, 0.92) !important;
    color: #b2eaff !important;
    border-radius: 8px !important;
    border: 1.5px solid #7fd8ff !important;
    min-height: 120px;
    font-size: 1.1em;
}
.ck.ck-editor__main > .ck-editor__editable:not(.ck-focused) {
    border-color: #7fd8ff !important;
}
.ck.ck-editor__main > .ck-editor__editable.ck-focused {
    border-color: #b2eaff !important;
    box-shadow: 0 0 18px #7fd8ff44 !important;
}

@media (max-width: 768px) {
    main.container {
        margin-top: 20px;
        margin-bottom: 20px;
        padding: 15px 5px;
    }
    .character-avatar {
        height: 160px;
    }
    .card.bg-dark {
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    main.container {
        margin-top: 10px;
        margin-bottom: 10px;
        padding: 8px 2px;
    }
    .character-avatar {
        height: 110px;
    }
    .card.bg-dark {
        margin-bottom: 10px;
    }
    h1, h2, h4 {
        font-size: 1.2em;
    }
}

/* --- Création personnage : style formulaire type "fiche" --- */
.create-character-grid {
    display: grid;
    grid-template-columns: 180px 1fr 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 18px 24px;
    align-items: center;
    margin-bottom: 1.5em;
}
@media (max-width: 900px) {
    .create-character-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto auto auto;
    }
}
@media (max-width: 600px) {
    .create-character-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        gap: 12px 0;
    }
}

.create-character-photo-label {
    grid-row: 1 / span 3;
    grid-column: 1 / 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-weight: bold;
    color: #b2eaff;
    font-size: 1.13em;
    /* Ajout pour aligner verticalement avec les champs à droite */
    justify-content: flex-start;
    margin-top: -18px;
}

.create-character-photo-input {
    width: 160px;
    height: 160px;
    border-radius: 18px;
    border: 2px solid #7fd8ff;
    background: #0a223a;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 0;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.create-character-photo-input input[type="file"] {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0; top: 0;
    cursor: pointer;
    z-index: 2;
}

.create-character-photo-input label,
.create-character-photo-input .choose-file-label {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: none;
    color: #b2eaff;
    font-size: 1em;
    z-index: 1;
    pointer-events: none;
}

.create-character-photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 18px;
    display: none;
    z-index: 0;
    background: #0a223a;
}

.create-character-field {
    width: 100%;
    margin-bottom: 0;
}
.create-character-label {
    color: #b2eaff;
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 1.08em;
}
.create-character-input {
    width: 100%;
    background: rgba(20, 35, 60, 0.92);
    color: #b2eaff;
    border: 1.5px solid #7fd8ff;
    border-radius: 8px;
    box-shadow: 0 0 10px #7fd8ff22;
    font-size: 1.1em;
    padding: 10px 18px;
    margin-bottom: 0.5em;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.create-character-input:focus {
    border-color: #b2eaff;
    box-shadow: 0 0 18px #7fd8ff44;
    outline: none;
}

.create-character-select {
    width: 100%;
    background: rgba(20, 35, 60, 0.92);
    color: #b2eaff;
    border: 1.5px solid #7fd8ff;
    border-radius: 8px;
    box-shadow: 0 0 10px #7fd8ff22;
    font-size: 1.1em;
    padding: 10px 18px;
    margin-bottom: 0.5em;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.create-character-select:focus {
    border-color: #b2eaff;
    box-shadow: 0 0 18px #7fd8ff44;
    outline: none;
}

.create-character-description-label {
    color: #b2eaff;
    font-weight: bold;
    font-size: 1.13em;
    margin-top: 1em;
    margin-bottom: 0.2em;
    display: block;
}
.create-character-description-area {
    width: 100%;
    min-height: 120px;
    background: rgba(20, 35, 60, 0.92);
    color: #b2eaff;
    border: 1.5px solid #7fd8ff;
    border-radius: 8px;
    box-shadow: 0 0 10px #7fd8ff22;
    font-size: 1.1em;
    padding: 10px 18px;
    margin-bottom: 0.5em;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.create-character-description-area:focus {
    border-color: #b2eaff;
    box-shadow: 0 0 18px #7fd8ff44;
    outline: none;
}

/* Ajustement du bouton créer_perso */
#show-create-form {
    width: 220px !important;
    max-width: 100%;
    margin-bottom: 0 !important;
    margin-left: auto !important;
    display: block;
}

/* Pour la ligne recherche + bouton */
.d-flex.align-items-center.mb-4 {
    gap: 18px;
}

/* Responsive : sur mobile, le bouton passe en dessous */
@media (max-width: 600px) {
    .d-flex.align-items-center.mb-4 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }
    #show-create-form {
        width: 100% !important;
        margin-left: 0 !important;
    }
}
