:root {
    --bg-color: #000000;
    --text-white: #ffffff;
    --text-gray: #a0a0a0;
    --icon-purple: #8178fc; /* Violet spécifique de l'app */
    --fab-purple: #9691ff; 
    --card-border-gray: #3a3a3c; /* Gris foncé iOS */
    --card-box-bg: #1c1c1e; /* Gris background secondaire iOS */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    /* Utilisation prioritaire de la police système Apple (San Francisco) */
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color); 
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    /* Empêche le rebond sur iOS pour simuler une app native */
    overscroll-behavior-y: none; 
}

.app-container {
    width: 100%;
    /* 100vw et 100vh pour prendre tout l'écran sur mobile */
    width: 100vw;
    height: 100vh;
    /* On utilise la hauteur réelle de l'écran (gère la barre de navigation sur iOS Safari) */
    height: 100dvh; 
    background-color: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text-white);
}

/* Si on est sur un très grand écran (ordinateur), on simule la taille d'un iPhone Pro Max */
@media (min-width: 450px) {
    .app-container {
        width: 430px;
        height: 932px;
        border-radius: 45px;
        box-shadow: 0 0 0 10px #222, 0 0 40px rgba(0,0,0,0.8);
    }
}

/* --- Barre supérieure (Icônes) --- */
.top-bar {
    display: flex;
    justify-content: flex-end;
    padding: 11px 24px 16px 24px; /* padding-top réduit de 5px */
    /* Gestion de l'encoche (Dynamic Island / Notch) */
    padding-top: max(15px, env(safe-area-inset-top)); 
}

.header-icons {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header-icons a {
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-purple {
    color: var(--icon-purple);
    font-size: 24px;
}

.icon-wrapper {
    position: relative;
}

/* Point rouge de notification */
.notification-dot {
    position: absolute;
    top: -1px;
    right: 0px;
    width: 11px;
    height: 11px;
    background-color: #ff3b30; /* Rouge iOS */
    border-radius: 50%;
    /* Contour noir pour faire une encoche dans l'icône de la cloche */
    border: 2px solid var(--bg-color); 
}

/* Badge avec bouclier sur le profil */
.status-shield {
    position: absolute;
    bottom: -2px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Contenu principal --- */
.content {
    flex: 1;
    padding: 0 20px;
    overflow-y: auto;
    /* Laisse de la place pour le bouton flottant et la zone de sécurité basse */
    padding-bottom: max(140px, calc(env(safe-area-inset-bottom) + 120px)); 
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.content::-webkit-scrollbar {
    display: none;
}

.section {
    margin-bottom: 40px;
}

.section h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0px;
}

/* --- Carte Identité Numérique (Image) --- */
.id-card-image {
    width: 100%;
    aspect-ratio: 1.58 / 1;
    border-radius: 12px;
    background-color: transparent;
    background-size: cover; /* Permet de couper automatiquement les bandes noires si l'image n'a pas le format parfait */
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    /* Léger contour interne/externe pour finir l'intégration */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Ajouter une carte --- */
.add-card-box {
    width: 100%;
    aspect-ratio: 1.58 / 1;
    border-radius: 12px;
    /* Pointillés */
    border: 2px dashed rgba(255, 255, 255, 0.4);
    background-color: #1a1a1c;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
}

.add-card-box p {
    color: #8e8e93; /* Gris clair iOS */
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.add-btn-square {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background-color: transparent;
    color: #ffffff;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}



/* --- Bouton d'action flottant (QR Code) --- */
.floating-action-button {
    position: absolute;
    /* Gère la barre du bas de l'iPhone */
    bottom: max(35px, env(safe-area-inset-bottom)); 
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none; 
}

.qr-btn {
    pointer-events: auto; 
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #8b88fd; /* Correspondance exacte pixel par pixel */
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-bottom: 5px; 
}

/* --- QR Scanner Modal --- */
.qr-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.qr-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.qr-modal-content {
    background-color: #1c1c1e;
    width: 100%;
    height: 96%;
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 36px 20px max(30px, env(safe-area-inset-bottom)) 20px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    position: relative;
}

.qr-modal-overlay.active .qr-modal-content {
    transform: translateY(0);
}

.modal-drag-handle {
    width: 40px;
    height: 5px;
    background-color: #4a4a4c;
    border-radius: 3px;
    margin-bottom: 24px;
}

.qr-modal-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
    letter-spacing: -0.5px;
    align-self: flex-start;
}

.qr-modal-content p {
    font-size: 14px;
    color: #8e8e93;
    margin-bottom: 40px;
    text-align: left;
    align-self: flex-start;
}

.camera-simulation {
    width: calc(100% + 40px);
    margin-left: -20px;
    margin-right: -20px;
    flex: 1;
    background-color: #000;
    position: relative;
    overflow: hidden;
    /* On laisse l'espace naturel du padding de la modale en bas en retirant le margin négatif */
    border-radius: 6px 6px 0 0; /* Coins arrondis très légèrement en haut */
}

.camera-mask {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%;
    aspect-ratio: 1 / 1.15;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.65);
    pointer-events: none;
    border-radius: 12px; /* Coins arrondis pour le carré transparent */
}

#cameraVideo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.top-close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: #8b88fd; /* Même violet que le fond du QR code */
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px; /* Zone de clic plus confortable */
}
