/**
 * layout.css — Grille et structure des pages
 * AstroTool v1.0
 */

/* ─── App shell ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
#app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--accent-gold);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.header-logo .logo-star { font-size: 1.25rem; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* ─── Pages ──────────────────────────────────────────────────────────────────── */
.page {
  display: none;
  flex: 1;
  padding: var(--space-lg) var(--space-md);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.page.active {
  display: flex;
  flex-direction: column;
}

/* ─── Page 1 — Formulaire ────────────────────────────────────────────────────── */
#page-form {
  justify-content: flex-start;
  align-items: center;
}

.form-container {
  width: 100%;
  max-width: 480px;
  padding: var(--space-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.form-title {
  text-align: center;
  margin-bottom: var(--space-xl);
  color: var(--text-primary);
}
.form-title .title-star {
  color: var(--accent-gold);
  margin-right: var(--space-sm);
}

/* ─── Page 2 — Chargement ────────────────────────────────────────────────────── */
#page-loading {
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 52px);
}

.loading-content {
  text-align: center;
  max-width: 400px;
}

.loading-animation {
  font-size: 2rem;
  letter-spacing: 0.5rem;
  margin-bottom: var(--space-lg);
  animation: twinkle 1.5s ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

.progress-bar-container {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: var(--space-md);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent-gold);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ─── Page 3 — Thème natal ───────────────────────────────────────────────────── */
#page-chart {
  padding: 0;
  max-width: none;
}

/* En-tête de fiche */
.chart-header {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.chart-identity h2 {
  font-size: 1.125rem;
  margin-bottom: 2px;
}
.chart-identity p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.chart-identity .trinity {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-family: var(--font-symbols);
}

.chart-actions {
  display: flex;
  gap: var(--space-xs);
}

/* Layout principal P3 — Mobile (single column) */
.chart-body {
  display: flex;
  flex-direction: column;
}

/* Zone SVG */
.chart-svg-zone {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-sm);
  background: var(--bg-app);
}
.chart-svg-wrapper {
  width: 100%;
  max-width: min(calc(100vw - 2 * var(--space-sm)), 420px);
  aspect-ratio: 1;
}

/* Zone tableaux */
.chart-tables-zone {
  padding: var(--space-md);
}

/* ─── Desktop ≥1024px : 2 colonnes ─────────────────────────────────────────── */
@media (min-width: 1024px) {
  #page-chart {
    display: flex;
    flex-direction: column;
  }

  .chart-body {
    flex-direction: row;
    flex: 1;
    min-height: 0;
  }

  /* Colonne gauche : roue SVG sticky */
  .chart-svg-zone {
    position: sticky;
    top: 52px;
    height: calc(100vh - 52px - 60px);
    width: 45%;
    min-width: 380px;
    max-width: 560px;
    overflow: hidden;
    align-items: center;
    padding: var(--space-md);
  }
  .chart-svg-wrapper {
    max-width: min(66vw, 660px);
  }

  /* Colonne droite : tableaux scrollables */
  .chart-tables-zone {
    flex: 1;
    overflow-y: auto;
    height: calc(100vh - 52px - 60px);
    padding: var(--space-lg);
    border-left: 1px solid var(--border);
  }
}

@media (min-width: 1280px) {
  .chart-svg-zone {
    width: 50%;
  }
}

/* ─── Page 4 — Liste des fiches ──────────────────────────────────────────────── */
#page-list {
  max-width: 600px;
}

.fiches-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.fiche-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition);
}
.fiche-card:hover { border-color: var(--border-strong); }

.fiche-info { flex: 1; }
.fiche-name { font-weight: 600; margin-bottom: 2px; }
.fiche-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.fiche-signs {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-family: var(--font-symbols);
}
.fiche-actions { display: flex; gap: var(--space-xs); flex-shrink: 0; }

/* Confirmation de suppression inline */
.fiche-confirm {
  display: none;
  font-size: 0.8125rem;
  color: var(--color-error);
  gap: var(--space-sm);
  align-items: center;
}
.fiche-confirm.visible { display: flex; }

/* ─── Fiches récentes (P1) ───────────────────────────────────────────────────── */
.recent-fiches {
  margin-top: var(--space-xl);
  width: 100%;
  max-width: 480px;
}
.recent-title {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}
.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.recent-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* ─── Section bannière sans heure ───────────────────────────────────────────── */
.no-time-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(221,170,0,0.08);
  border-bottom: 1px solid rgba(221,170,0,0.2);
  font-size: 0.8125rem;
  color: var(--color-warning);
}

/* ─── Responsive général ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .page {
    padding: var(--space-md) var(--space-sm);
  }
  .form-container {
    padding: var(--space-lg);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .chart-svg-wrapper {
    max-width: 500px;
  }
}
