* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: Roboto, -apple-system, "Segoe UI", Arial, sans-serif;
    margin: 0; padding: 8px 16px;
    background: #f7f7f8; color: #1a1a1a;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.app-header {
    flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid #e5e7eb;
}
.app-header-titles { min-width: 0; }
.app-header h1 { font-size: 1.1rem; margin: 0; }
.app-sub { color: #666; font-size: 0.75rem; margin: 2px 0 0; }
.app-header-actions { display: flex; align-items: center; gap: 16px; flex-shrink: 0; flex-wrap: wrap; }
/* en-tête uniformisée avec les autres services Gnet (transcription/videos/mon-compte/protectis/
   geneatique-net/toponymes) : retour à l'espace services + prénom du compte + déconnexion, groupés
   à droite du titre. */
.back-link, .account-name { color: #64748b; text-decoration: none; font-size: .9em; }
.back-link:hover { color: #4fa066; }
.logout-link { color: #64748b; text-decoration: none; font-size: .9em; }
.logout-link:hover { color: #4fa066; }
.account-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid #cbd5e1;
                border-radius: 6px; color: #64748b; text-decoration: none; font-size: .8em; font-weight: 600; }
.account-btn:hover { background: #f1f5f9; color: #4fa066; border-color: #4fa066; }
/* choix de la langue d'interface (cf. inc/i18n.php::gnet_rendreSelecteurLangue) - meme gabarit visuel que .account-btn */
.lang-select { padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 6px; color: #64748b;
               font-size: .8em; font-weight: 600; background: #fff; cursor: pointer; }
.lang-select:hover { border-color: #4fa066; color: #4fa066; }
.gnet-footer { flex-shrink: 0; background: #fff; border-top: 1px solid #e5e7eb; padding: 6px 16px;
               margin: 8px -16px -8px; display: flex; justify-content: space-between; align-items: center; font-size: .75em; }
.gnet-footer .gnet-footer-brand { color: #4fa066; font-weight: 700; }
.gnet-footer .gnet-footer-version { color: #000; }
.panel-toggle-btn {
    border: 1px solid #ccc; border-radius: 6px; background: #fff; color: #333;
    font-size: 0.78rem; font-weight: 600; padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
.panel-toggle-btn:hover { background: #f3f4f6; }
.panel-toggle-btn.is-collapsed { background: #eff6ff; border-color: #93c5fd; color: #1e3a8a; }

/* panneau lateral "Mes photos" : quand replie (manuellement via le bouton de l'entete, ou
   automatiquement des qu'une analyse est en cours d'affichage), entierement retire du flux
   (display:none) pour ne laisser aucun espace mort - on le rouvre via son bouton, toujours visible
   dans l'entete. */
.layout {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 20px;
    align-items: stretch;
}
.panel-history { width: 280px; flex-shrink: 0; }
.layout.history-collapsed .panel-history { display: none; }
@media (max-width: 1000px) {
    body { overflow: auto; height: auto; }
    .layout { height: auto; flex-direction: column; }
    .panel-history { width: 100%; }
    .panel { height: auto !important; }
}

.panel {
    background: #fff; border: 1px solid #ddd; border-radius: 8px;
    padding: 14px; height: 100%; min-height: 0;
}
.panel h2 { font-size: 0.95rem; margin: 0 0 10px; }

.panel-history { overflow-y: auto; }

label { display: block; margin-top: 10px; font-weight: 600; font-size: 0.82rem; }
textarea {
    width: 100%; padding: 6px 8px; margin-top: 4px;
    border: 1px solid #ccc; border-radius: 4px; font-family: inherit; font-size: 0.85rem;
    resize: vertical;
}

.dropzone {
    margin-top: 0; margin-bottom: 16px; border: 2px dashed #93c5fd; border-radius: 8px;
    padding: 24px 12px; text-align: center; cursor: pointer;
    background: #eff6ff; color: #1e3a8a; transition: background 0.15s, border-color 0.15s;
}
.dropzone:hover, .dropzone.dragover { background: #e6f4ea; border-color: #4fa066; }
.dropzone-icon { font-size: 2rem; }
.dropzone p { margin: 6px 0 0; font-size: 0.85rem; }
.dropzone-hint { color: #6b7280; font-size: 0.72rem !important; }

.progress-block { margin-top: 16px; }
.progress-label { font-size: 0.8rem; color: #333; margin: 0 0 4px; font-weight: 600; }
.progress-bar { height: 8px; border-radius: 4px; background: #e5e7eb; overflow: hidden; position: relative; }
.progress-fill { height: 100%; background: #4fa066; width: 0%; transition: width 0.2s; }
.progress-bar.indeterminate .progress-fill {
    width: 40% !important; position: absolute;
    animation: indeterminate 1.1s infinite linear;
}
@keyframes indeterminate {
    0% { left: -40%; }
    100% { left: 100%; }
}

.error-msg { color: #b91c1c; font-size: 0.82rem; font-weight: 600; margin-top: 12px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-empty { color: #888; font-size: 0.82rem; }
.history-item {
    display: flex; align-items: center; gap: 2px;
    border: 1px solid #eee; border-radius: 6px;
    background: #fff; width: 100%;
}
.history-item:hover { border-color: #93c5fd; }
.history-item-open {
    display: flex; gap: 8px; align-items: center; padding: 6px;
    border: none; border-radius: 6px 0 0 6px; cursor: pointer; text-align: left;
    background: none; font: inherit; color: inherit; flex: 1; min-width: 0;
}
.history-item-open:hover { background: #f0f4ff; }
.history-item-delete {
    flex-shrink: 0; width: 26px; height: 26px; margin-right: 6px;
    border: none; border-radius: 4px; background: none; color: #999;
    cursor: pointer; font-size: 0.8rem;
}
.history-item-delete:hover { background: #fee2e2; color: #b91c1c; }
.history-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.history-item-info { min-width: 0; }
.history-item-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-meta { font-size: 0.72rem; color: #777; }
.history-item-status { font-size: 0.68rem; padding: 1px 6px; border-radius: 10px; display: inline-block; margin-top: 2px; }
.status-termine { background: #dcfce7; color: #166534; }
.status-termine_avec_erreurs { background: #ffedd5; color: #9a3412; }
.status-erreur_analyse { background: #fee2e2; color: #991b1b; }

.btn-primary, .btn-secondary {
    border-radius: 6px; padding: 7px 14px; font-size: 0.82rem; font-weight: 600;
    cursor: pointer; border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: #4fa066; color: #fff; }
.btn-primary:hover { background: #3d8552; }
.btn-primary:disabled { background: #93c5fd; cursor: default; }
.btn-secondary { background: #fff; border-color: #ccc; color: #333; }
.btn-secondary:hover { background: #f3f4f6; }
.btn-secondary:disabled { color: #aaa; cursor: default; }

.panel-result { display: flex; flex-direction: column; overflow: hidden; flex: 1 1 auto; min-width: 0; }
/* bandeau de l'analyse d'exemple (visiteur non connecte, cf. #demoBanniere dans index.php) : teinte ambre,
   volontairement differente du vert du service et du rouge des erreurs - c'est un avertissement, pas un
   resultat ni une panne. flex-shrink:0 parce que .panel-result est une colonne flex : sans cela le bandeau
   serait comprime (voire reduit a un trait) par la zone de resultat qui occupe toute la hauteur. */
.demo-banner { flex-shrink: 0; margin: 0 0 8px; padding: 8px 12px; border-radius: 6px;
    border: 1px solid #fcd34d; background: #fffbeb; color: #92400e;
    font-size: 0.82rem; font-weight: 600; line-height: 1.4; }
.result-toolbar { flex-shrink: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.result-toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.credits-info { font-size: 0.78rem; color: #555; }
/* solde + credits consommes par la derniere analyse : mis en avant (demande explicite du service),
   contrairement a .credits-info (discret, juste informatif dans le panneau lateral). */
.credits-consumed { font-size: 0.8rem; color: #166534; font-weight: 600; background: #dcfce7;
    border-radius: 6px; padding: 4px 10px; }

/* zone resultat : photo (gauche, 1/2) + description par themes (droite, 1/2) toujours cote a cote,
   meme hauteur, chacune avec son propre defilement interne. */
.edit-area { flex: 1; min-height: 0; display: flex; flex-direction: row; gap: 12px; overflow: hidden; }
.image-col { position: relative; flex: 1 1 50%; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.text-col { flex: 1 1 50%; min-width: 0; min-height: 0; overflow-y: auto; }

@media (max-width: 1000px) {
    .edit-area { flex-direction: column; }
    .image-col { flex: 0 0 auto; }
}

.image-wrap {
    flex: 1; min-height: 0; overflow: auto;
    border: 1px solid #eee; border-radius: 6px; margin-bottom: 10px; background: #fafafa;
    display: flex; align-items: center; justify-content: center;
}
#photoImg { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; }
.image-col textarea#contexte { flex-shrink: 0; margin-bottom: 0; }

.resume-text {
    font-size: 0.88rem; font-style: italic; color: #334155; margin: 0 0 14px;
    padding: 10px 12px; background: #f9fafb; border: 1px solid #eee; border-radius: 6px;
}

.themes-list { display: flex; flex-direction: column; gap: 10px; }
.theme-card { border: 1px solid #ddd; border-radius: 8px; padding: 10px 12px; }
.theme-card-title { font-size: 0.85rem; font-weight: 700; color: #3d8552; margin: 0 0 6px; }
.theme-card-text { font-size: 0.85rem; color: #1a1a1a; margin: 0; white-space: pre-wrap; }
.theme-card.theme-erreur { border-color: #fecaca; background: #fef2f2; }
.theme-card.theme-erreur .theme-card-title { color: #991b1b; }
