:root {
    --bg-deep: #0a1941;
    --bg-mid: #102a6b;
    --cyan: #00e5ff;
    --cyan-soft: #4da6ff;
    --text: #e8f4ff;
    --text-muted: rgba(232, 244, 255, 0.75);
    --glass: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(77, 166, 255, 0.25);
    --danger: #ff6b6b;
    --success: #69f0ae;
    --radius: 14px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background: linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-mid) 55%, #0d1f4a 100%);
    background-attachment: fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("../img/affiche-ia.png");
    background-size: cover;
    background-position: center top;
    opacity: 0.22;
    z-index: 0;
    pointer-events: none;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 20% 10%, rgba(0, 229, 255, 0.12), transparent 50%),
        radial-gradient(ellipse 60% 40% at 85% 90%, rgba(77, 166, 255, 0.1), transparent 45%);
    z-index: 0;
    pointer-events: none;
}

.page-wrap {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.brand h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 0 24px rgba(0, 229, 255, 0.35);
}

.brand p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.card {
    background: var(--glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.75rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 229, 255, 0.06) inset;
}

.card h2 {
    margin: 0 0 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--cyan);
}

.field {
    margin-bottom: 1.1rem;
}

.field label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.field input,
.field .select2-container {
    width: 100% !important;
}

.field input {
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(10, 25, 65, 0.5);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input::placeholder {
    color: rgba(232, 244, 255, 0.35);
}

.field input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.2);
}

.btn-submit {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.85rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: #0a1941;
    background: linear-gradient(135deg, var(--cyan), var(--cyan-soft));
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(0, 229, 255, 0.45);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.alert {
    display: none;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.45;
}

.alert.is-visible {
    display: block;
}

.alert--error {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.45);
    color: #ffb4b4;
}

.alert--success {
    background: rgba(105, 240, 174, 0.12);
    border: 1px solid rgba(105, 240, 174, 0.4);
    color: #b9f6ca;
}

.footer-note {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-note a {
    color: var(--cyan-soft);
}

/* Select2 thème sombre */
.select2-container--default .select2-selection--single {
    height: 46px;
    padding: 0.4rem 0.5rem;
    border-radius: 10px !important;
    border: 1px solid var(--glass-border) !important;
    background: rgba(10, 25, 65, 0.65) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
    line-height: 2rem !important;
    padding-left: 0.25rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
}

.select2-dropdown {
    border: 1px solid var(--glass-border) !important;
    background: rgba(16, 42, 107, 0.98) !important;
    border-radius: 10px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: rgba(10, 25, 65, 0.8) !important;
    border-color: var(--glass-border) !important;
    color: var(--text) !important;
    border-radius: 8px !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--cyan-soft) !important;
    color: #0a1941 !important;
}

.select2-container--default .select2-results__option[aria-disabled="true"] {
    opacity: 0.45;
}

/* Popup « salle pleine » (au-dessus de Select2) */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.modal.is-open {
    display: flex;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 8, 28, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
}

