/* =================================================================
   stock.css — The Compound Family v1.0
   Styles for stock.html only.
   Requires theme.css to be loaded first.
================================================================= */

/* ═══════════════════════════════════════════════════════════════
   1. PAGE LAYOUT
═══════════════════════════════════════════════════════════════ */

.stock-wrap {
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ═══════════════════════════════════════════════════════════════
   2. SEARCH BAR
═══════════════════════════════════════════════════════════════ */

.search-section {
  padding: 32px 0 24px;
}

.search-form {
  display: flex;
  gap: 12px;
  max-width: 480px;
}

.search-input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: border-color 0.2s;
  outline: none;
}

.search-input::placeholder {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text3);
  font-weight: 400;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-btn {
  height: 48px;
  padding: 0 24px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: var(--body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.search-btn:hover { opacity: 0.88; }
.search-btn:active { opacity: 0.75; transform: scale(0.98); }

/* ═══════════════════════════════════════════════════════════════
   3. COMPANY HEADER
═══════════════════════════════════════════════════════════════ */

.company-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

/* Верхняя строка: logo + info + price */
.company-header-top {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
}

.company-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  object-fit: contain;
  padding: 4px;
  flex-shrink: 0;
}

.company-logo-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text2);
  flex-shrink: 0;
}

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

.company-name {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.2;
}

.company-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.company-ticker {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 5px;
}

.company-sector {
  font-size: 13px;
  color: var(--text2);
}

.company-exchange {
  font-size: 12px;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 4px;
}

.company-price-block {
  text-align: right;
  flex-shrink: 0;
}

/* Описание компании — разворачивается по клику */
.company-description {
  margin-top: 16px;
  width: 100%;
}

