/* ═══════════════════════════════════════════
   Stock Analyzer – Dark Theme
   ═══════════════════════════════════════════ */

:root {
  --bg:           #0b0e11;
  --bg-card:      #1a1d26;
  --bg-hover:     #22262f;
  --bg-input:     #13161d;
  --border:       #2a2e3a;
  --text:         #eaecef;
  --text-muted:   #848e9c;
  --accent:       #3b82f6;
  --green:        #00d395;
  --green-dim:    #00d39533;
  --red:          #ff4757;
  --red-dim:      #ff475733;
  --orange:       #ffb347;
  --orange-dim:   #ffb34733;
  --gold:         #f0b90b;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ─── Container ─── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ─── Header ─── */
header {
  text-align: center;
  padding: 3rem 0 2rem;
}

.logo {
  font-size: 3.5rem;
  margin-bottom: .5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: .5rem;
  max-width: 520px;
  margin-inline: auto;
}

/* ─── Badges ─── */
.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.5rem;
}

.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: .35rem .85rem;
  border-radius: 999px;
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Action Section ─── */
#action-section {
  text-align: center;
  padding: 3rem 0;
}

#analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
  padding: 1.1rem 2.8rem;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 20px rgba(59,130,246,.35);
}

#analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(59,130,246,.45);
}

#analyze-btn:active:not(:disabled) {
  transform: translateY(0);
}

#analyze-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.btn-icon { font-size: 1.4rem; }

.hint {
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: 1rem;
}

/* ─── Loading ─── */
#loading-section {
  text-align: center;
  padding: 3rem 0;
  animation: fadeIn .3s ease;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1.2rem;
  animation: spin .8s linear infinite;
}

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

#loading-text {
  color: var(--text-muted);
  font-size: .95rem;
  margin-bottom: 1rem;
}

.progress-bar {
  width: 300px;
  max-width: 80%;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  margin: 0 auto;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 99px;
  transition: width .4s ease;
}

/* ─── Error ─── */
.error-card {
  background: var(--bg-card);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  max-width: 500px;
  margin: 2rem auto;
  animation: fadeIn .3s ease;
}

.error-icon { font-size: 2rem; display: block; margin-bottom: .75rem; }

#error-message {
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  white-space: pre-line;
}

/* ─── Buttons ─── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: .65rem 1.6rem;
  font-size: .9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: .65rem 1.6rem;
  font-size: .9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--text-muted); }

/* ─── Results ─── */
#results-section {
  animation: fadeIn .4s ease;
  padding-top: 1rem;
}

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

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.results-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.results-meta {
  display: flex;
  gap: 1rem;
  font-size: .82rem;
  color: var(--text-muted);
}

/* Stats cards */
.results-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}

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

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

thead { background: var(--bg-hover); }

th {
  padding: .85rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-hover);
}

th.num { text-align: right; }

td {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

tr:hover td { background: rgba(255,255,255,.02); }

td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Symbol link */
.symbol-link {
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}
.symbol-link:hover { text-decoration: underline; }

/* Color helpers */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-orange { color: var(--orange); }

.chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}

.chip-green  { background: var(--green-dim);  color: var(--green); }
.chip-red    { background: var(--red-dim);    color: var(--red); }
.chip-orange { background: var(--orange-dim); color: var(--orange); }

/* Disclaimer */
.disclaimer {
  text-align: center;
  color: var(--text-muted);
  font-size: .78rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ─── Footer ─── */
footer {
  text-align: center;
  padding: 2.5rem 0 1rem;
  color: var(--text-muted);
  font-size: .8rem;
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: fadeIn .25s ease;
}

.modal-content h3 {
  font-size: 1.3rem;
  margin-bottom: .75rem;
}

.modal-content p,
.modal-content li {
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.7;
}

.modal-content ol {
  padding-left: 1.3rem;
  margin: .75rem 0 1.2rem;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  margin-bottom: 1.2rem;
  outline: none;
  transition: border-color .2s;
}

.modal-content input[type="text"]:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  h1 { font-size: 1.8rem; }
  .subtitle { font-size: .92rem; }
  #analyze-btn { padding: .9rem 2rem; font-size: 1.1rem; }
  .results-header { flex-direction: column; }
  table { font-size: .8rem; }
  th, td { padding: .6rem .65rem; }
}

@media (max-width: 480px) {
  .container { padding: 1rem; }
  h1 { font-size: 1.5rem; }
  .badges { gap: .35rem; }
  .badge { font-size: .72rem; padding: .25rem .6rem; }
}
