/* app.css - Composants de l'interface. Toutes les couleurs viennent des variables de theme.css. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; background: var(--bg-page); color: var(--text); min-height: 100vh; padding: 20px 20px 70px; }
body.page-gradient { background: var(--bg-gradient); }
body.page-center { display: flex; justify-content: center; align-items: center; }
body.page-form { padding-top: 40px; }
body.page-print { max-width: 800px; margin: 0 auto; min-height: 0; padding-top: 60px; font-family: Arial, sans-serif; }

a { color: var(--link); }
h1 { color: var(--text); font-size: 26px; margin-bottom: 5px; }
.subtitle { color: var(--text-faint); margin-bottom: 20px; }
.muted { color: var(--text-faint); font-size: 14px; }
.note { color: var(--text-faint); font-size: 13px; margin-top: 10px; }
.empty { color: var(--text-muted); padding: 30px; text-align: center; }

.container { max-width: 1200px; margin: 0 auto; }
.container-md { max-width: 900px; }
.panel { background: var(--bg-surface); border-radius: 10px; padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel h2 { font-size: 17px; color: var(--link); margin-bottom: 15px; }
.panel-table { padding: 10px 20px 20px; overflow-x: auto; }

/* ---------- Boutons ---------- */
.btn { display: inline-block; padding: 14px 28px; background: var(--gradient); color: #fff; border: none; border-radius: 8px; font-family: inherit; font-size: 16px; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, background 0.2s; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; font-weight: 400; border-radius: 5px; white-space: nowrap; }
.btn-sm:hover { transform: none; box-shadow: none; }
.btn-md { padding: 12px 24px; margin: 5px; border-radius: 5px; font-weight: 400; }
.btn-add { flex: none; padding: 10px 18px; font-size: 14px; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-secondary:hover { background: var(--btn-secondary-hover); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4); }
.btn-warning { background: var(--warning); }

.download-btn { display: block; width: 100%; padding: 16px; margin-bottom: 10px; background: var(--gradient); color: #fff; text-align: center; text-decoration: none; border-radius: 10px; font-size: 16px; font-weight: 600; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); }
.download-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6); }
.download-btn.grey { background: var(--btn-grey); box-shadow: none; }

