/* =========================================================
   PromptESG Competition Platform — Global Styles
   v2.0.0 | Primary: #2D6A4F | Accent: #F4A261
   ========================================================= */

:root {
  --primary: #2D6A4F;
  --primary-dark: #1B4332;
  --primary-light: #52B788;
  --secondary: #40916C;
  --accent: #F4A261;
  --accent-dark: #E76F51;
  --bg: #F8F9FA;
  --white: #ffffff;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffc107;
  --info: #17a2b8;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
  --radius: 0.5rem;
  --radius-lg: 1rem;
  --transition: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== NAVBAR ===== */
.navbar {
  background: var(--white);
  border-bottom: 2px solid var(--primary-light);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}
.navbar-brand {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar-nav { display: flex; align-items: center; gap: 0.75rem; }
.navbar-user { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--gray-600); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--primary); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }
.btn-ghost { background: transparent; color: var(--gray-600); border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-weight: 700; font-size: 1rem; color: var(--gray-800); }
.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--gray-100); background: var(--gray-100); }

/* ===== FORM ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 600; font-size: 0.875rem; color: var(--gray-700); margin-bottom: 0.4rem; }
.form-control {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(82,183,136,0.15); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-primary { background: rgba(45,106,79,0.12); color: var(--primary); }
.badge-success { background: rgba(40,167,69,0.12); color: var(--success); }
.badge-warning { background: rgba(255,193,7,0.15); color: #856404; }
.badge-danger { background: rgba(220,53,69,0.12); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-accent { background: rgba(244,162,97,0.15); color: var(--accent-dark); }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  padding: 1.5rem 0;
  flex-shrink: 0;
}
.sidebar-nav { list-style: none; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.5rem;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--gray-100); color: var(--primary); }
.sidebar-link.active { background: rgba(45,106,79,0.08); color: var(--primary); border-left-color: var(--primary); font-weight: 700; }
.main-content { flex: 1; padding: 1.5rem; overflow-x: hidden; }

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 900; color: var(--primary); }
.stat-label { font-size: 0.82rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ===== TABLES ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { background: var(--gray-100); padding: 0.75rem 1rem; text-align: left; font-weight: 700; color: var(--gray-700); border-bottom: 2px solid var(--gray-200); }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tr:hover td { background: var(--gray-100); }

/* ===== PROGRESS STEPS ===== */
.progress-steps { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 1rem 0; }
.step-item { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; flex: 1; min-width: 70px; }
.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  transition: var(--transition);
}
.step-circle.done { background: var(--success); color: white; }
.step-circle.active { background: var(--primary); color: white; }
.step-label { font-size: 0.72rem; color: var(--gray-500); text-align: center; }
.step-label.done { color: var(--success); }
.step-label.active { color: var(--primary); font-weight: 700; }
.step-connector { flex: 1; height: 2px; background: var(--gray-200); min-width: 20px; }
.step-connector.done { background: var(--success); }

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--secondary) 100%);
  color: white;
  padding: 5rem 1.5rem;
  text-align: center;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 0.4rem 1.25rem;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255,255,255,0.3);
}
.hero-title { font-size: 3rem; font-weight: 900; margin-bottom: 1rem; }
.hero-subtitle { font-size: 1.1rem; opacity: 0.9; max-width: 600px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ===== FLOW STEPS ===== */
.flow-steps { display: flex; justify-content: center; gap: 0; flex-wrap: wrap; padding: 2rem 0; }
.flow-step { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 1rem; min-width: 120px; }
.flow-step:not(:last-child)::after { content: '→'; color: var(--gray-400); font-size: 1.5rem; align-self: center; position: relative; top: -1rem; }
.flow-icon { width: 60px; height: 60px; background: linear-gradient(135deg, var(--primary), var(--secondary)); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; }
.flow-label { font-size: 0.82rem; font-weight: 700; color: var(--gray-700); text-align: center; }

/* ===== COMPANY CARDS ===== */
.companies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5rem; }
.company-card { background: white; border: 2px solid var(--gray-200); border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; cursor: pointer; transition: var(--transition); }
.company-card:hover { border-color: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.company-card.selected { border-color: var(--primary); background: rgba(45,106,79,0.05); }
.company-logo { width: 64px; height: 64px; border-radius: var(--radius); background: var(--primary); color: white; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 0.75rem; }

/* ===== QUIZ OPTIONS ===== */
.quiz-option {
  padding: 1rem 1.25rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.quiz-option:hover { border-color: var(--primary-light); background: rgba(82,183,136,0.05); }
.quiz-option.selected { border-color: var(--primary); background: rgba(45,106,79,0.08); }
.quiz-option.correct { border-color: var(--success); background: rgba(40,167,69,0.1); }
.quiz-option.wrong { border-color: var(--danger); background: rgba(220,53,69,0.1); }
.option-letter { width: 32px; height: 32px; border-radius: 50%; background: var(--gray-200); color: var(--gray-600); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.quiz-option.correct .option-letter { background: var(--success); color: white; }
.quiz-option.wrong .option-letter { background: var(--danger); color: white; }

/* ===== PROMPT BUILDER ===== */
.prompt-section {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.prompt-section-title { font-size: 0.8rem; font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== SLOGAN CARDS ===== */
.slogan-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}
.slogan-card:hover { border-color: var(--accent); }
.slogan-card.selected { border-color: var(--accent); background: rgba(244,162,97,0.05); }
.slogan-text { font-size: 1.3rem; font-weight: 700; color: var(--gray-800); text-align: center; }

/* ===== ITERATION HISTORY ===== */
.iteration-thumb { width: 60px; height: 60px; border-radius: var(--radius); object-fit: cover; border: 2px solid var(--gray-200); cursor: pointer; transition: var(--transition); }
.iteration-thumb:hover { border-color: var(--primary); }

/* ===== KNOWLEDGE LIST ===== */
.knowledge-list { list-style: none; }
.knowledge-item {
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: var(--transition);
}
.knowledge-item:hover { background: var(--gray-100); }
.knowledge-item.active { background: rgba(45,106,79,0.08); color: var(--primary); font-weight: 700; }
.knowledge-item.completed { color: var(--success); }
.knowledge-num { width: 24px; height: 24px; border-radius: 50%; background: var(--gray-200); color: var(--gray-600); font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.knowledge-item.completed .knowledge-num { background: var(--success); color: white; }
.knowledge-item.active .knowledge-num { background: var(--primary); color: white; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 80px; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: slideIn 0.3s ease;
  max-width: 320px;
  font-size: 0.875rem;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== DEMO BADGE ===== */
.demo-badge {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: rgba(244,162,97,0.95);
  color: white;
  padding: 0.4rem 1rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  z-index: 9000;
}

/* ===== SPINNER ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== LANG SWITCHER ===== */
.lang-switcher { position: relative; display: inline-flex; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  background: rgba(45,106,79,0.08);
  border: 1.5px solid rgba(45,106,79,0.2);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.lang-btn:hover { background: rgba(45,106,79,0.15); }
.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  z-index: 999;
}
.lang-switcher:hover .lang-dropdown, .lang-dropdown:hover { display: block; }
.lang-option { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.875rem; cursor: pointer; font-size: 0.875rem; transition: var(--transition); }
.lang-option:hover { background: var(--gray-100); }
.lang-option.active { color: var(--primary); font-weight: 700; }
.lang-flag { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; }

/* ===== CHAT (AI Tutor) ===== */
.chat-container { display: flex; flex-direction: column; height: 400px; border: 1.5px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.chat-message { max-width: 85%; padding: 0.6rem 0.9rem; border-radius: var(--radius); font-size: 0.875rem; line-height: 1.5; }
.chat-message.user { align-self: flex-end; background: var(--primary); color: white; border-radius: var(--radius) var(--radius) 0 var(--radius); }
.chat-message.ai { align-self: flex-start; background: var(--gray-100); color: var(--gray-800); border-radius: 0 var(--radius) var(--radius) var(--radius); }
.chat-input-row { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--gray-200); }

/* ===== UTILS ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.section { padding: 3rem 0; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 1rem; } .mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; } .text-right { text-align: right; }
.text-primary { color: var(--primary); } .text-accent { color: var(--accent); } .text-danger { color: var(--danger); } .text-success { color: var(--success); } .text-gray { color: var(--gray-500); }
.font-bold { font-weight: 700; } .font-900 { font-weight: 900; }
.hidden { display: none; }
.flex { display: flex; } .flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }
.sticky-bar { position: sticky; bottom: 0; background: white; border-top: 1px solid var(--gray-200); padding: 1rem 1.5rem; box-shadow: 0 -4px 16px rgba(0,0,0,0.08); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hero-title { font-size: 2rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--gray-200); padding: 0.5rem 0; }
  .sidebar-nav { display: flex; overflow-x: auto; gap: 0; }
  .sidebar-link { white-space: nowrap; padding: 0.6rem 1rem; border-left: none; border-bottom: 3px solid transparent; }
  .sidebar-link.active { border-left-color: transparent; border-bottom-color: var(--primary); }
  .hero-actions { flex-direction: column; align-items: center; }
}
