/* ============================================================
   Trade Tools Hub — Custom Styles
   Tailwind handles layout/spacing; this file handles
   component-level tokens and non-utility patterns.
   ============================================================ */

/* ---------- Global ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* Smooth theme transitions — applies on every element so toggle feels intentional */
*, *::before, *::after {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---------- Calculator Inputs ---------- */
.calc-input {
  width: 100%;
  background: #0f172a;               /* slate-950 */
  border: 1px solid #1e293b;         /* slate-800 */
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  color: #e2e8f0;                     /* slate-200 */
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.calc-input:focus {
  border-color: #22c55e;             /* emerald-500 */
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.calc-input:hover:not(:focus) {
  border-color: #334155;             /* slate-700 */
}

/* Number input — hide spin buttons */
.calc-input[type="number"]::-webkit-outer-spin-button,
.calc-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.calc-input[type="number"] { -moz-appearance: textfield; }

/* Select styling */
select.calc-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* Input with addon (currency prefix / percent suffix) */
.input-with-addon {
  display: flex;
  align-items: stretch;
}

.input-with-addon .addon-select {
  background: #1e293b;
  border: 1px solid #1e293b;
  border-right: none;
  border-radius: 0.5rem 0 0 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  min-width: 68px;
  text-align: center;
}

.input-with-addon .addon-select:focus {
  border-color: #22c55e;
}

.input-with-addon .calc-input.with-addon {
  border-radius: 0 0.5rem 0.5rem 0;
  border-left: 1px solid #334155;
}

.input-with-addon .addon-suffix {
  background: #1e293b;
  border: 1px solid #1e293b;
  border-left: none;
  border-radius: 0 0.5rem 0.5rem 0;
  padding: 0.625rem 0.875rem;
  font-size: 0.85rem;
  color: #64748b;
  display: flex;
  align-items: center;
  user-select: none;
}

/* Static text prefix (for drawdown $) */
.addon-prefix {
  background: #1e293b;
  border: 1px solid #1e293b;
  border-right: none;
  border-radius: 0.5rem 0 0 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  color: #64748b;
  display: flex;
  align-items: center;
  user-select: none;
}

.input-with-addon .calc-input:not(.with-addon) {
  border-radius: 0.5rem 0 0 0.5rem;
  flex: 1;
}

/* Input group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #94a3b8;                    /* slate-400 */
  letter-spacing: 0.01em;
}

.input-hint {
  font-size: 0.7rem;
  color: #475569;                    /* slate-600 */
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #22c55e;              /* emerald-500 */
  color: #052e16;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
}

.btn-primary:hover {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.btn-secondary:hover {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
}

.btn-secondary:active { transform: scale(0.97); }

/* Small button variant */
.btn-xs {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
}

/* ---------- Keyboard shortcut hint ---------- */
.kbd-hint {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.6rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 0.25rem;
  padding: 0.1rem 0.35rem;
  color: rgba(5, 46, 22, 0.75);
  margin-left: 0.125rem;
  vertical-align: middle;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ---------- Result Stats ---------- */
.stat-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.625rem;
  padding: 0.875rem 1rem;
}

.stat-label {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 600;
}

/* ---------- Scenario Comparison Table ---------- */
.scenario-table {
  font-size: 0.8rem;
  border-collapse: collapse;
  width: 100%;
}

.scenario-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e293b;
  background: #0f172a;
}

.scenario-table td {
  padding: 0.5rem 0.75rem;
  color: #cbd5e1;
  border-bottom: 1px solid #1e293b;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.scenario-table tr:last-child td { border-bottom: none; }

.scenario-table tr:hover td { background: #1e293b40; }

.scenario-table .scenario-active td {
  background: rgba(34, 197, 94, 0.06);
}

/* Scenario custom % input */
.scenario-input {
  width: 70px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  color: #e2e8f0;
  outline: none;
  -moz-appearance: textfield;
  text-align: center;
}
.scenario-input::-webkit-outer-spin-button,
.scenario-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.scenario-input:focus { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.12); }

/* ---------- Drawdown Chart ---------- */
.dd-chart {
  min-height: 140px;
  display: block;
}

/* ---------- News Cards ---------- */
.news-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.625rem;
  padding: 0.875rem 1rem;
  transition: border-color 0.15s, background 0.15s;
}

.news-card:hover {
  border-color: #334155;
  background: #1e293b;
}

.news-card a {
  text-decoration: none;
}

.news-card a:hover h3 {
  color: #4ade80;
}

.news-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: #cbd5e1;                    /* slate-300 */
  line-height: 1.45;
  margin-bottom: 0.375rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.news-snippet {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: #475569;
}

.news-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Source badge colour tokens */
.source-bbc        { background: #1a1a2e; color: #f87171; }  /* red    */
.source-guardian   { background: #1a2a1a; color: #4ade80; }  /* green  */
.source-ft         { background: #1a1f2e; color: #f59e0b; }  /* amber  */
.source-investing  { background: #1c2f1c; color: #6ee7b7; }  /* teal   */
.source-default    { background: #1e293b; color: #64748b; }  /* grey   */

/* ---------- Scrollable News Panel ---------- */
.news-panel {
  max-height: min(78vh, 720px);
  overflow-y: auto;
}

/* Custom scrollbar for the news panel */
.news-panel::-webkit-scrollbar { width: 4px; }
.news-panel::-webkit-scrollbar-track { background: transparent; }
.news-panel::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }
.news-panel::-webkit-scrollbar-thumb:hover { background: #22c55e; }

.news-panel-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f172a;  /* slate-900 — matches card bg */
}

/* ---------- Filter Chips ---------- */
.filter-chip {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid #334155;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-chip:hover {
  border-color: #475569;
  color: #e2e8f0;
}

.filter-chip.active {
  background: #22c55e;
  border-color: #22c55e;
  color: #052e16;
}

/* ---------- Preset Instrument Pills ---------- */
.preset-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid #334155;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.02em;
  user-select: none;
}

.preset-pill:hover {
  border-color: #22c55e;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.06);
}

.preset-pill.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #4ade80;
  font-weight: 600;
}

/* ---------- Muted kbd variant (for Reset button) ---------- */
.kbd-hint--muted {
  background: rgba(148, 163, 184, 0.05);
  border-color: rgba(148, 163, 184, 0.18);
  color: rgba(148, 163, 184, 0.45);
}

/* ---------- Economic Calendar widget wrapper ---------- */
.calendar-wrapper {
  background: #020617;
  /* No min-height — let the widget set its own height */
}

.calendar-wrapper .tradingview-widget-container {
  width: 100%;
}

/* Loading placeholder shown while the widget script is still running.
   :empty matches before TradingView injects the iframe into __widget. */
.tradingview-widget-container__widget:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #334155;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.tradingview-widget-container__widget:empty::before {
  content: 'Loading economic calendar…';
}

/* Style the mandatory TradingView copyright line to match dark theme */
.tradingview-widget-copyright {
  padding: 0.25rem 1rem 0.5rem;
  font-size: 0.65rem;
}
.tradingview-widget-copyright a,
.tradingview-widget-copyright .blue-text {
  color: #334155 !important;
  text-decoration: none;
}
.tradingview-widget-copyright a:hover {
  color: #475569 !important;
}

/* ---------- Spinning refresh icon ---------- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.spinning { animation: spin 0.8s linear infinite; }

/* ---------- News status dot ---------- */
.dot-live {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

.dot-error { background: #ef4444; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---------- Scrollbar (WebKit) ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ---------- Result animation ---------- */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-animate {
  animation: fadeSlideIn 0.3s ease forwards;
}

/* ---------- Disclaimer ribbon ---------- */
.disclaimer-ribbon {
  font-size: 0.7rem;
  letter-spacing: 0.01em;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 640px) {
  .stat-value { font-size: 0.9rem; }
  #calcResults .text-4xl { font-size: 2rem; }
  .scenario-table th,
  .scenario-table td { padding: 0.4rem 0.5rem; font-size: 0.72rem; }
  /* calendar: no min-height override needed, widget is responsive */
}

/* =============================================================
   LIGHT MODE — html.light overrides
   Dark mode is the default; all values below lift dark → light.
   ============================================================= */

/* ── Page shell ── */
html.light body                          { background: #f0f2f5 !important; color: #1a1a2e; }
html.light header                        { background: rgba(255,255,255,0.97) !important; border-color: #e0e0e0 !important; }
html.light footer                        { background: rgba(255,255,255,0.8) !important; border-color: #e0e0e0 !important; }

/* ── Disclaimer ribbon ── */
html.light .disclaimer-ribbon            { background: #fff8e1 !important; border-color: #f59e0b !important; color: #856404 !important; }

/* ── Nav links ── */
html.light nav a                         { color: #5a6a7a !important; }
html.light nav a:hover                   { color: #1a1a2e !important; background: #f0f2f5 !important; }

/* ── Theme toggle button ── */
html.light #themeToggle                  { color: #5a6a7a !important; }
html.light #themeToggle:hover            { color: #1a1a2e !important; background: #f0f2f5 !important; }

/* ── Cards / panels (bg-slate-900) ── */
html.light .card,
html.light .news-panel                   { background: #ffffff !important; border-color: #e0e0e0 !important; }

/* ── Inner dark bg (bg-slate-950, bg-slate-800/50 etc.) ── */
html.light .stat-card                    { background: #f8f9fa !important; border-color: #e0e0e0 !important; }
html.light .bg-slate-950,
html.light [class*="bg-slate-950"]       { background: #f8f9fa !important; }
html.light .bg-slate-800\/50             { background: #f3f4f6 !important; }

/* ── Section headers (text colors driven by Tailwind utilities) ── */
html.light .text-slate-100              { color: #1a1a2e !important; }
html.light .text-slate-200              { color: #1a1a2e !important; }
html.light .text-slate-300              { color: #2a3a4a !important; }
html.light .text-slate-400              { color: #5a6a7a !important; }
html.light .text-slate-500              { color: #6b7a8a !important; }
html.light .text-slate-600              { color: #8a9aaa !important; }
html.light .text-slate-700              { color: #9aaaba !important; }

/* ── Borders ── */
html.light .border-slate-800            { border-color: #e0e0e0 !important; }
html.light .border-slate-700            { border-color: #d0d7de !important; }

/* ── Calculator inputs ── */
html.light .calc-input                  { background: #ffffff !important; border-color: #d0d7de !important; color: #1a1a2e !important; }
html.light .calc-input:hover:not(:focus){ border-color: #b0b7be !important; }
html.light .calc-input:focus            { border-color: #22c55e !important; }
html.light .addon-select                { background: #f3f4f6 !important; border-color: #d0d7de !important; color: #2a3a4a !important; }
html.light .addon-suffix,
html.light .addon-prefix                { background: #f3f4f6 !important; border-color: #d0d7de !important; color: #6b7a8a !important; }
html.light .input-label                 { color: #2a3a4a !important; }
html.light .input-hint                  { color: #8a9aaa !important; }

/* ── Select dropdowns ── */
html.light select.calc-input            { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235a6a7a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") !important; }

/* ── Pip mode row ── */
html.light #pipModeRow > div            { background: #f3f4f6 !important; border-color: #d0d7de !important; }
html.light #pipModeRow .text-slate-400  { color: #5a6a7a !important; }
html.light #pipModeRow .text-slate-300  { color: #2a3a4a !important; }
html.light #pipModeRow .text-slate-600  { color: #8a9aaa !important; }
html.light #pipModeRow .border-slate-600{ border-color: #d0d7de !important; }

/* ── Preset pills ── */
html.light .preset-pill                 { border-color: #d0d7de !important; color: #5a6a7a !important; }
html.light .preset-pill:hover           { border-color: #22c55e !important; color: #16a34a !important; background: rgba(34,197,94,0.08) !important; }
html.light .preset-pill.active          { border-color: #22c55e !important; color: #16a34a !important; background: rgba(34,197,94,0.12) !important; }

/* ── Scenario input ── */
html.light .scenario-input              { background: #ffffff !important; border-color: #d0d7de !important; color: #1a1a2e !important; }

/* ── Buttons ── */
html.light .btn-secondary               { border-color: #d0d7de !important; color: #5a6a7a !important; }
html.light .btn-secondary:hover         { background: #f3f4f6 !important; color: #1a1a2e !important; border-color: #b0b7be !important; }
html.light .kbd-hint                    { background: rgba(0,0,0,0.07) !important; border-color: rgba(0,0,0,0.12) !important; color: rgba(5,46,22,0.6) !important; }
html.light .kbd-hint--muted             { color: rgba(90,106,122,0.5) !important; }

/* ── Stat cards (emerald primary result) ── */
html.light .bg-emerald-950\/40          { background: rgba(209,250,229,0.5) !important; border-color: #6ee7b7 !important; }

/* ── Scenario table ── */
html.light .scenario-table th           { background: #f8f9fa !important; color: #8a9aaa !important; border-color: #e0e0e0 !important; }
html.light .scenario-table td           { color: #1a1a2e !important; border-color: #e0e0e0 !important; }
html.light .scenario-table tr:hover td  { background: #f3f4f6 !important; }
html.light .scenario-table .scenario-active td { background: rgba(34,197,94,0.06) !important; }

/* ── Drawdown chart container ── */
html.light #ddChartContainer            { background: #f8f9fa; border-color: #e0e0e0; }

/* ── News panel ── */
html.light .news-panel-header           { background: #ffffff !important; border-color: #e0e0e0 !important; }
html.light .news-card                   { background: #f8f9fa !important; border-color: #e8e8e8 !important; }
html.light .news-card:hover             { background: #f0f2f5 !important; border-color: #d0d7de !important; }
html.light .news-title                  { color: #2a3a4a !important; }
html.light .news-snippet                { color: #6b7a8a !important; }
html.light .news-meta                   { color: #8a9aaa !important; }

/* ── Filter chips ── */
html.light .filter-chip                 { border-color: #d0d7de !important; color: #5a6a7a !important; }
html.light .filter-chip:hover           { border-color: #b0b7be !important; color: #1a1a2e !important; }
html.light .filter-chip.active          { background: #22c55e !important; border-color: #22c55e !important; color: #052e16 !important; }

/* ── Source badges — preserve their brand colours in light mode ── */
html.light .source-bbc,
html.light .source-guardian,
html.light .source-ft,
html.light .source-investing,
html.light .source-default              { filter: brightness(1.15) !important; }

/* ── News scrollbar in light ── */
html.light .news-panel::-webkit-scrollbar-thumb { background: #d0d7de; }
html.light .news-panel::-webkit-scrollbar-thumb:hover { background: #22c55e; }

/* ── Calendar wrapper ── */
html.light .calendar-wrapper            { background: #f8f9fa !important; }

/* ── Footer content ── */
html.light .bg-amber-950\/30            { background: #fff8e1 !important; border-color: #f59e0b !important; }
html.light .text-amber-200\/80          { color: #856404 !important; }
html.light .text-amber-300              { color: #b45309 !important; }