/* ---------- Alertes et badges ---------- */
.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-error, .alert-warning { background: var(--error-bg); color: var(--error-text); border-color: var(--error-border); }
.success-links { margin-top: 15px; }
.success-links a { display: inline-block; margin-right: 10px; color: var(--link); text-decoration: none; font-weight: 500; }
.success-links a:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; margin-left: 4px; vertical-align: middle; }
.badge-admin { background: var(--primary); color: #fff; }
.badge-ok { background: var(--success-bg); color: var(--success-text); margin-left: 0; }
.badge-off { background: var(--error-bg); color: var(--error-text); }
.badge-nologin { background: var(--notice-bg); color: var(--notice-text); margin-left: 0; }

/* ---------- Formulaires ---------- */
label { display: block; margin-bottom: 5px; color: var(--text-label); font-weight: 500; font-size: 14px; }
.required { color: var(--required); }
input:not([type=checkbox]), select, textarea { width: 100%; padding: 12px; border: 2px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--text); background: var(--bg-input); transition: border-color 0.2s; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
::placeholder { color: var(--text-faint); }
.hint { color: var(--text-faint); font-size: 13px; margin-top: 5px; }
.hint-lead { margin: -10px 0 25px; }
.hint-address { margin: -8px 0 15px; }
.hint-mb { margin-bottom: 15px; }

.form-container { max-width: 640px; margin: 0 auto; background: var(--bg-surface); border-radius: 15px; padding: 40px; box-shadow: var(--shadow-lg); }
.form-container h1 { margin-bottom: 30px; }
.form-section { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 2px solid var(--border-soft); }
.form-section h2 { font-size: 18px; color: var(--link); margin-bottom: 15px; }
.form-group { margin-bottom: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.actions { display: flex; gap: 10px; margin-top: 30px; flex-wrap: wrap; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } .form-container { padding: 25px; } }

.photo-preview { margin-top: 10px; text-align: center; }
.photo-preview img { max-width: 200px; max-height: 200px; border-radius: 10px; border: 2px solid var(--border); }
.current-photo { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.current-photo img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; font-weight: normal; cursor: pointer; margin-bottom: 12px; line-height: 1.4; color: var(--text-label); }
.checkbox-label.flush { margin: 0; }
.checkbox-label input { margin-top: 3px; }
.file-input-wrapper { position: relative; overflow: hidden; display: inline-block; width: 100%; }
.file-input-wrapper input[type=file] { position: absolute; left: -9999px; }
.file-input-label { display: block; padding: 12px; background: var(--bg-subtle); border: 2px dashed var(--primary); border-radius: 8px; text-align: center; cursor: pointer; transition: background 0.2s; }
.file-input-label:hover { background: var(--bg-subtle-hover); }

.danger-zone { margin-top: 30px; padding: 20px; border: 2px solid var(--error-border); border-radius: 10px; }
.danger-zone h2 { color: var(--danger); font-size: 18px; margin-bottom: 10px; }
.danger-zone p { margin-bottom: 8px; }
.danger-zone form { display: inline-block; margin: 10px 10px 0 0; }

/* ---------- Connexion et message ---------- */
.login-card, .message-box { background: var(--bg-surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: 100%; }
.login-card { max-width: 400px; padding: 40px 35px; }
.login-card h1 { text-align: center; }
.login-card .subtitle { text-align: center; font-size: 14px; margin-bottom: 30px; }
.message-box { max-width: 420px; padding: 40px; text-align: center; }
.message-box h1 { margin-bottom: 10px; }
.message-box p { color: var(--text-muted); }
.message-box .btn { margin-top: 20px; }

/* ---------- Carte publique et profil ---------- */
.card { background: var(--bg-surface); border-radius: 20px; box-shadow: var(--shadow-lg); max-width: 520px; width: 100%; overflow: hidden; }
.card .header { background: var(--gradient); padding: 40px 30px; text-align: center; color: #fff; }
.photo-container { width: 120px; height: 120px; margin: 0 auto 20px; border-radius: 50%; overflow: hidden; border: 4px solid rgba(255, 255, 255, 0.3); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); }
.photo-container img { width: 100%; height: 100%; object-fit: cover; }
.card .header h1 { color: #fff; font-size: 28px; }
.header .nickname { font-size: 14px; opacity: 0.85; font-style: italic; margin-bottom: 5px; }
.header .title { font-size: 16px; opacity: 0.9; margin-bottom: 3px; }
.header .company { font-size: 14px; opacity: 0.8; }
.card .content { padding: 30px; }
.qr-section { text-align: center; margin-bottom: 30px; }
.qr-section img { width: 250px; height: 250px; border: 3px solid var(--border-soft); border-radius: 10px; padding: 10px; background: #fff; }
.info-grid { display: grid; gap: 15px; margin-bottom: 25px; }
.info-item { display: flex; align-items: center; padding: 12px; background: var(--bg-subtle); border-radius: 8px; }
.info-icon { width: 40px; height: 40px; background: var(--gradient); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-right: 12px; color: #fff; font-size: 18px; flex-shrink: 0; }
.info-text { flex: 1; min-width: 0; }
.info-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; font-weight: normal; }
.info-value { font-size: 14px; color: var(--text); word-break: break-word; }
.info-value a { color: var(--link); text-decoration: none; }

/* Variante plus grande : page web de la carte (ordinateur) */
.card-lg { max-width: 600px; }
.card-lg .header h1 { font-size: 30px; }
.card-lg .photo-container { width: 150px; height: 150px; border-width: 5px; }
.card-lg .header .nickname { font-size: 15px; }
.card-lg .header .title { font-size: 18px; }
.card-lg .header .company { font-size: 16px; }
.card-lg .content { padding: 40px 30px; }
.card-lg .info-grid { gap: 20px; margin-bottom: 30px; }
.card-lg .info-item { padding: 15px; border-radius: 10px; transition: transform 0.2s; }
.card-lg .info-item:hover { transform: translateX(5px); background: var(--bg-subtle-hover); }
.card-lg .info-icon { width: 50px; height: 50px; margin-right: 15px; font-size: 22px; }
.card-lg .info-label { font-size: 12px; margin-bottom: 3px; }
.card-lg .info-value { font-size: 16px; }
.card-lg .info-value a:hover { text-decoration: underline; }
.download-section { text-align: center; padding: 30px; background: var(--bg-download); border-radius: 15px; }
.download-section h3 { color: var(--text); margin-bottom: 15px; font-size: 20px; }
.download-section p { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }
.download-btn.inline { display: inline-block; width: auto; padding: 18px 36px; margin-bottom: 0; border-radius: 12px; font-size: 18px; }
.download-btn.inline:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6); }

/* ---------- Liste des utilisateurs ---------- */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 10px; }
.top-bar h1 { font-size: 30px; margin: 0; }
.top-actions, .top-links { display: flex; gap: 8px; flex-wrap: wrap; }
.top-links { margin-bottom: 25px; }
.stats-box { background: var(--bg-surface); padding: 20px; border-radius: 10px; margin-bottom: 30px; box-shadow: var(--shadow); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; }
.stat-item { text-align: center; }
.stat-number { font-size: 36px; font-weight: bold; color: var(--link); }
.stat-label { color: var(--text-muted); font-size: 14px; margin-top: 5px; }
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.user-card { background: var(--bg-surface); border-radius: 10px; padding: 20px; box-shadow: var(--shadow); transition: transform 0.2s; }
.user-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.user-card.disabled { opacity: 0.65; }
.user-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.user-head img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-card h2 { margin: 0 0 3px 0; color: var(--link); font-size: 19px; }
.user-card .title { color: var(--text-muted); font-size: 14px; }
.user-card .info { font-size: 13px; color: var(--text-faint); margin: 5px 0; word-break: break-word; }
.card-actions { margin-top: 15px; display: flex; gap: 6px; flex-wrap: wrap; }
.card-actions .btn { flex: 1; padding: 8px; }

/* ---------- Statistiques et journal ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 25px; }
.kpi { background: var(--bg-surface); border-radius: 10px; padding: 18px; text-align: center; box-shadow: var(--shadow); }
.kpi .n { font-size: 32px; font-weight: bold; color: var(--link); }
.kpi .l { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar { width: 100%; background: linear-gradient(180deg, #667eea 0%, #764ba2 100%); border-radius: 3px 3px 0 0; }
.bar.zero { background: var(--track); min-height: 2px; }
.axis { display: flex; justify-content: space-between; color: var(--text-faint); font-size: 12px; margin-top: 6px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.dist-row { display: grid; grid-template-columns: 110px 1fr 80px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; }
.track { background: var(--track); border-radius: 5px; height: 10px; overflow: hidden; }
.fill { background: var(--primary); height: 100%; }
.val { color: var(--text-muted); font-size: 13px; text-align: right; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--link); padding: 12px 10px; border-bottom: 2px solid var(--border-soft); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
td.ua { max-width: 320px; word-break: break-all; color: var(--text-muted); }
.pager { margin-top: 15px; display: flex; gap: 8px; align-items: center; color: var(--text-muted); font-size: 14px; }
.pager a { padding: 6px 12px; background: var(--primary); color: #fff; text-decoration: none; border-radius: 5px; }

/* Largeurs et hauteurs en pourcentage (graphiques) : des classes plutôt que des attributs style
   pour pouvoir interdire le CSS inline par la politique de sécurité (CSP). */
.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}.w-25{width:25%}.w-30{width:30%}.w-35{width:35%}.w-40{width:40%}.w-45{width:45%}.w-50{width:50%}
.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}.w-70{width:70%}.w-75{width:75%}.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}.w-100{width:100%}
.h-0{height:0}.h-4{height:4%}.h-6{height:6%}.h-8{height:8%}.h-10{height:10%}.h-12{height:12%}.h-14{height:14%}.h-16{height:16%}.h-18{height:18%}.h-20{height:20%}
.h-22{height:22%}.h-24{height:24%}.h-26{height:26%}.h-28{height:28%}.h-30{height:30%}.h-32{height:32%}.h-34{height:34%}.h-36{height:36%}.h-38{height:38%}.h-40{height:40%}
.h-42{height:42%}.h-44{height:44%}.h-46{height:46%}.h-48{height:48%}.h-50{height:50%}.h-52{height:52%}.h-54{height:54%}.h-56{height:56%}.h-58{height:58%}.h-60{height:60%}
.h-62{height:62%}.h-64{height:64%}.h-66{height:66%}.h-68{height:68%}.h-70{height:70%}.h-72{height:72%}.h-74{height:74%}.h-76{height:76%}.h-78{height:78%}.h-80{height:80%}
.h-82{height:82%}.h-84{height:84%}.h-86{height:86%}.h-88{height:88%}.h-90{height:90%}.h-92{height:92%}.h-94{height:94%}.h-96{height:96%}.h-98{height:98%}.h-100{height:100%}

