/* ============================================================
   MORGEN BRIEFING – Dark Mode Trading Dashboard
   ============================================================ */

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:     #0d1117;
  --bg-card:     #161b22;
  --bg-card2:    #1c2128;
  --bg-hover:    #21262d;
  --border:      #30363d;
  --border-glow: #388bfd33;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --green:       #3fb950;
  --green-dim:   #1a4d2a;
  --green-glow:  #3fb95033;
  --red:         #f85149;
  --red-dim:     #4d1a1a;
  --red-glow:    #f8514933;
  --yellow:      #e3b341;
  --yellow-dim:  #4d3d1a;
  --yellow-glow: #e3b34133;
  --blue:        #58a6ff;
  --blue-dim:    #1a2d4d;
  --purple:      #bc8cff;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg: 12px;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* --- Layout ------------------------------------------------ */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* --- Header ------------------------------------------------ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-brand .logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.header-brand .logo span {
  color: var(--green);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.market-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.open  { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
.status-dot.closed { background: var(--red-dim); border: 1px solid var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.refresh-info { color: var(--text-muted); }
#refresh-countdown { color: var(--blue); font-weight: 600; }

/* --- Grid -------------------------------------------------- */
.main-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto auto 1fr;
  gap: 1rem;
}

.col-left  { grid-column: 1; display: flex; flex-direction: column; gap: 1rem; }
.col-right { grid-column: 2; display: flex; flex-direction: column; gap: 1rem; }
.col-full  { grid-column: 1 / -1; }

/* --- Card -------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.card-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title .material-icons { font-size: 0.95rem; }

/* --- Börsenampel ------------------------------------------- */
.ampel-card {
  text-align: center;
  position: relative;
  overflow: hidden;
}

.ampel-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.ampel-card.green::before { background: radial-gradient(ellipse at 50% 0%, var(--green-glow), transparent 70%); opacity: 1; }
.ampel-card.yellow::before { background: radial-gradient(ellipse at 50% 0%, var(--yellow-glow), transparent 70%); opacity: 1; }
.ampel-card.red::before    { background: radial-gradient(ellipse at 50% 0%, var(--red-glow), transparent 70%); opacity: 1; }

.ampel-lights {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
}

.ampel-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-card2);
  border: 2px solid var(--border);
  transition: all 0.4s;
}

.ampel-dot.active-green  { background: var(--green);  border-color: var(--green);  box-shadow: 0 0 16px var(--green), 0 0 40px var(--green-glow); }
.ampel-dot.active-yellow { background: var(--yellow); border-color: var(--yellow); box-shadow: 0 0 16px var(--yellow), 0 0 40px var(--yellow-glow); }
.ampel-dot.active-red    { background: var(--red);    border-color: var(--red);    box-shadow: 0 0 16px var(--red), 0 0 40px var(--red-glow); }

.ampel-label {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
  font-family: var(--font-mono);
}

.ampel-card.green  .ampel-label { color: var(--green); }
.ampel-card.yellow .ampel-label { color: var(--yellow); }
.ampel-card.red    .ampel-label { color: var(--red); }

.ampel-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  min-height: 2.5em;
}

/* VIX Divergenz Banner */
.divergence-banner {
  display: none;
  background: var(--green-dim);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  color: var(--green);
  margin-top: 0.5rem;
}
.divergence-banner.visible { display: block; }

/* --- Contango Indikator ------------------------------------ */
.contango-bar-wrap {
  margin-top: 0.75rem;
}

.contango-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 0.4rem;
  font-family: var(--font-mono);
}

.contango-track {
  height: 8px;
  background: var(--bg-card2);
  border-radius: 99px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.contango-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease, background 0.4s;
  background: var(--green);
}

.contango-fill.backwardation { background: var(--red); }

/* --- Strategie-Signale ------------------------------------- */
.signals-list { display: flex; flex-direction: column; gap: 0.6rem; }

.signal-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.3s;
}

.signal-item.active  { border-color: var(--green); }
.signal-item.warning { border-color: var(--yellow); }
.signal-item.inactive { opacity: 0.55; }

.signal-icon {
  font-size: 1.1rem;
  min-width: 24px;
  margin-top: 1px;
}
.signal-item.active   .signal-icon { color: var(--green); }
.signal-item.inactive .signal-icon { color: var(--text-muted); }
.signal-item.warning  .signal-icon { color: var(--yellow); }

.signal-body { flex: 1; min-width: 0; }

.signal-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.signal-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1em 0.5em;
  border-radius: 99px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.badge-aktiv, .badge-bestätigt, .badge-möglich {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
}
.badge-pause, .badge-warten, .badge-warnung {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid var(--yellow);
}

.signal-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.45;
}

/* --- Volatilitäts-Cockpit ---------------------------------- */
.vola-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.vola-item {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  text-align: center;
}

