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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --text: #e5e5e5;
  --text2: #999;
  --accent: #ff6b35;
  --accent2: #ff8c5a;
  --green: #4ade80;
  --red: #f87171;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.logo {
  font-size: 1.4em;
  font-weight: 700;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.nav-item {
  display: block;
  padding: 12px 20px;
  color: var(--text2);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.95em;
}

.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: var(--surface2); border-right: 3px solid var(--accent); }

.content {
  margin-left: 220px;
  padding: 40px;
  flex: 1;
  max-width: 900px;
}

h1 { font-size: 1.8em; margin-bottom: 5px; }
.subtitle { color: var(--text2); margin-bottom: 25px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

input, textarea, select {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95em;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

button {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

button:hover { background: var(--accent2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.input-group input { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.form-group.inline {
  flex-direction: row;
  flex-wrap: wrap;
}

.form-group.inline input { flex: 1; min-width: 120px; }

.form-group label {
  font-size: 0.85em;
  color: var(--text2);
  margin-bottom: -6px;
}

.result-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-height: 100px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.result-box:empty::before {
  content: 'Kết quả sẽ hiển thị ở đây...';
  color: var(--text2);
}

.result-box .loading {
  color: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Calculator */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.calc-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calc-label { color: var(--text2); font-size: 0.9em; }
.calc-value { font-size: 1.3em; font-weight: 700; }
.calc-card.profit .calc-value { color: var(--green); }

/* Products grid */
.products-grid {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-info h3 { font-size: 1em; margin-bottom: 4px; }
.product-info span { color: var(--text2); font-size: 0.85em; }

.product-actions { display: flex; gap: 8px; align-items: center; }

.product-margin {
  font-weight: 700;
  font-size: 1.1em;
}

.margin-good { color: var(--green); }
.margin-bad { color: var(--red); }

.btn-delete {
  background: transparent;
  color: var(--text2);
  padding: 6px 10px;
  font-size: 0.85em;
}

.btn-delete:hover { color: var(--red); }

/* AI result formatting */
.ai-product {
  background: var(--surface2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.ai-product h3 { color: var(--accent); margin-bottom: 8px; }
.ai-product .detail { color: var(--text2); font-size: 0.9em; margin: 4px 0; }
.ai-product .detail strong { color: var(--text); }

.ad-variation {
  background: var(--surface2);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--accent);
}

.ad-variation h4 { color: var(--accent); margin-bottom: 8px; font-size: 0.85em; }
.ad-hook { font-size: 1.1em; font-weight: 600; margin-bottom: 10px; }
.ad-body { margin-bottom: 10px; color: var(--text2); }
.ad-cta { font-weight: 600; color: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo { font-size: 1.2em; padding: 0 10px 15px; text-align: center; }
  .nav-item { padding: 12px 10px; font-size: 1.1em; text-align: center; overflow: hidden; }
  .content { margin-left: 60px; padding: 20px; }
  .calc-grid { grid-template-columns: 1fr; }
  .input-group { flex-direction: column; }
  .form-group.inline { flex-direction: column; }
}
