/* ===============================
   Mintycharts — CSS Mobile-First
   Structure : Base mobile → 480px → 640px → 768px → 1024px
==================================*/

/* ===============================
   Variables CSS
==================================*/
:root {
  --mint-primary: #4ECDC4;
  --mint-secondary: #44a08d;
  --accent-violet: #A78BFA;
  --blue-primary: #A78BFA;
  --mint-primary-rgb: 78, 205, 196;
  --theme-primary-text: #4ECDC4;
  --theme-primary-text-rgb: 78, 205, 196;
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --page-bg: #E8EBF2;   /* était #f0f4f8 */
  --card-bg: #ffffff;
  --card-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  --bg-white: #ffffff;
  --bg-light: #ffffff;
  --border-light: #e2e8f0;
  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.15);
  --radius-card: 10px;
  --radius-input: 8px;
  --radius-button: 8px;
  --spacing-lg: 20px;
  --spacing-2xl: 32px;
  --spacing-3xl: 48px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

/* ===============================
   Mode sombre
==================================*/
html[data-theme="dark"] {
  --page-bg: #1a1a2e;
  --card-bg: #252535;
  --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  --text-primary: #e2e8f0;
  --text-secondary: #b8c5d6;
  --text-muted: #94a3b8;
  --bg-white: #252535;
  --bg-light: #252535;
  --bg-card: #252535;
  --border-light: #3d3d4d;
  --accent: var(--mint-primary);
  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.4);
  --shadow-card-soft: 0 4px 24px rgba(0, 0, 0, 0.25);
  --hover-lift: 0 6px 20px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] body {
  background: var(--page-bg);
}

html[data-theme="dark"] .main-container {
  background: transparent;
  border: none;
  box-shadow: none;
}

html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .char-count,
html[data-theme="dark"] .file-info-details,
html[data-theme="dark"] .upload-progress-text,
html[data-theme="dark"] .theme-toggle-label,
html[data-theme="dark"] .preview-caption {
  color: var(--text-secondary);
  opacity: 1;
}

html[data-theme="dark"] .upload-text,
html[data-theme="dark"] .upload-subtext {
  color: var(--text-secondary);
  opacity: 0.95;
}

html[data-theme="dark"] .ai-suggestion {
  color: var(--mint-primary);
  opacity: 1;
}

html[data-theme="dark"] .footer {
  color: var(--text-secondary);
  opacity: 0.9;
}

