/* ==========================================================================
   ANIME PODCAST STUDIO - MAIN CSS
   Design System : Style AutoShort.ai & CRM Moderne
   Palette : Noir Obsidienne Mat (#09090b, #0d0d11, #141417, #18181c, #27272a)
   Accents : Jaune Cyber Électrique (#facc15, #fde047, #eab308)
   Typographie : ObelixPro (Titres), Plus Jakarta Sans & JetBrains Mono
   Exclusion stricte : AUCUNE nuance de rose sur toute l'interface.
   ========================================================================== */

/* Police manga/comic ObelixPro (identique à Sukishort / AutoAMV) */
@font-face {
  font-family: 'ObelixPro';
  src: url('../assets/fonts/ObelixPro.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Palette Noir Obsidienne Mat (AutoShort) */
  --bg-abyss: #09090b;
  --bg-darker: #0d0d11;
  --bg-surface: #141417;
  --bg-card: #18181c;
  --bg-card-hover: #222228;
  --bg-input: #101014;
  
  /* Bordures et Lignes Précises */
  --border-subtle: #27272a;
  --border-highlight: #3f3f46;
  --border-gold: rgba(250, 204, 21, 0.45);
  
  /* Accents Jaune Cyber (AutoShort) */
  --gold-primary: #facc15;
  --gold-light: #fde047;
  --gold-dark: #eab308;
  --gold-pale: #fef08a;
  --gold-glow: rgba(250, 204, 21, 0.35);
  --gold-subtle: rgba(250, 204, 21, 0.12);

  /* Statut / Actif (Vert émeraude pour les indicateurs "En Ligne") */
  --accent-emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.15);

  /* Typographie & Couleurs de Texte */
  --font-display: 'ObelixPro', 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: 'JetBrains Mono', "SFMono-Regular", Consolas, Menlo, monospace;

  --text-white: #ffffff;
  --text-primary: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;

  /* Rayons et Ombres CRM */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.8), 0 2px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 22px rgba(250, 204, 21, 0.28);
  --shadow-gold-hover: 0 0 32px rgba(253, 224, 71, 0.5);

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset, Base & Protection Anti-Zoom Mobile */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

html {
  scrollbar-gutter: stable;
}

html, body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  background-color: var(--bg-abyss);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Protection anti-zoom iOS : 16px minimum pour tous les champs */
input, textarea, select, button {
  font-family: inherit;
  font-size: 16px !important;
  touch-action: manipulation;
}

/* ==========================================================================
   STRUCTURE CRM : SIDEBAR GAUCHE (PC) + CONTENU PRINCIPAL
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-abyss);
}

/* ==========================================================================
   SIDEBAR CRM (PC / DESKTOP)
   ========================================================================== */
.crm-sidebar {
  width: 260px;
  background-color: var(--bg-darker);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  z-index: 90;
}

.crm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding: 0 8px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  -webkit-text-stroke: 1px #070b14;
  text-shadow: 1.5px 1.5px 0 #070b14;
}

.brand-title span {
  color: var(--gold-primary);
  -webkit-text-stroke: 1px #070b14;
  text-shadow: 1.5px 1.5px 0 #070b14, 0 0 14px var(--gold-glow);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--gold-primary);
  color: #000000;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.crm-sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 0 8px;
}

.crm-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.crm-sidebar-nav .crm-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.crm-sidebar-nav .crm-nav-link svg {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.crm-sidebar-nav .crm-nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-white);
}

.crm-sidebar-nav .crm-nav-link:hover svg {
  color: var(--gold-primary);
}

.crm-sidebar-nav .crm-nav-link.active {
  background: var(--gold-primary);
  color: #000000;
  font-weight: 700;
  box-shadow: 0 0 16px var(--gold-glow);
}

.crm-sidebar-nav .crm-nav-link.active svg {
  color: #000000;
}

.crm-sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.crm-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ==========================================================================
   CONTENU PRINCIPAL
   ========================================================================== */
.crm-main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: radial-gradient(circle at 50% 0%, rgba(250, 204, 21, 0.03) 0%, rgba(13, 13, 17, 0.98) 60%, var(--bg-abyss) 100%);
}

/* ==========================================================================
   TOP HEADER BAR - AUTOPOD STUDIO (Desktop & Mobile)
   Design System moderne : Style sukishort / autoamv / AutoShort
   ========================================================================== */
.app-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(60px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
  padding-bottom: 0;
  background-color: #09090b !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.header-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  transition: transform var(--transition-fast);
}

.header-logo:hover {
  transform: scale(1.08);
}

