:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --bg: #0f172a; /* Dark sleek background as default */
  --surface: rgba(30, 41, 59, 0.7);
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --glass: rgba(255, 255, 255, 0.03);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --surface: rgba(255, 255, 255, 0.8);
    --text: #1e293b;
    --text-light: #64748b;
    --border: rgba(0, 0, 0, 0.05);
    --primary-light: rgba(99, 102, 241, 0.1);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(
      at 0% 0%,
      rgba(99, 102, 241, 0.15) 0px,
      transparent 50%
    ),
    radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.1) 0px, transparent 50%);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

header {
  padding: 30px 20px;
  background: transparent;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-light);
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text);
  transform: scale(1.1);
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

main {
  flex: 1;
  padding: 0 20px 140px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.input-card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.input-card:focus-within {
  border-color: rgba(99, 102, 241, 0.4);
}

label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 12px;
  display: block;
}

textarea {
  width: 100%;
  height: 120px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-family: inherit;
  resize: none;
  outline: none;
}

.log-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.log-item {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.log-item:hover {
  transform: translateY(-2px);
}

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

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.log-word {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.log-status {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 100px;
  letter-spacing: 0.05em;
}

.status-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.status-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.sub-steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sub-step {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.sub-step.active {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.sub-step.failed {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

.sub-step.success {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
}

.progress-text {
  font-size: 13px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

.dots::after {
  content: "";
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75% {
    content: "...";
  }
}

.fab-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  padding: 0 20px;
  display: flex;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}

#generate-btn {
  pointer-events: auto;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border: none;
  padding: 18px 40px;
  border-radius: 100px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 20px 40px -12px rgba(99, 102, 241, 0.5);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  justify-content: center;
}

#generate-btn:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 25px 50px -12px rgba(99, 102, 241, 0.6);
}

#generate-btn:active {
  transform: translateY(-2px) scale(0.98);
}

#generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: scale(0.98);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-top-color: var(--primary);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-right-color: transparent;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none;
}

/* --- Stats Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 32px;
  width: 100%;
  max-width: 450px;
  padding: 32px;
  box-shadow: var(--shadow);
  animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 800;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-light);
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.stat-cost {
  font-size: 24px;
  font-weight: 800;
  color: var(--success);
}

.stat-full-width {
  grid-column: span 2;
}

.components-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.component-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 12px 16px;
  background: var(--glass);
  border-radius: 12px;
}

.comp-name {
  font-weight: 600;
  color: var(--text);
}

.comp-val {
  color: var(--text-light);
}

.comp-price {
  font-weight: 700;
  color: var(--text);
}

.error-text {
  font-size: 12px;
  color: var(--error);
  margin-top: 5px;
}

.warning-text {
  font-size: 12px;
  color: var(--warning);
  margin-top: 5px;
}