.modal__box {
    position: relative;
    z-index: 1;
    max-width: 440px;
    width: 100%;
    margin: 0;
    animation: modalIn 0.22s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal__title {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
    color: var(--cyan);
}

.modal__text {
    margin: 0 0 1.25rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.modal__ok {
    width: auto;
    min-width: 140px;
    margin-top: 0;
}

.modal__title--success {
    color: var(--success) !important;
    text-shadow: 0 0 20px rgba(105, 240, 174, 0.35);
}

.modal__ok--primary {
    width: 100%;
    max-width: 100%;
}

.modal--invite .invitation-modal-box {
    max-width: 920px;
    width: min(96vw, 920px);
    max-height: min(92vh, 92dvh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.modal--invite .invitation-modal-box > .modal__title,
.modal--invite .invitation-modal-box > .modal-ok-lede,
.modal--invite .invitation-modal-box > .modal-ok-hint {
    flex-shrink: 0;
}

.modal-ok-lede {
    margin-bottom: 0.5rem !important;
}

.modal-ok-hint {
    margin: 0 0 0.85rem;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.modal-ok-hint kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
    font-family: inherit;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    border: 1px solid var(--glass-border);
}

.invite-frame-wrap {
    flex: 1 1 0;
    min-height: 0;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    background: #050d24;
    margin-bottom: 0.85rem;
    display: flex;
    flex-direction: column;
}

.invitation-preview-scale {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box;
}

.invitation-preview-root {
    width: 100%;
    max-width: 560px;
    box-sizing: border-box;
}

.invitation-preview-root img {
    max-width: 100%;
    height: auto;
}

.invite-actions {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    flex-shrink: 0;
}

.invite-actions .btn-submit {
    width: 100%;
    margin-top: 0;
}

.invite-actions .btn-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.modal-invite-footnote {
    margin: 0.85rem 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: rgba(232, 244, 255, 0.55);
    text-align: center;
}

.btn-outline {
    background: transparent !important;
    color: var(--cyan) !important;
    border: 1px solid var(--cyan-soft) !important;
    box-shadow: none !important;
}

.btn-outline:hover:not(:disabled) {
    background: rgba(0, 229, 255, 0.12) !important;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.2) !important;
}

/* Bureau / tablette : modale entière visible sans défilement ; invitation réduite (scale) */
@media (min-width: 641px) {
    .modal--invite {
        align-items: center;
        justify-content: center;
        padding: 0.5rem 0.75rem;
    }

    .modal--invite .invitation-modal-box {
        max-height: calc(100dvh - 1rem);
        max-height: calc(100vh - 1rem);
        width: min(900px, calc(100vw - 1.5rem));
    }

    .modal--invite .invite-frame-wrap {
        flex: 1 1 0;
        min-height: 140px;
        max-height: calc(100dvh - 13.5rem);
        max-height: calc(100vh - 13.5rem);
        overflow: hidden;
    }

    .modal--invite .invitation-preview-scale {
        overflow: hidden;
        align-items: center;
        justify-content: center;
        padding: 0.35rem;
    }

    .modal--invite .invitation-preview-root {
        transform: scale(0.68);
        transform-origin: center center;
        overflow: visible;
        min-height: 0;
        max-height: none;
    }

    @media (min-height: 700px) {
        .modal--invite .invitation-preview-root {
            transform: scale(0.76);
        }
    }

    @media (min-height: 900px) {
        .modal--invite .invitation-preview-root {
            transform: scale(0.85);
        }

        .modal--invite .invite-frame-wrap {
            max-height: calc(100dvh - 12rem);
            max-height: calc(100vh - 12rem);
        }
    }
}

/* Mobile : défilement dans la zone d’aperçu et modale utilisable au doigt */
@media (max-width: 640px) {
    .modal--invite {
        align-items: flex-end;
        justify-content: center;
        padding: 0;
    }

    .modal--invite .invitation-modal-box {
        width: 100%;
        max-width: none;
        max-height: 96dvh;
        max-height: 96vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal--invite .invite-frame-wrap {
        flex: 0 1 auto;
        min-height: 200px;
        max-height: none;
        overflow: visible;
    }

    .modal--invite .invitation-preview-scale {
        overflow: visible;
        align-items: flex-start;
        min-height: 220px;
        max-height: 48vh;
        max-height: 48dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal--invite .invitation-preview-root {
        transform: none;
        overflow-y: visible;
        min-height: 200px;
    }

    .modal--invite .modal-ok-hint {
        font-size: 0.8rem;
    }
}

/* Bloc partage réseaux sociaux */
.share-block {
    margin-top: 1.5rem;
}

.share-block h2 {
    margin-top: 0;
}

.share-block__lede {
    margin: 0 0 0.65rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--cyan);
    line-height: 1.4;
}

.share-block__text {
    margin: 0 0 1rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.share-preview {
    margin: 0 0 1rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.share-preview img {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: middle;
}

.share-block__hint {
    margin: 0 0 1rem;
    font-size: 0.78rem;
    line-height: 1.45;
    color: rgba(232, 244, 255, 0.55);
}

.share-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.share-links__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    transition: transform 0.12s, box-shadow 0.12s;
    color: #fff;
}

.share-links__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.share-links__btn--fb {
    background: #1877f2;
}

.share-links__btn--tw {
    background: #000;
    border-color: #333;
}

.share-links__btn--in {
    background: #0a66c2;
}

.share-links__btn--wa {
    background: #25d366;
    color: #fff;
}

.share-links__btn--tg {
    background: #229ed9;
}