.header-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  color: var(--text-white);
  line-height: 1;
  text-transform: uppercase;
  -webkit-text-stroke: 1px #070b14;
  text-shadow: 1.5px 1.5px 0 #070b14;
}

.header-title .gold-text {
  color: var(--gold-primary);
  -webkit-text-stroke: 1px #070b14;
  text-shadow: 1.5px 1.5px 0 #070b14, 0 0 12px var(--gold-glow);
}

.header-badge {
  display: inline-flex;
  align-items: center;
  background: var(--gold-subtle);
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-subtle);
}

.header-tagline {
  font-family: var(--font-main);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.header-meta-item .meta-label {
  color: var(--text-dim);
}

.header-meta-item .meta-value {
  color: var(--gold-light);
  font-weight: 600;
}

/* Layout en grille du Studio */
.studio-main {
  flex: 1;
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1680px;
  margin: 0 auto;
  width: 100%;
}

.config-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Cartes CRM AutoShort */
.studio-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
  position: relative;
}

.studio-card:hover {
  border-color: var(--border-highlight);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title svg {
  color: var(--gold-primary);
  width: 18px;
  height: 18px;
}

/* Footer CRM */
.app-footer {
  padding: 16px 24px;
  background-color: var(--bg-darker);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.app-footer a {
  color: var(--gold-light);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   SYSTÈME DE PAGES SPA (Show/Hide)
   ========================================================================== */
.crm-page {
  display: none;
  flex: 1;
}

.crm-page.active {
  display: block;
}

/* Header de page (Mascottes, Historique, Paramètres) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 0;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-white);
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   PAGE MASCOTTES - Grille complète
   ========================================================================== */
.mascots-full-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 20px 24px 24px;
}

.mascot-full-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.mascot-full-card:hover {
  border-color: var(--border-highlight);
  transform: translateY(-2px);
}

.mascot-full-card.selected {
  border-color: var(--gold-primary);
  box-shadow: 0 0 20px var(--gold-glow);
}

.mascot-full-thumb {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mascot-full-thumb img,
.mascot-full-thumb svg {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.mascot-full-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-white);
  text-align: center;
}

.mascot-full-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.mascot-stat-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gold-subtle);
  color: var(--gold-primary);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.mascot-full-card .btn-delete-mascot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.mascot-full-card .btn-delete-mascot:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* ==========================================================================
   PAGE SUJETS VIDÉO - Liste dynamique type "base de données"
   ========================================================================== */
.topics-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px 12px;
}

.topics-db-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 24px 24px;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topic-row:hover {
  border-color: var(--border-gold);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.topic-cover {
  width: 64px;
  height: 90px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.topic-rank {
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.topic-row-content {
  flex: 1;
  min-width: 0;
}

.topic-row-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-row-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-row-badges {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.topic-badge-score {
  background: var(--gold-subtle);
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
}

.topic-badge-trend {
  background: var(--emerald-subtle);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.topic-badge-neutral {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.topic-row-action {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .topic-row {
    flex-wrap: wrap;
  }
  .topic-rank {
    width: auto;
  }
  .topic-row-content {
    flex: 1 1 auto;
    min-width: 0;
  }
  .topic-row-title {
    white-space: normal;
  }
  .topic-row-action {
    flex: 1 0 100%;
  }
  .topic-row-action .btn {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.8rem;
  }
}

.mascot-default-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface);
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   PAGE HISTORIQUE
   ========================================================================== */
.history-list {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-entry {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: border-color var(--transition-fast);
}

.history-entry:hover {
  border-color: var(--border-highlight);
}

.history-entry-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-entry-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-entry-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.history-entry-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--gold-subtle);
  color: var(--gold-primary);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text-dim);
  text-align: center;
}

.empty-state svg {
  color: var(--text-dim);
  opacity: 0.4;
}

/* ==========================================================================
   PAGE PARAMÈTRES - Console de Logs
   ========================================================================== */
#page-settings .studio-card {
  margin: 0 24px 20px;
}

#page-settings .studio-card:first-of-type {
  margin-top: 20px;
}

.logs-console {
  background: var(--bg-abyss);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(39, 39, 42, 0.3);
  word-break: break-all;
}

.log-entry.log-info {
  color: var(--text-muted);
}

.log-entry.log-warn {
  color: #facc15;
}

.log-entry.log-error {
  color: #ef4444;
  font-weight: 600;
}

/* Barre de navigation mobile du bas (par défaut masquée sur PC) */
.mobile-bottom-nav {
  display: none;
}