/* ---------- QR code imprimable ---------- */
.qr-card { border: 2px solid var(--text); border-radius: 10px; padding: 30px; text-align: center; background: var(--bg-surface); page-break-after: always; }
.qr-card h1 { margin-bottom: 10px; font-size: 28px; }
.qr-card .subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 16px; }
.qr-card img { width: 300px; height: 300px; margin: 20px 0; padding: 10px; background: #fff; }
.qr-card .instruction { margin-top: 20px; color: var(--text-faint); font-size: 14px; }
.url-display { background: var(--bg-subtle-hover); padding: 10px; border-radius: 5px; margin: 20px 0; word-break: break-all; font-family: monospace; font-size: 12px; }
.qr-actions { margin-top: 30px; text-align: center; }

/* ---------- Menu du site (☰) : session, langue, thème, déconnexion ---------- */
.site-menu { position: fixed; bottom: 12px; right: 12px; z-index: 1000; }
.site-menu summary { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 50%; background: var(--nav-bg); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); cursor: pointer; list-style: none; font-size: 22px; line-height: 1; user-select: none; }
.site-menu summary::-webkit-details-marker { display: none; }
.site-menu summary::before { content: '\2630'; }
.site-menu[open] summary::before { content: '\2715'; }
.site-menu summary:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.site-menu-panel { position: absolute; bottom: 56px; right: 0; display: flex; flex-direction: column; gap: 14px; width: min(300px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow-y: auto; padding: 14px; background: var(--nav-bg); color: var(--text); border-radius: 16px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); font-size: 15px; }
.menu-user { font-weight: 600; overflow-wrap: anywhere; }
.menu-links { display: flex; flex-direction: column; gap: 2px; }
.menu-links a { display: block; padding: 11px 12px; border-radius: 10px; color: var(--link); font-weight: 600; text-decoration: none; }
.menu-links a:hover { background: var(--bg-subtle-hover); }
.menu-title { margin-bottom: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.menu-langs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu-langs a { padding: 10px; border-radius: 10px; background: var(--bg-subtle); color: var(--text); font-size: 14px; text-align: center; text-decoration: none; }
.menu-langs a:hover { background: var(--bg-subtle-hover); }
.menu-langs a[aria-current='true'] { background: var(--primary); color: #fff; font-weight: 600; }
.menu-theme { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: none; border-radius: 10px; background: var(--bg-subtle); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.menu-theme:hover { background: var(--bg-subtle-hover); }
.menu-theme::before { content: '\1F319'; }
[data-theme='dark'] .menu-theme::before { content: '\2600\FE0F'; }
.menu-theme::after { content: attr(aria-label); }
.menu-logout { width: 100%; padding: 11px 12px; border: none; border-radius: 10px; background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.menu-logout:hover { background: var(--primary-hover); }

/* ---------- Avis de publication et onglets du formulaire de profil ---------- */
.public-notice { margin-bottom: 25px; padding: 12px 15px; border-radius: 8px; background: var(--notice-bg); color: var(--notice-text); font-size: 14px; line-height: 1.5; }
.public-notice a { color: inherit; font-weight: 600; }
.address-kind { margin-bottom: 10px; }
input[type=color] { height: 46px; padding: 4px; cursor: pointer; }
.form-container .qr-section { margin-bottom: 25px; }
.form-container .qr-section img { width: 220px; height: 220px; }
.privacy p { margin-bottom: 8px; line-height: 1.5; }
.privacy ul { padding-left: 20px; }
.privacy li { margin-bottom: 8px; line-height: 1.5; }
.tab-list { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border-soft); }
.tab { flex: 1; margin-bottom: -2px; padding: 12px 10px; border: none; border-bottom: 3px solid transparent; background: none; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--link); }
.tab[aria-selected='true'] { color: var(--link); border-bottom-color: var(--primary); }
.tab:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }

/* ---------- Impression : toujours sur fond blanc, sans les boutons ---------- */
@media print {
    .no-print, .site-menu { display: none !important; }
    body { background: #fff !important; --bg-surface: #fff; --bg-subtle-hover: #f0f0f0; --text: #000; --text-muted: #444; --text-faint: #555; }
}