html[data-theme="dark"] .title {
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--mint-primary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-theme="dark"] .upload-area {
  background: var(--card-bg);
  border: 1px dashed var(--border-light);
  color: var(--text-primary);
  box-shadow: var(--card-shadow);
  border-radius: 8px;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

html[data-theme="dark"] .upload-area:hover,
html[data-theme="dark"] .upload-area.dragover {
  background: #2d2d3e;
  border-color: var(--accent);
  box-shadow: var(--hover-lift);
}

html[data-theme="dark"] .file-info {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  box-shadow: var(--card-shadow);
  border-radius: 8px;
  transition: box-shadow 0.2s ease;
}

html[data-theme="dark"] .file-info:hover {
  box-shadow: var(--hover-lift);
}

html[data-theme="dark"] .preview-section .preview-header {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

html[data-theme="dark"] .preview-section .preview-header:hover {
  background: #2d3d52;
  box-shadow: var(--hover-lift);
}

html[data-theme="dark"] .description-section {
  padding: 0;
}

html[data-theme="dark"] .description-textarea {
  background: #2d3d52;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] .description-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.95;
}

html[data-theme="dark"] .description-textarea:focus {
  border-color: var(--mint-primary);
  box-shadow: 0 0 0 3px rgba(var(--mint-primary-rgb), 0.2);
  outline: none;
  background: #334155;
}

html[data-theme="dark"] .description-label {
  color: var(--text-primary);
}

html[data-theme="dark"] .main-button {
  background: linear-gradient(135deg, var(--mint-secondary) 0%, var(--mint-primary) 100%);
  color: #0f172a;
}

html[data-theme="dark"] .main-button:hover:not(:disabled) {
  box-shadow: 0 12px 35px rgba(var(--mint-primary-rgb), 0.45);
}

html[data-theme="dark"] .main-button:focus-visible {
  outline: 2px solid var(--mint-primary);
  outline-offset: 2px;
}

html[data-theme="dark"] .reset-link {
  margin: 28px 0 20px 0;
  padding-top: 20px;
}

html[data-theme="dark"] .reset-link a {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  opacity: 0.85;
  transition: color 0.2s ease, opacity 0.2s ease;
}

html[data-theme="dark"] .reset-link a:hover,
html[data-theme="dark"] .reset-link a:focus-visible {
  color: var(--text-secondary);
  opacity: 1;
  outline: none;
  text-decoration: none;
}

html[data-theme="dark"] .table-container {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-card);
}


html[data-theme="dark"] .message.success { background: rgba(78, 205, 196, 0.15); color: var(--mint-primary); border-color: rgba(78, 205, 196, 0.4); }
html[data-theme="dark"] .message.error { background: rgba(231, 76, 60, 0.15); color: #f87171; border-color: rgba(248, 113, 113, 0.4); }

html[data-theme="dark"] table.dataframe-preview th {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-light);
}

html[data-theme="dark"] table.dataframe-preview td {
  border-color: var(--border-light);
  color: var(--text-primary);
}

html[data-theme="dark"] .modal-content {
  background: var(--bg-white);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

html[data-theme="dark"] .chart-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

html[data-theme="dark"] .chart-action-btn:hover,
html[data-theme="dark"] .chart-action-btn:focus-visible {
  background: rgba(var(--mint-primary-rgb), 0.2);
  color: var(--mint-primary);
  border-color: var(--mint-primary);
  outline: none;
}

html[data-theme="dark"] .loading {
  color: var(--text-primary);
}

html[data-theme="dark"] .theme-toggle-track {
  background: var(--border-light);
}

html[data-theme="dark"] .theme-toggle-thumb {
  background: var(--text-primary);
}

html[data-theme="dark"] .theme-footer {
  border-top-color: var(--border-light);
}

html[data-theme="dark"] .upload-progress-wrap {
  background: var(--bg-light);
  border-color: var(--border-light);
}

html[data-theme="dark"] .upload-progress-text {
  color: var(--text-primary);
}

/* ===============================
   Reset
==================================*/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100%;
}

body {
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  background: var(--page-bg);
  padding: 8px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
}

body.upload-page {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.upload-page:has(#chartResult.is-visible) {
  max-height: 100dvh;
  overflow: hidden;
}

/* Barre fixe haut droite : retour discret + thème */
.minty-top-bar-fixed {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 100;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
}

.upload-theme-fixed .theme-toggle-wrap {
  margin: 0;
}

/* Flèche retour : volontairement discrète (à côté du toggle clair/sombre) */
.minty-back-discrete {
  box-sizing: border-box;
  margin: 0;
  padding: 0 2px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 300;
  color: var(--text-primary);
  opacity: 0.38;
  text-decoration: none;
  cursor: pointer;
  border-radius: 10px;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

a.minty-back-discrete {
  color: var(--text-primary);
}

.minty-back-discrete:hover,
.minty-back-discrete:focus-visible {
  opacity: 0.72;
  background: rgba(15, 23, 42, 0.06);
  outline: none;
}

html[data-theme="dark"] .minty-back-discrete:hover,
html[data-theme="dark"] .minty-back-discrete:focus-visible {
  background: rgba(255, 255, 255, 0.07);
}

.minty-back-discrete:active {
  opacity: 0.9;
}

/* Accueil : flèche fixe seulement si graphique simple (pas de carte dashboard avec sa propre flèche) */
.minty-back-discrete--home {
  display: none;
}

body.upload-page:has(#chartResult.is-visible):not(:has(.dash2-shell)) .minty-back-discrete--home {
  display: inline-flex;
}

/* Page résultat : barre fixe masquée dès que le dashboard (avec flèche dans l’en-tête) est rendu */
body.result-page-root:has(.dash2-shell) .result-back-bar {
  display: none !important;
}

.upload-page-center {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  min-height: 0;
  /* Réserve = logo footer (~200px) + padding sous logo + safe area + marge nette au-dessus du logo */
  padding-top: max(40px, 6vh);
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: max(
    20rem,
    calc(
      200px + max(0.5rem, env(safe-area-inset-bottom, 0px)) + 4rem
    )
  );
  box-sizing: border-box;
  /* Permet de faire défiler tout le formulaire sans que le bouton passe sous le logo fixe */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.upload-page:has(#chartResult.is-visible) .upload-page-center {
  overflow-y: hidden;
  min-height: min(100vh, 100dvh);
}

/* Dashboard généré: réduire l'espace sous le contenu et éviter le scroll page */
body.upload-page:has(#chartResult.is-visible .dash2-shell) .upload-page-center {
  padding-bottom: max(
    10.5rem,
    calc(140px + max(0.2rem, env(safe-area-inset-bottom, 0px)) + 1rem)
  );
}

/* Dashboard affiché: logo de bas moins haut et un peu remonté pour garder l'ensemble sur une seule page */
body.upload-page:has(#chartResult.is-visible) .upload-footer-fixed {
  padding-bottom: max(0.2rem, env(safe-area-inset-bottom, 0px));
}

body.upload-page:has(#chartResult.is-visible) .upload-footer-fixed .footer-brand-logo {
  height: 140px !important;
  max-width: min(460px, 86vw);
}

.upload-footer-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 0 12px;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: 50;
  pointer-events: none;
}

.upload-footer-fixed .footer-brand-logo {
  height: 200px !important;
  width: auto !important;
  max-width: min(560px, 94vw);
  object-fit: contain;
  display: block;
  margin: 0;
  flex-shrink: 0;
}

.footer-brand-logo {
  height: 150px !important;
  width: auto !important;
  display: block;
  max-width: min(460px, 94vw);
  object-fit: contain;
  margin: 0;
  flex-shrink: 0;
}

.footer-brand-credit {
  margin: 0;
  font-size: inherit;
  line-height: 1.35;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===============================
   BASE MOBILE (< 480px)
==================================*/

/* --- Layout principal --- */
.main-container {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border: none;
  padding: 20px 16px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  box-sizing: border-box;
}

.upload-page .main-container {
  padding: 10px 16px 12px;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: clamp(0.9rem, 2vh, 1.45rem);
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 24px;
}

.header--with-theme {
  margin-bottom: 8px;
}

.header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
}

.header-title-row .title {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.header-theme {
  flex-shrink: 0;
}

.header--with-theme .subtitle {
  margin-top: 4px;
  margin-bottom: 0;
}

.title {
  font-size: 1.85rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--mint-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  padding: 6px 0;
  position: relative;
}

.title::after {
  content: '\2728';
  position: absolute;
  right: -28px;
  top: 0;
  font-size: 1.2rem;
  animation: sparkle 1.2s ease-out 1 forwards;
}

@keyframes sparkle {
  0% { transform: scale(0.5) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(20deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
  opacity: 0.8;
}

/* --- Upload area --- */
.upload-section {
  margin-bottom: var(--spacing-lg);
}

.upload-area {
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  padding: 12px 16px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  min-height: 44px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
}

.upload-area:hover {
  border-color: var(--mint-primary);
  background: #f0fdfa;
}

.upload-area.dragover {
  border-color: var(--mint-primary);
  background: #f0fdfa;
  transform: scale(1.01);
}

.upload-icon {
  font-size: 1.35rem;
  display: block;
  flex-shrink: 0;
}

.upload-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 0;
}

.upload-subtext {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.8;
  margin: 0;
  width: 100%;
  flex-basis: 100%;
  order: 1;
}

.file-input {
  display: none;
}

/* --- File info (mobile : empilé) --- */
.file-info {
  margin-top: 12px;
  padding: 8px 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-input);
  box-shadow: var(--card-shadow);
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  transition: all 0.3s ease;
}

.file-info.show {
  display: flex;
}

.file-info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.file-info-text-wrap {
  flex: 1;
  min-width: 0;
}

.file-remove-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: -4px -4px 0 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.file-remove-btn:hover {
  opacity: 1;
  background: rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] .file-remove-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.file-info-icon {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.file-info-text {
  font-size: 0.8rem;
  color: var(--text-primary);
  font-weight: 600;
  flex: 1;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.file-info-details {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
  align-self: flex-end;
}

/* --- Preview section --- */
.preview-section {
  margin: var(--spacing-lg) 0;
  display: none;
}

.preview-section.show {
  display: block;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-input);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  min-height: 44px;
  touch-action: manipulation;
}

.preview-header:hover {
  background: rgba(var(--mint-primary-rgb), 0.08);
  border-color: var(--mint-primary);
}

.preview-title {
  flex: 1;
  text-align: left;
}

.preview-toggle-icon {
  color: var(--mint-primary);
  font-size: 0.85rem;
  transition: transform 0.2s;
}

.preview-body {
  margin-top: 8px;
  overflow: hidden;
}

.preview-caption {
  font-size: 0.875rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
}

.table-container {
  overflow-x: auto;
  overflow-y: auto;
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-input);
  max-height: 420px;
}

table.dataframe-preview {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table.dataframe-preview th {
  background-color: var(--bg-light);
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  border-bottom: 2px solid var(--border-light);
  min-width: 80px;
  max-width: 220px;
  white-space: normal;
  word-break: break-word;
}

table.dataframe-preview td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  min-width: 80px;
  max-width: 220px;
  word-break: break-word;
  overflow-wrap: break-word;
  vertical-align: top;
}

table.dataframe-preview tr:hover {
  background-color: rgba(var(--mint-primary-rgb), 0.05);
}

/* --- Description section --- */
.description-section {
  margin-bottom: var(--spacing-2xl);
}

.description-label {
  color: var(--text-primary);
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 1rem;
}

.description-textarea {
  width: 100%;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-input);
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  min-height: 160px;
  background: var(--bg-white);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

.description-textarea:focus {
  border-color: var(--mint-primary);
  box-shadow: 0 0 0 3px rgba(var(--mint-primary-rgb), 0.15);
  outline: none;
}

.description-textarea:focus-visible {
  outline: none;
}

.description-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.8rem;
}

.char-count {
  color: var(--text-secondary);
}

/* Page upload : centrage 100vh, formulaire max 800px */
.upload-page .title {
  font-size: clamp(1.65rem, 4.5vw, 2.15rem);
  padding: 0 0 6px;
}

.upload-page .title::after {
  font-size: 1.05rem;
  right: -22px;
}

.upload-page .subtitle {
  font-size: 0.85rem;
  margin-top: 4px;
  line-height: 1.5;
}

.upload-page .file-info {
  flex-direction: column;
}

.upload-page .header {
  margin-bottom: 0;
  padding-bottom: 6px;
}

.upload-page .upload-section {
  margin-bottom: 0;
}

.upload-page .upload-area {
  min-height: 120px;
  padding: 18px 18px;
  gap: 8px 10px;
}

/* Fichier choisi : zone d’upload compacte pour éviter le scroll vertical */
.upload-page .upload-section:has(.file-info.show) .upload-area {
  min-height: 0;
  padding: 0.5rem 0.875rem;
  gap: 0.35rem 0.5rem;
}

.upload-page .upload-section:has(.file-info.show) .upload-subtext {
  display: none;
}

.upload-page .upload-section:has(.file-info.show) .upload-text {
  font-size: 0.8rem;
}

.upload-page .upload-section:has(.file-info.show) .upload-icon {
  font-size: 1.05rem;
}

.upload-page .upload-section:has(.file-info.show) .file-info {
  margin-top: 6px;
  padding: 5px 8px;
}

.upload-page .upload-icon {
  font-size: 1.35rem;
}

.upload-page .upload-text {
  font-size: 0.88rem;
}

.upload-page .upload-subtext {
  font-size: 0.72rem;
}

.upload-page .upload-progress-wrap {
  margin: 0;
  padding: 6px 10px;
}

.upload-page .preview-section {
  margin: 0;
}

.upload-page .preview-header {
  padding: 6px 10px;
  min-height: 34px;
  font-size: 0.82rem;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

.upload-page .table-container {
  max-height: 110px;
}

.upload-page .description-section {
  margin-bottom: 0;
}

.upload-page .description-label {
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.upload-page .description-textarea {
  min-height: 0;
  max-height: none;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.4;
  resize: none;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

.upload-page .description-footer {
  margin-top: 8px;
}

.upload-page .button-section {
  margin-top: 0;
}

.upload-page .main-button {
  width: 100%;
  padding: 12px 18px;
  min-height: 44px;
  font-size: 0.95rem;
}

.upload-page .main-button,
.upload-page .main-button:disabled {
  background: #2dd4a8 !important;
  color: #13131f !important;
  opacity: 1 !important;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(45, 212, 168, 0.38);
}

.upload-page .main-button:hover,
.upload-page .main-button:disabled:hover {
  background: #2dd4a8 !important;
  color: #13131f !important;
  box-shadow: 0 12px 35px rgba(45, 212, 168, 0.48);
}

.upload-page .main-button:not(:disabled):hover {
  transform: translateY(-3px);
}

.upload-page .main-button:disabled:hover {
  transform: none;
}

.upload-page .main-button:focus-visible {
  outline: 2px solid #2dd4a8;
  outline-offset: 2px;
}

.upload-page .loading {
  margin: 0;
}

.upload-page .chart-result {
  margin-top: 0;
}

.upload-page .message {
  margin: 0;
  padding: 12px 14px;
}

.ai-suggestion {
  color: var(--theme-primary-text);
  font-style: italic;
  opacity: 0.95;
}

/* --- Bouton principal --- */
.main-button {
  background: linear-gradient(135deg, var(--mint-primary) 0%, var(--mint-secondary) 100%);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: var(--radius-button);
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(var(--mint-primary-rgb), 0.3);
  width: 100%;
  min-height: 52px;
  letter-spacing: 0.02em;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.main-button:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(var(--mint-primary-rgb), 0.4);
}

.main-button:focus-visible {
  outline: 2px solid var(--mint-primary);
  outline-offset: 2px;
}

.main-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  background: #9CA3AF;
}

.button-section {
  margin-bottom: 0;
}

/* --- Reset link --- */
.reset-link {
  text-align: center;
  margin: 28px 0 20px 0;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.reset-link a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: color 0.2s ease;
  padding: 8px 12px;
  display: inline-block;
}

.reset-link a:hover,
.reset-link a:focus-visible {
  color: var(--accent-violet);
  outline: none;
  text-decoration: underline;
}

/* --- Theme toggle --- */
.theme-footer {
  margin-top: var(--spacing-3xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: center;
  align-items: center;
}

.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.theme-toggle-btn {
  padding: 8px;
  border: none;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 0;
  border-radius: 999px;
  min-width: 52px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle-track {
  width: 52px;
  height: 28px;
  border-radius: 999px;
  background: var(--border-light);
  position: relative;
  transition: background 0.25s ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-white);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease;
}

.theme-toggle-btn[aria-pressed="true"] .theme-toggle-track {
  background: var(--mint-primary);
}

.theme-toggle-btn[aria-pressed="true"] .theme-toggle-thumb {
  transform: translateX(24px);
}

.theme-toggle-btn:hover .theme-toggle-track {
  background: var(--text-secondary);
  opacity: 0.8;
}

.theme-toggle-btn[aria-pressed="true"]:hover .theme-toggle-track {
  background: var(--mint-secondary);
}

/* --- Footer --- */
.footer {
  text-align: center;
  margin-top: var(--spacing-lg);
  opacity: 0.6;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* --- Messages --- */
.message {
  position: fixed;
  top: 100px;
  right: 20px;
  left: auto;
  transform: none;
  z-index: 9999;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 0.85rem;
  display: none;
}

.message.error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #DC2626;
}

.message.success {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  color: #166534;
}

.message.info {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
}

/* --- Upload progress --- */
.upload-progress-wrap {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--bg-light);
  border-radius: var(--radius-input);
  border: 1px solid var(--border-light);
}

.upload-progress-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border-light);
  overflow: hidden;
  margin-bottom: 8px;
}

.upload-progress-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--upload-pct, 0%);
  background: linear-gradient(90deg, var(--mint-secondary), var(--mint-primary));
  border-radius: 4px;
  transition: width 0.15s ease;
}

.upload-progress-wrap.upload-progress-indeterminate .upload-progress-bar::after {
  width: 40% !important;
  animation: upload-progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes upload-progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.upload-progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Chart result (mobile : empilé) --- */
.chart-result {
  margin-top: var(--spacing-2xl);
  text-align: center;
  display: none;
  width: 100%;
}

.chart-result.is-visible {
  display: flex !important;
  flex-direction: column;
  align-items: center;
}

/* Graphique Plotly : pleine largeur sous le résultat */
.chart-result.is-visible > .chart-canvas-container {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
}

/* --- Chart canvas container (mobile : 1 colonne) --- */
.chart-canvas-container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  display: block;
}

/* --- Chart actions (mobile : flex centré, pastilles) --- */
.chart-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.chart-action-btn {
  background: var(--mint-primary);
  color: #0f172a;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  white-space: nowrap;
  min-height: auto;
  touch-action: manipulation;
  letter-spacing: 0.01em;
}

.chart-action-btn:hover {
  background: var(--mint-secondary);
  transform: translateY(-2px);
}

/* --- Loading --- */
.loading {
  display: none;
  text-align: center;
  margin: 20px 0;
}

.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--mint-primary);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- Modal image --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  margin: 2% auto;
  padding: 12px;
  width: 98%;
  max-width: 1200px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.modal-content img {
  max-width: 100%;
  max-height: 90vh;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
}

