/* ─────────────────────────────────────────────────────────────
   Studio-Plus – Global Styles (iOS Theme Enhanced)
   ───────────────────────────────────────────────────────────── */

:root {
    /* Palette iOS 15+ System Colors */
    --bg-color: #F2F2F7;       /* Gris fond système */
    --card-bg: #FFFFFF;        /* Blanc pur */
    --text-main: #1C1C1E;      /* Noir profond */
    --text-sub: #8E8E93;       /* Gris secondaire */
    
    --primary: #007AFF;        /* Bleu Action */
    --primary-active: #0056b3; 
    --success: #34C759;        /* Vert Validation */
    --danger: #FF3B30;         /* Rouge Alerte */
    --warning: #FFCC00;        /* Jaune Attention */
    
    --border-color: #C6C6C8;   /* Bordures subtiles */
    --input-bg: #EEF0F4;       /* Fond des inputs */
    
    /* Dimensions */
    --radius-xl: 24px;         /* Cartes Login */
    --radius-l: 18px;          /* Icônes Apps */
    --radius-m: 12px;          /* Boutons / Inputs */
    --radius-s: 8px;           /* Petits éléments */
    
    /* Ombres douces (Apple Style) */
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.06);
    --shadow-icon: 0 2px 10px rgba(0, 0, 0, 0.08), 0 0 2px rgba(0,0,0,0.05);
}

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

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    /* Pour éviter que le contenu soit caché par la barre d'upload */
    padding-bottom: 140px; 
}

/* ─────────────────────────────────────────────────────────────
   1. TYPOGRAPHIE & ELEMENTS DE BASE
   ───────────────────────────────────────────────────────────── */

h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
}

h2 {
    font-size: 22px;
    font-weight: 700;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

a:active { opacity: 0.7; }

/* ─────────────────────────────────────────────────────────────
   2. COMPOSANTS UI (Inputs, Boutons)
   ───────────────────────────────────────────────────────────── */

/* Inputs style iOS */
input[type="email"],
input[type="text"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    padding: 16px;
    margin-bottom: 15px;
    border: 1px solid transparent; /* Pas de bordure par défaut */
    background: var(--input-bg);
    border-radius: var(--radius-m);
    font-size: 17px; /* 17px évite le zoom auto sur iPhone */
    color: var(--text-main);
    transition: all 0.2s ease;
}

input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    outline: none;
}

/* Boutons Principaux */
button, .btn, .action-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-m);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: transform 0.1s, background-color 0.2s;
    gap: 8px; /* Espace icône/texte */
}

button:active, .btn:active {
    transform: scale(0.98);
    background-color: var(--primary-active);
}

button:disabled {
    background-color: var(--text-sub);
    opacity: 0.7;
    cursor: not-allowed;
}

/* Messages d'alerte */
.message, .login-message {
    font-size: 14px;
    margin-bottom: 20px;
    padding: 12px;
    border-radius: var(--radius-s);
    text-align: center;
    line-height: 1.4;
    display: none; /* Caché par défaut JS */
}
.error { background: #FFE5E5; color: var(--danger); border: 1px solid rgba(255,59,48,0.2); display: block; }
.success { background: #E5FFE5; color: var(--success); border: 1px solid rgba(52,199,89,0.2); display: block; }
.warning { background: #FFF8C5; color: #947600; border: 1px solid rgba(255,204,0,0.3); display: block; }

/* ─────────────────────────────────────────────────────────────
   3. PAGE LOGIN (Centrage & Carte)
   ───────────────────────────────────────────────────────────── */

.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--card-bg);
    padding: 40px 30px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    width: 100%;
    max-width: 360px;
    text-align: center;
    position: relative;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    border-radius: 20px;
    object-fit: cover;
    box-shadow: var(--shadow-icon);
}

.subtitle {
    color: var(--text-sub);
    font-size: 15px;
    margin-top: 5px;
    margin-bottom: 30px;
}

/* Indicateur Offline dans le Login */
.offline-indicator {
    display: none; /* JS toggle */
    background: #FFF0F0;
    color: var(--danger);
    font-weight: 600;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

/* Toggle Link */
.toggle-container {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.05);
}
.toggle-btn {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    width: auto;
    padding: 5px;
}

/* ─────────────────────────────────────────────────────────────
   4. DASHBOARD (Grille & Apps)
   ───────────────────────────────────────────────────────────── */

/* En-tête du Dashboard */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 0 20px; /* Marges adaptées */
}

/* Titres de Sections (Style iOS "Settings") */
.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-sub);
    margin: 30px 20px 10px 20px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    letter-spacing: 0.5px;
}

/* Grille des Apps */
.grid {
    display: grid;
    /* Responsive : colonnes de min 85px */
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 25px 10px;
    padding: 10px 20px;
}

/* Élément App */
.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    text-decoration: none;
    color: var(--text-main);
    cursor: pointer;
    /* Empêche la sélection de texte sur mobile */
    -webkit-user-select: none;
    user-select: none;
}

/* Icône App */
.app-icon {
    width: 68px;
    height: 68px;
    background: var(--card-bg);
    border-radius: var(--radius-l);
    object-fit: cover;
    box-shadow: var(--shadow-icon);
    margin-bottom: 8px;
    transition: filter 0.2s, transform 0.1s;
}

.app-item:active .app-icon {
    filter: brightness(0.85);
    transform: scale(0.95);
}

/* Nom App */
.app-name {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    width: 80px; /* Force la largeur pour le text-overflow */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

/* ─────────────────────────────────────────────────────────────
   5. MODE GESTION (Suppression / Tremblement)
   ───────────────────────────────────────────────────────────── */

/* Croix de suppression */
.delete-btn {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.3); /* Fond sombre semi-transparent */
    backdrop-filter: blur(4px);   /* Flou iOS */
    color: white;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 300;
    line-height: 22px; /* Centrage vertical */
    text-align: center;
    z-index: 10;
    text-decoration: none;
    display: none; /* Caché par défaut */
}

/* Quand le mode gestion est actif */
.manage-mode .delete-btn {
    display: block;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.manage-mode .app-icon {
    animation: shake 0.25s infinite linear;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(1.5deg); }
    75% { transform: rotate(-1.5deg); }
    100% { transform: rotate(0deg); }
}

/* ─────────────────────────────────────────────────────────────
   6. BARRE D'UPLOAD (Glassmorphism)
   ───────────────────────────────────────────────────────────── */

.upload-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85); /* Blanc transparent */
    backdrop-filter: blur(20px);            /* Flou iOS puissant */
    -webkit-backdrop-filter: blur(20px);
    
    border-top: 1px solid rgba(0,0,0,0.1);
    padding: 15px 20px;
    /* Gestion safe-area pour iPhone X et + */
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    
    text-align: center;
    z-index: 1000;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

details[open] {
    padding-bottom: 10px;
}

summary {
    list-style: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    padding: 8px;
    outline: none;
}
summary::-webkit-details-marker { display: none; }

.upload-bar form {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Input File custom */
input[type="file"] {
    background: white;
    border: 1px dashed #ccc;
    font-size: 14px;
    padding: 10px;
}

/* Bouton spécifique upload */
.btn-upload {
    background-color: var(--primary);
    border-radius: 25px;
    padding: 12px;
    font-size: 15px;
}
