/* =============================================
   Feature Flag Playground — Styles
   Theme: Dark mode, Sunset Orange  
   ============================================= */

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

:root {
  --primary: #E67E22;
  --primary-dim: rgba(230, 126, 34, 0.12);
  --primary-glow: rgba(230, 126, 34, 0.3);
  --secondary: #F39C12;
  --bg: #1A0E00;
  --bg-card: #231400;
  --bg-input: #1A0E00;
  --bg-hover: #2D1A05;
  --border: rgba(230, 126, 34, 0.15);
  --border-focus: rgba(230, 126, 34, 0.5);
  --text: #F0E6D8;
  --text-dim: #A89478;
  --text-muted: #6B5A44;
  --green: #2ECC71;
  --green-dim: rgba(46, 204, 113, 0.12);
  --red: #E74C3C;
  --red-dim: rgba(231, 76, 60, 0.12);
  --blue: #3498DB;
  --blue-dim: rgba(52, 152, 219, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 0.2s ease;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(230, 126, 34, 0.04), transparent 60%);
  pointer-events: none;
}

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  background: rgba(26, 14, 0, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-dim);
  border-radius: var(--radius);
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.header-actions {
  display: flex;
  gap: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #D35400);
  color: #1A0E00;
  font-weight: 600;
}
.btn-primary:hover { box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--primary); background: var(--primary-dim); }

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

.btn-danger { color: var(--red); border-color: rgba(231,76,60,0.3); }
.btn-danger:hover { background: var(--red-dim); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active { color: var(--primary); background: var(--primary-dim); border-color: rgba(230,126,34,0.2); }

/* Main */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* Panels */
.panel[hidden] { display: none; }
.panel { animation: fadeSlide 0.3s ease; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title { font-size: 1.15rem; font-weight: 700; }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 5px; }
.req { color: var(--red); }
.hint { font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--text-muted); }

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23A89478' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

textarea { resize: vertical; min-height: 60px; }

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--primary-glow);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--text-muted);
  border-radius: 12px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  left: 3px;
  bottom: 3px;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Section label */
.section-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* Flag Cards */
.flag-list, .segment-list { display: flex; flex-direction: column; gap: 8px; }

.flag-card, .seg-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.flag-card:hover, .seg-card:hover { border-color: rgba(230,126,34,0.3); background: var(--bg-hover); }

.flag-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.flag-status.on { background: var(--green); box-shadow: 0 0 8px rgba(46,204,113,0.4); }
.flag-status.off { background: var(--red); opacity: 0.6; }

.flag-info { flex: 1; min-width: 0; }

.flag-key {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
}

.flag-name {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.flag-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.badge {
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-rollout { background: var(--blue-dim); color: var(--blue); }
.badge-segment { background: rgba(155,89,182,0.15); color: #9B59B6; }
.badge-type { background: rgba(230,126,34,0.12); color: var(--primary); }

.flag-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Rule row */
.rule-row {
  display: grid;
  grid-template-columns: 1fr 120px 1fr 30px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.rule-row .btn-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--red);
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
}

.rule-row .btn-remove:hover { background: var(--red-dim); }

/* Evaluate */
.evaluate-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.evaluate-user, .evaluate-results {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.results-grid { display: flex; flex-direction: column; gap: 8px; }

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.result-key {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
}

.result-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
}

.result-value.true { color: var(--green); }
.result-value.false { color: var(--red); }
.result-value.string { color: var(--blue); }

.result-reason {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* A/B Test */
.abtest-container { max-width: 700px; }

.ab-results { margin-top: 20px; }

.ab-chart {
  display: flex;
  height: 36px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
}

.ab-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: white;
  transition: width 0.5s ease;
}

.ab-bar.on { background: linear-gradient(135deg, var(--green), #27ae60); }
.ab-bar.off { background: linear-gradient(135deg, var(--red), #c0392b); }

.ab-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ab-stat {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.ab-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.ab-stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 18px; overflow-y: auto; }

/* Toast */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column-reverse; gap: 8px; }

.toast {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease;
}

.toast.success { border-color: rgba(46,204,113,0.3); }
.toast.error { border-color: rgba(231,76,60,0.3); }

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 768px) {
  .main { padding: 12px; }
  .header-inner { padding: 12px 14px; }
  .header h1 { font-size: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .evaluate-container { grid-template-columns: 1fr; }
  .ab-stats { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .tab { padding: 8px 10px; font-size: 0.78rem; }
  .tab svg { display: none; }
  .flag-card, .seg-card { flex-wrap: wrap; }
  .flag-meta { width: 100%; justify-content: flex-start; margin-top: 8px; }
  .rule-row { grid-template-columns: 1fr; }
}