.close {
  position: absolute;
  top: 15px;
  right: 25px;
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close:hover {
  color: #000;
}

/* --- Modal carte geo (Plotly) --- */
.modal-content-geo {
  width: 98%;
  max-width: 1100px;
  height: 90vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-content-geo .close {
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 10;
  background: white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  font-size: 20px;
  line-height: 1;
}

.geo-map-container {
  width: 100%;
  flex: 1;
  overflow: hidden;
  border-radius: 8px;
}

.geo-map-container iframe,
.geo-map-container > div {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  border: none;
  display: block;
}

/* Modal carte : titre HTML + Plotly sans titre dupliqué */
.geo-modal-map-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1 1 auto;
}

.geo-modal-map-title {
  margin: 0;
  padding: 0 4px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.geo-modal-map-plot-host {
  flex: 1 1 auto;
  min-height: 400px;
  max-height: min(72vh, 640px);
  overflow: hidden;
}

.geo-map-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  height: min(50vh, 400px);
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.geo-map-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  height: auto;
  color: #e74c3c;
  font-size: 14px;
  padding: 20px;
  text-align: center;
}

/* Plotly dans le modal carte (voir geo-leaflet-layout.css) */
.geo-plotly-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.geo-plotly-canvas {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(128, 148, 168, 0.22);
}

html[data-theme="dark"] .geo-plotly-canvas {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  border-color: rgba(148, 163, 184, 0.28);
}

/* ===============================
   BREAKPOINT 480px (petits téléphones → grands téléphones)
==================================*/
@media (min-width: 480px) {
  body {
    padding: 16px;
  }

  .main-container {
    padding: 24px 20px;
    border-radius: 24px;
  }

  .title {
    font-size: 2.25rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .upload-area {
    padding: 14px 18px;
  }
}

/* ===============================
   BREAKPOINT 640px (tablettes portrait)
==================================*/
/* ===============================
   BREAKPOINT 768px (tablettes paysage / petits laptops)
==================================*/
@media (min-width: 768px) {
  body {
    padding: 24px;
  }

  .main-container {
    padding: 32px 28px;
    max-width: 980px;
    border-radius: 28px;
  }

  .header {
    margin-bottom: var(--spacing-3xl);
  }

  .title {
    font-size: 2.75rem;
    padding: 8px 0;
  }

  .title::after {
    right: -36px;
    font-size: 1.4rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  .upload-area {
    padding: 32px 24px;
    gap: 10px 14px;
  }

  .upload-icon {
    font-size: 1.5rem;
  }

  .upload-text {
    font-size: 1rem;
  }

  .upload-subtext {
    font-size: 0.8rem;
  }

  /* File info en ligne */
  .file-info {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 10px;
  }

  .file-info-text {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .file-info-details {
    font-size: 0.75rem;
    align-self: auto;
  }

  .preview-header {
    padding: 10px 12px;
  }

  .description-textarea {
    padding: 20px;
    min-height: 140px;
  }

  .upload-page .description-textarea {
    min-height: 0;
  }

  .main-button {
    padding: 20px 32px;
    font-size: 1.1rem;
    min-height: 64px;
  }

  .reset-link {
    margin: 24px 0 20px 0;
    padding-top: 16px;
  }

  .reset-link a {
    font-size: 0.875rem;
  }

  /* Chart actions en ligne (desktop / tablette) */
  .chart-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  .chart-action-btn {
    min-width: auto;
    padding: 14px 20px;
    font-size: 0.9rem;
    min-height: 48px;
    white-space: normal;
  }

  .chart-canvas-container {
    max-width: min(92%, 1000px);
  }

  .modal-content {
    padding: 20px;
    width: 95%;
  }

  .modal-content-geo {
    width: 92%;
    height: 85vh;
  }
}

/* ===============================
   BREAKPOINT 1024px (desktop)
==================================*/
@media (min-width: 1024px) {
  .main-container {
    padding: var(--spacing-3xl) 40px;
    border-radius: var(--radius-card);
  }

  .title {
    font-size: 3.2rem;
    margin-bottom: 12px;
  }

  .title::after {
    right: -40px;
    font-size: 1.5rem;
  }
}

/* ─── RTL (arabe et scripts RTL) : alignement à droite, pas seulement à gauche ─── */
.description-textarea[dir="rtl"] {
  text-align: right;
}
.chart-canvas-container[dir="rtl"] {
  direction: rtl;
}
#dataPreview[dir="rtl"] .dataframe-preview th,
#dataPreview[dir="rtl"] .dataframe-preview td {
  text-align: right;
}

/* Page /result : html sans min-height 100% du reset — évite bande vide sous un contenu court. */
html.minty-html-result {
  min-height: auto;
  height: auto;
}

/* Page /result — plein écran, barre thème + retour en haut à droite, footer discret */
body.result-page-root {
  margin: 0;
  padding: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Le body global centre en justify-content — en colonne + 100vh ça laisse du vide en bas. */
  justify-content: flex-start;
  align-items: stretch;
  box-sizing: border-box;
  background: var(--page-bg);
}
html[data-theme="dark"] body.result-page-root {
  background: var(--page-bg);
}
.result-main-full {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 40px 0 0;
  box-sizing: border-box;
  min-height: 0;
}

/* Page résultat : le main ne remplit pas le viewport (évite vide en bas sous le toggle / graphique). */
body.result-page-root .result-main-full {
  flex: 0 1 auto;
}

/* Dashboard chargé : moins de bandeau vide en haut. */
body.result-page-root:has(.dash2-shell),
body.result-page-root.minty-result-dashboard {
  min-height: 0;
}
body.result-page-root:has(.dash2-shell) .result-main-full,
body.result-page-root.minty-result-dashboard .result-main-full {
  padding-top: max(4px, env(safe-area-inset-top, 0px));
}
body.result-page-root .chart-result--result-full {
  margin-top: 0;
  width: 100%;
  max-width: 100%;
}
body.result-page-root .chart-result.is-visible {
  align-items: stretch;
}
body.result-page-root .chart-result.is-visible > .adaptive-dashboard {
  width: 100%;
  max-width: 100%;
}
body.result-page-root .dash2-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  border-radius: 0;
  border: none;
  box-sizing: border-box;
  padding-bottom: 0;
  /* Même fond que le body : évite le « trait » dû au léger décalage de teinte (#fff vs #f0f4f8, etc.) */
  background: var(--page-bg);
  box-shadow: none;
}
body.result-page-root .dash2-chart-box {
  margin-bottom: 0;
}
body.result-page-root .result-main-full {
  padding-bottom: 0;
}
body.result-page-root .geo-plotly-canvas {
  max-width: none;
}
.loading--result {
  margin: 0;
  padding: 48px 16px 16px;
}
.message--result {
  margin: 48px 16px 0;
}
@media (min-width: 768px) {
  .upload-page .main-container {
    padding: 14px 20px 18px;
    max-width: 800px;
    border-radius: 0;
  }

  body.result-page-root {
    padding: 0;
  }
}

button.preview-header,
button.preview-header *,
.preview-header,
.preview-header * {
  font-weight: 400 !important;
}
/* --- User bar ------------------------------------------------- */
.minty-user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.minty-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(45,212,168,0.12);
    border: 0.5px solid rgba(45,212,168,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 500;
    color: #2dd4a8;
    flex-shrink: 0;
}
.minty-user-email {
    font-size: 0.75rem;
    color: #94a3b8;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.minty-logout-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: #94a3b8;
    text-decoration: none;
    padding: 4px 10px;
    border: 0.5px solid #3a4460;
    border-radius: 6px;
    transition: color 0.2s, border-color 0.2s;
}
.minty-logout-btn:hover {
    color: #2dd4a8;
    border-color: #2dd4a8;
}