.company-description details {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.company-description summary {
  cursor: pointer;
  list-style: none;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  user-select: none;
}

.company-description summary::-webkit-details-marker { display: none; }

.company-description summary .desc-preview {
  display: inline;
}

/* Когда details открыт — скрываем preview, показываем только полный текст */
.company-description details[open] summary .desc-preview {
  display: none;
}

.company-description summary .desc-toggle {
  color: var(--accent);
  font-size: 12px;
  margin-left: 4px;
  white-space: nowrap;
}

.company-description details[open] summary .desc-toggle::after {
  content: ' Show less';
}

.company-description details:not([open]) summary .desc-toggle::after {
  content: ' Read more ↓';
}

.company-description .desc-full {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.company-price {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.company-change {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.company-change.positive { color: var(--green); }
.company-change.negative { color: var(--red);   }

/* ═══════════════════════════════════════════════════════════════
   4. OVERALL SCORE (top of page)
═══════════════════════════════════════════════════════════════ */

.overall-score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.overall-score-left {
  flex-shrink: 0;
}

.overall-score-num {
  font-family: var(--mono);
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
}

.overall-score-num.score-green { color: var(--green); }
.overall-score-num.score-amber { color: var(--amber); }
.overall-score-num.score-red   { color: var(--red);   }

.overall-score-max {
  font-size: 16px;
  color: var(--text3);
  font-family: var(--mono);
}

.overall-score-right {
  flex: 1;
}

.overall-score-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.overall-score-desc {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 12px;
}

.overall-track {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.overall-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.overall-fill.score-green { background: var(--green); }
.overall-fill.score-amber { background: var(--amber); }
.overall-fill.score-red   { background: var(--red);   }

/* ═══════════════════════════════════════════════════════════════
   5. SECTION CARDS
═══════════════════════════════════════════════════════════════ */

/* ── Sector Warning ────────────────────────────────────────── */
.sector-warning {
  background: linear-gradient(135deg, var(--surface2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.sector-warning-content {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.sector-warning-icon { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.sector-warning-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.sector-warning-text { font-size: 13px; color: var(--text2); line-height: 1.6; }
.sector-warning-cta { font-size: 13px; color: var(--text2); margin: 0 0 10px 0; }
.sw-form-row { display: flex; gap: 8px; max-width: 480px; }
.sw-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.sw-input:focus { border-color: var(--accent); }
.sw-input::placeholder { color: var(--text3); }
.sw-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.sw-btn:hover { opacity: 0.85; }
.sw-privacy { font-size: 11px; color: var(--text3); margin: 8px 0 0 0; }

.stock-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 20px;
  overflow: hidden;
}

.stock-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.stock-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stock-section-icon {
  font-size: 16px;
}

.stock-section-question {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

.stock-section-body {
  padding: 20px 24px;
}

/* ═══════════════════════════════════════════════════════════════
   6. METRIC CARDS GRID
═══════════════════════════════════════════════════════════════ */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.15s;
}

.metric-card:hover {
  border-color: var(--border2);
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tooltip иконка ⓘ рядом с названием метрики */
.metric-tip {
  font-size: 10px;
  color: var(--text3);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  text-transform: none;
  letter-spacing: 0;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.metric-tip:hover {
  opacity: 1;
  color: var(--accent);
}

/* Глобальный tooltip popup — показывается при hover/tap на ⓘ */
#tcf-tooltip {
  position: absolute;
  z-index: 9999;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  max-width: 280px;
}

#tcf-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.metric-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 8px;
}

.metric-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-sub {
  font-size: 11px;
  color: var(--text3);
}

/* ═══════════════════════════════════════════════════════════════
   7. BADGES
═══════════════════════════════════════════════════════════════ */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-green   { background: var(--accent-dim);  color: var(--accent); border: 1px solid var(--accent-border); }
.badge-amber   { background: var(--amber-dim);   color: var(--amber);  border: 1px solid var(--amber-border);  }
.badge-red     { background: var(--red-dim);     color: var(--red);    border: 1px solid var(--red-border);    }
.badge-neutral { background: var(--surface2);    color: var(--text3);  border: 1px solid var(--border);        }
.badge-blue    { background: var(--blue-dim);    color: var(--blue);   border: 1px solid var(--blue-border);   }

/* ═══════════════════════════════════════════════════════════════
   8. SCORE BAR
═══════════════════════════════════════════════════════════════ */

.score-bar-wrap {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.score-bar-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.score-emoji { font-size: 16px; }

.score-number {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
}

.score-number.score-green { color: var(--green); }
.score-number.score-amber { color: var(--amber); }
.score-number.score-red   { color: var(--red);   }

.score-slash {
  font-size: 14px;
  color: var(--text3);
  font-family: var(--mono);
}

.score-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-fill-green { background: var(--green); }
.score-fill-amber { background: var(--amber); }
.score-fill-red   { background: var(--red);   }

.score-label {
  font-size: 12px;
  font-weight: 500;
}

.score-label-green { color: var(--green); }
.score-label-amber { color: var(--amber); }
.score-label-red   { color: var(--red);   }

/* ═══════════════════════════════════════════════════════════════
   9. SECTION SUMMARY (stop/go signal)
═══════════════════════════════════════════════════════════════ */

.section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 10px;
  margin-top: 20px;
  gap: 16px;
}

.section-summary-green { background: var(--accent-dim); border: 1px solid var(--accent-border); }
.section-summary-amber { background: var(--amber-dim);  border: 1px solid var(--amber-border);  }
.section-summary-red   { background: var(--red-dim);    border: 1px solid var(--red-border);    }

.ss-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.ss-signal {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.section-summary-green .ss-signal { color: var(--green); }
.section-summary-amber .ss-signal { color: var(--amber); }
.section-summary-red   .ss-signal { color: var(--red);   }

.ss-text {
  font-size: 13px;
  color: var(--text2);
}

.ss-score {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.ss-max {
  font-size: 13px;
  color: var(--text3);
}

/* ═══════════════════════════════════════════════════════════════
   10. CHARTS
═══════════════════════════════════════════════════════════════ */

.chart-wrap {
  position: relative;
  height: 220px;
  margin-bottom: 8px;
}

.chart-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 10px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
  margin-bottom: 20px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-legend-label { font-size: 12px; }

.chart-empty {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════
   11. VALUATION TABLE
═══════════════════════════════════════════════════════════════ */

.valuation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.valuation-table thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}

.valuation-table thead th:not(:first-child) {
  text-align: right;
}

.valuation-row td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.valuation-row:last-child td { border-bottom: none; }

.val-label   { color: var(--text2); font-weight: 500; }
.val-current { text-align: right; font-family: var(--mono); font-weight: 600; color: var(--text); }
.val-avg     { text-align: right; font-family: var(--mono); color: var(--text3); }
.val-vs      { text-align: right; font-family: var(--mono); font-size: 12px; }
.val-above   { color: var(--red);   }
.val-below   { color: var(--green); }
.val-verdict { text-align: right; }

/* ═══════════════════════════════════════════════════════════════
   12. PIOTROSKI BREAKDOWN
═══════════════════════════════════════════════════════════════ */

.piotroski-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.piotroski-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.piotroski-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  margin-bottom: 4px;
}

.piotroski-factor {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.p-pass { border-color: var(--accent-border); background: var(--accent-dim); }
.p-fail { border-color: var(--red-border);    background: var(--red-dim);    }

.p-icon {
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
  width: 16px;
}

.p-pass .p-icon { color: var(--green); }
.p-fail .p-icon { color: var(--red);   }
.p-unknown .p-icon { color: var(--text3); }

.p-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.p-desc {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
  display: block;
}

/* ═══════════════════════════════════════════════════════════════
   13. LOADING & ERROR STATES
═══════════════════════════════════════════════════════════════ */

.state-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text2);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.state-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  color: var(--red);
  font-size: 14px;
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  border-radius: 10px;
  margin: 16px 0;
}

.state-error-icon { font-size: 18px; }

.state-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════
   14. AI ANALYSIS SECTION
═══════════════════════════════════════════════════════════════ */

.ai-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 20px;
  overflow: hidden;
}

.ai-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.ai-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-btn {
  height: 36px;
  padding: 0 18px;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 8px;
  color: var(--gold);
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-btn:hover {
  background: rgba(212,168,67,0.2);
  border-color: var(--gold);
}

.ai-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-counter {
  font-size: 12px;
  color: var(--text3);
}

.ai-body {
  padding: 20px 24px;
}

.ai-result {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}

.ai-result p {
  margin: 0 0 10px;
}

.ai-result p:last-child { margin-bottom: 0; }

.ai-disclaimer {
  font-size: 11px;
  color: var(--text3);
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   15. DCF LINK BUTTON
═══════════════════════════════════════════════════════════════ */

.dcf-link-card {
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.dcf-link-text {
  font-size: 14px;
  color: var(--text2);
}

.dcf-link-text strong {
  color: var(--text);
  font-weight: 600;
}

.dcf-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  background: var(--accent);
  border-radius: 8px;
  color: #fff;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.dcf-link-btn:hover { opacity: 0.88; }

/* ═══════════════════════════════════════════════════════════════
   16. RESPONSIVE
═══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .stock-wrap { padding: 0 16px 60px; }

  .company-header-top {
    flex-wrap: wrap;
  }

  .company-price-block {
    text-align: left;
    width: 100%;
  }

  .overall-score-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stock-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .valuation-table thead th:nth-child(3),
  .valuation-row td:nth-child(3) {
    display: none;
  }

  .dcf-link-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .ss-score { font-size: 18px; }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-value { font-size: 17px; }

  .company-name { font-size: 20px; }

  .overall-score-num { font-size: 40px; }
}
