@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&display=swap');

:root {
  --primary: #ffd700; /* Or FF14 */
  --secondary: #e3f2fd; /* Bleu clair */
  --accent: #1976d2; /* Bleu FF14 */
  --bg: #fefefe; /* Blanc très clair */
  --card: #ffffff; /* Blanc */
  --border: #ffd700; /* Or */
  --text: #212529; /* Gris foncé pour lisibilité */
  --muted: #6c757d; /* Gris */
  --error: #dc3545; /* Rouge */
  --success: #28a745; /* Vert */
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 16px;
  max-width: 1200px;
  margin: 32px auto;
  background: var(--bg);
  color: var(--text);
  padding: 20px;
  background-image: radial-gradient(circle at 20% 50%, rgba(255, 215, 0, 0.05) 0%, transparent 50%),
                    radial-gradient(circle at 80% 50%, rgba(25, 118, 210, 0.03) 0%, transparent 50%),
                    linear-gradient(135deg, rgba(255, 215, 0, 0.02) 0%, transparent 100%);
  background-attachment: fixed;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1 {
  margin: 0;
  font-size: 32px;
  color: var(--primary);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  font-family: 'Cinzel', serif;
}

.btn {
  padding: 12px 18px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:hover {
  background: var(--primary);
  color: var(--text);
  box-shadow: 0 6px 12px rgba(255, 215, 0, 0.3);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(255, 215, 0, 0.2);
}

.btn.primary {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
  box-shadow: 0 3px 6px rgba(255, 215, 0, 0.3);
}

.btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 6px 12px rgba(25, 118, 210, 0.4);
}

.btn.secondary {
  background: var(--secondary);
  border-color: var(--accent);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--accent);
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 215, 0, 0.1);
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

input[type="text"], input[type="password"], select {
  padding: 12px 14px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

input[type="text"]:focus, input[type="password"]:focus, select:focus {
  outline: none;
  box-shadow: 0 0 8px var(--primary);
}

input[disabled] {
  background: var(--muted);
  color: var(--text);
  cursor: not-allowed;
  opacity: 0.6;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.status {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}

.progress {
  height: 8px;
  background: var(--accent);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 8px;
  border: 1px solid var(--border);
}

.progress > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.3s ease;
}

.result {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.result:hover {
  background: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.1);
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--bg);
  margin-left: 8px;
  font-weight: bold;
}

.badge-msq {
  background: #ffd700; /* Or pour MSQ */
  color: #000; /* Texte noir pour contraste */
}

.badge-side {
  background: #1976d2; /* Bleu pour Side Quests */
}

.badge-class {
  background: #28a745; /* Vert pour Class Quests */
}

.badge-role {
  background: #6f42c1; /* Violet pour Role Quests */
}

.badge-beast {
  background: #8b4513; /* Marron pour Beast Tribe */
}

.badge-expansion {
  background: #17a2b8; /* Cyan pour expansions */
  color: white;
}

.badge-job {
  background: #ffc107; /* Jaune pour jobs */
  color: black;
}

.details {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--primary);
  background: var(--secondary);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 215, 0, 0.1);
}

.quest-summary {
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
}

.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s ease-in-out infinite;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result {
  animation: fadeIn 0.3s ease;
}

.hidden {
  display: none !important;
}

#logs {
  background: var(--card);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  height: 280px;
  overflow-y: auto;
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

dialog {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0;
  width: min(520px, 92vw);
  background: var(--card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

dialog .inner {
  padding: 20px;
}

dialog h3 {
  margin: 0 0 12px 0;
  color: var(--primary);
  font-size: 20px;
}

dialog label div {
  font-size: 16px;
  color: var(--text) !important;
  margin-bottom: 4px;
}

.checkbox {
  color: var(--text);
}

/* Onglets */
.tabs {
  display: flex;
  margin-bottom: 16px;
}

.tab-button {
  padding: 10px 16px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: 'Cinzel', serif;
  transition: all 0.3s ease;
  border-radius: 8px 8px 0 0;
}

.tab-button.active {
  background: var(--primary);
  color: var(--text);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Styles pour les labels et contenu du modal résumé IA */
#summaryDialog strong {
  color: var(--text);
}

#summaryPrompt, #summaryResponse {
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
}

#summaryPrompt {
  display: none;
}

/* Filtres */
.filters-panel {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.filters-panel.collapsed {
  max-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  box-shadow: none;
  overflow: hidden;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
  flex: 1;
  overflow-y: auto;
}

.filter-group {
  display: flex;
  flex-direction: column;
  max-height: 50vh;
  overflow-y: auto;
}

.filter-group label {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group select[size] {
  height: 100%;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}

/* Styles pour les filtres de types avec details/summary */
#type-filter details {
  margin-bottom: 8px;
}

#type-filter summary {
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 0;
}

#type-filter .type-options {
  margin-left: 16px;
  margin-top: 4px;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
}

#type-filter label {
  cursor: pointer;
  padding: 2px 0;
}

#type-filter input[type="checkbox"] {
  margin-right: 6px;
}

#filterType {
  max-height: 70vh;
  overflow-y: auto;
}

.level-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-range input {
  width: 60px;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}

.filter-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-shrink: 0;
}

.filter-actions .btn {
  min-width: 120px;
  font-size: 14px;
}

/* Styles pour la modale de détails de quête */
#questDetailDialog {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

#questDetailDialog .inner {
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
}

#questDetailHeader h2 {
  margin: 0 0 16px 0;
  color: var(--primary);
  font-size: 24px;
  font-family: 'Cinzel', serif;
}

#questDetailMeta {
  font-size: 14px;
  color: var(--muted);
}

.quest-section {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.quest-section h3 {
  margin: 0 0 12px 0;
  color: var(--primary);
  font-size: 18px;
  font-family: 'Cinzel', serif;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.quest-section p {
  margin: 8px 0;
  line-height: 1.6;
}

.quest-section ul {
  margin: 8px 0;
  padding-left: 20px;
}

.quest-section li {
  margin: 4px 0;
  line-height: 1.5;
}

.quest-link {
  background: var(--secondary) !important;
  border-color: var(--accent) !important;
  color: var(--text) !important;
  font-size: 14px !important;
  padding: 6px 12px !important;
  margin: 2px !important;
  transition: all 0.2s ease !important;
}

.quest-link:hover {
  background: var(--accent) !important;
  color: white !important;
  transform: translateY(-1px) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
    margin: 16px auto;
    font-size: 14px;
  }

  h1 {
    font-size: 28px;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    padding: 10px 14px;
    font-size: 14px;
  }

  .card {
    padding: 12px;
  }

  .filters-panel {
    padding: 12px;
  }

  .tab-button {
    padding: 8px 12px;
    font-size: 14px;
  }

  dialog {
    width: 95vw;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .filter-actions {
    flex-direction: column;
  }

  .filter-actions .btn {
    min-width: auto;
  }
}