.vola-name {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.vola-value {
  font-size: 1.9rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 0.3rem;
}

.vola-change {
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.vola-threshold {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-family: var(--font-mono);
}

/* Sparkline Canvas */
.vola-chart {
  width: 100%;
  height: 36px;
  margin-top: 0.5rem;
}

/* --- Indices ----------------------------------------------- */
.indices-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

/* Abschnitts-Label überspannt alle 5 Spalten */
.indices-section-label {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.1rem 0 0.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: -0.1rem;
}

.index-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  position: relative;
  overflow: hidden;
}

.index-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.index-card.positive::after { background: var(--green); }
.index-card.negative::after { background: var(--red); }
.index-card.neutral::after  { background: var(--border); }

.index-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.index-price {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 0.3rem;
}

.index-change {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Tag + YTD Zeile */
.index-perf-row {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.index-tag,
.index-ytd {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

.index-ytd {
  opacity: 0.75; /* YTD etwas dezenter */
}

.index-sparkline {
  width: 100%;
  height: 32px;
  margin-top: 0.6rem;
}

/* --- Farben ------------------------------------------------ */
.green, .positive .index-change  { color: var(--green); }
.red, .negative .index-change    { color: var(--red); }
.yellow                           { color: var(--yellow); }
.muted                            { color: var(--text-muted); }

.positive .index-price { color: var(--text-primary); }
.negative .index-price { color: var(--text-primary); }

/* --- News Feed --------------------------------------------- */
.news-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.news-col { display: flex; flex-direction: column; gap: 0; }

.news-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.news-item:last-child { border-bottom: none; }

.news-source-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: var(--radius-sm);
  background: var(--blue-dim);
  color: var(--blue);
  white-space: nowrap;
  min-width: 64px;
  text-align: center;
  margin-top: 1px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.news-source-badge.reuters    { background: #1a2d1a; color: #f90; }
.news-source-badge.cnbc       { background: #1a2a1a; color: #3fb950; }
.news-source-badge.tagesschau { background: #1a1a3a; color: var(--blue); }
.news-source-badge.handelsblatt { background: #2a1a1a; color: #ff8f4a; }

.news-body { flex: 1; min-width: 0; }

.news-title {
  font-size: 0.83rem;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-title a { color: inherit; }
.news-title a:hover { color: var(--blue); text-decoration: none; }

.news-age {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

/* --- Kalender (horizontaler Strip) ------------------------- */
.calendar-strip {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.calendar-strip::-webkit-scrollbar { height: 4px; }
.calendar-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cal-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.65rem 1rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 150px;
  max-width: 190px;
  border-top: 3px solid var(--border);
}

.cal-item.high   { border-top-color: var(--red); }
.cal-item.medium { border-top-color: var(--yellow); }

.cal-date {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--blue);
}

.cal-title {
  color: var(--text-primary);
  font-size: 0.8rem;
  line-height: 1.3;
  font-weight: 500;
}

.cal-days-left {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.cal-days-left.soon { color: var(--red); font-weight: 700; }

/* --- Loading & Error States -------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card2) 25%, var(--bg-hover) 50%, var(--bg-card2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 1em;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-placeholder {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.error-msg {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--red);
  margin-top: 0.5rem;
}

/* --- Material Icons ---------------------------------------- */
.material-icons {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: normal;
  font-size: 18px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .col-left, .col-right { grid-column: 1; }
  .indices-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .vola-grid       { grid-template-columns: 1fr 1fr; } /* 2x2 auf Mobile */
  .indices-grid    { grid-template-columns: 1fr 1fr; }
  .news-grid       { grid-template-columns: 1fr; }
  .header-meta     { display: none; }
}

/* --- Scrollbar --------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Fear & Greed Bar -------------------------------------- */
.fg-bar-track {
  height: 8px;
  background: linear-gradient(to right,
    #f85149 0%, #e3b341 40%, #3fb950 60%, #bc8cff 100%);
  border-radius: 99px;
  position: relative;
}

.fg-bar-fill {
  position: absolute;
  top: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
  transform: translateX(-50%);
  transition: left 0.6s ease;
  pointer-events: none;
}

/* --- Legende ----------------------------------------------- */
.legende-wrap {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.legende-toggle {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.legende-toggle:hover {
  background: var(--bg-card2);
  color: var(--text-primary);
}

.legende-arrow { margin-left: auto; }
.legende-arrow.open { transform: rotate(180deg); }

.legende-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 1.5rem;
  margin-top: -4px;
}

.legende-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

.legende-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.legende-section p {
  font-size: 0.81rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 0.5rem;
}

.legende-section ul {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.legende-section ul li {
  font-size: 0.79rem;
  color: var(--text-secondary);
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
  line-height: 1.4;
}

.legende-tip {
  background: var(--bg-card2);
  border-left: 3px solid var(--blue);
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.78rem !important;
  color: var(--text-secondary) !important;
}

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

/* --- Update Flash ------------------------------------------ */
.flash-update {
  animation: flashIn 0.5s ease-out;
}

@keyframes flashIn {
  0%   { background: rgba(58, 139, 253, 0.15); }
  100% { background: transparent; }
}
