/* =====================================================
   Keyword Analyzer — Professional Dark Theme
   ===================================================== */

:root {
  --bg-primary: #0b0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #1e2740;
  --bg-input: #0f1422;
  --border: #252d40;
  --border-focus: #4f6ef7;
  --text-primary: #e8edf5;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #4f6ef7;
  --accent-hover: #6b87ff;
  --accent-glow: rgba(79, 110, 247, 0.15);
  --buy-color: #f59e0b;
  --buy-bg: rgba(245, 158, 11, 0.08);
  --info-color: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.08);
  --geo-color: #34d399;
  --geo-bg: rgba(52, 211, 153, 0.08);
  --kaz-color: #a78bfa;
  --kaz-bg: rgba(167, 139, 250, 0.08);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

* { margin:0; padding:0; box-sizing:border-box; }
html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* =====================================================
   APP CONTAINER
   ===================================================== */
.app-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

/* =====================================================
   HEADER
   ===================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  font-size: 32px;
  color: var(--accent);
  font-variation-settings: 'FILL' 1;
}
.logo-area h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}
.header-actions {
  display: flex;
  gap: 8px;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn .material-symbols-outlined {
  font-size: 1.1rem;
}

/* =====================================================
   PROGRESS BAR
   ===================================================== */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
  padding: 0 20px;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.step-indicator {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  transition: var(--transition);
}
.step-indicator.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.step-indicator.done {
  background: rgba(79,110,247,0.2);
  color: var(--accent);
  border-color: var(--accent);
}
.step-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  display: none;
}
.step-line {
  width: 50px;
  height: 1.5px;
  background: var(--border);
  flex-shrink: 0;
}
.step-line.done {
  background: var(--accent);
}

@media (min-width: 600px) {
  .step-label { display: block; }
  .step-line { width: 80px; }
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  animation: fadeUp 0.35s ease;
  position: relative;
}
.card-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.card-icon .material-symbols-outlined {
  font-size: 40px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 12px;
  border-radius: 16px;
  font-variation-settings: 'FILL' 1;
}
.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.card-desc {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.card-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

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

/* =====================================================
   INPUTS
   ===================================================== */
.input-group {
  margin-bottom: 16px;
}
.input-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.1);
}
.input::placeholder { color: var(--text-muted); }
.input-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* =====================================================
   STEP CONTENT
   ===================================================== */
.step-content { display: none; }
.step-content.active { display: block; }

/* =====================================================
   LOADING
   ===================================================== */
.card-loading {
  text-align: center;
  padding: 60px 32px;
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-dots {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%,80%,100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* =====================================================
   RESULTS
   ===================================================== */
.result-info-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.result-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.result-info-item .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.result-info-item .value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* KU */
.card-ku {
  text-align: center;
  padding: 32px;
  margin-bottom: 20px;
  border-color: rgba(79, 110, 247, 0.2);
  background: linear-gradient(135deg, rgba(79,110,247,0.06), rgba(79,110,247,0.02));
}
.ku-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.ku-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.ku-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Card Sections */
.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  animation: fadeUp 0.35s ease;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}
.section-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.badge-buy {
  background: var(--buy-bg);
  color: var(--buy-color);
  border: 1px solid rgba(245,158,11,0.2);
}
.badge-info {
  background: var(--info-bg);
  color: var(--info-color);
  border: 1px solid rgba(56,189,248,0.2);
}
.badge-geo {
  background: var(--geo-bg);
  color: var(--geo-color);
  border: 1px solid rgba(52,211,153,0.2);
}
.badge-kaz {
  background: var(--kaz-bg);
  color: var(--kaz-color);
  border: 1px solid rgba(167,139,250,0.2);
}
.badge-beta {
  font-size: 0.65rem;
  background: rgba(167,139,250,0.1);
  color: var(--kaz-color);
  border: 1px solid rgba(167,139,250,0.15);
  margin-left: 6px;
  padding: 2px 8px;
}

/* Keyword Cloud */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: default;
  transition: var(--transition);
}
.keyword-tag:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* =====================================================
   KAZ SECTION
   ===================================================== */
.kaz-input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.kaz-input-group .input {
  flex: 1;
}
.kaz-result-group {
  margin-bottom: 16px;
}
.kaz-letter-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px 0;
}
.kaz-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.kaz-letter-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.kaz-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 36px;
}
.kaz-suggestion {
  padding: 4px 12px;
  background: var(--kaz-bg);
  border: 1px solid rgba(167,139,250,0.1);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--kaz-color);
  cursor: pointer;
  transition: var(--transition);
}
.kaz-suggestion:hover {
  background: rgba(167,139,250,0.15);
  border-color: rgba(167,139,250,0.3);
}
.kaz-empty {
  padding-left: 36px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}
.kaz-loading-bar {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.kaz-loading-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.kaz-loading-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}
.kaz-done-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: var(--radius-sm);
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.kaz-all-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.kaz-all-header h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* =====================================================
   EXPORT
   ===================================================== */
.export-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.section-export {
  border-color: rgba(255,255,255,0.06);
}

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease;
}
.modal-history {
  max-width: 580px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-body {
  overflow-y: auto;
  max-height: 55vh;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  border-color: rgba(34,197,94,0.3);
  color: var(--success);
}
.toast.error {
  border-color: rgba(239,68,68,0.3);
  color: var(--danger);
}

/* =====================================================
   HISTORY
   ===================================================== */
.history-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--accent);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.history-item:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.history-item-body {
  flex: 1;
  min-width: 0;
}
.history-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.history-item-ku {
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 2px;
}
.history-item-del {
  flex-shrink: 0;
  opacity: 0.4;
}
.history-item:hover .history-item-del {
  opacity: 0.8;
}

/* =====================================================
   FOOTER
   ===================================================== */
.app-footer {
  text-align: center;
  padding: 32px 0 0;
  margin-top: 32px;
  border-top: 1px solid var(--border);
}
.app-footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 600px) {
  .app-container { padding: 12px 16px 40px; }
  .card { padding: 24px 20px; }
  .card-section { padding: 18px 16px; }
  .section-header { flex-direction: column; }
  .card-actions { flex-direction: column; }
  .card-actions .btn { width: 100%; justify-content: center; }
  .kaz-input-group { flex-direction: column; }
  .result-info-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .keyword-tag { font-size: 0.78rem; padding: 5px 10px; }
  .ku-title { font-size: 1.15rem; }
  .export-actions { flex-direction: column; }
  .export-actions .btn { width: 100%; justify-content: center; }
}
