/* ============================================
   CORA Modern Theme - Dark/Light Mode Support
   Scientific Portal with Dense Data Tables
   ============================================ */

/* CSS Variables for Theme Switching */
:root {
  /* Light Theme (Default) */
  --bg-primary: #ffffff;
  /*--bg-primary: #FFFAF0;*/ /* old CORA bg */
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  
  /* Accent Colors */
  --accent-primary: #d32f2f;
  --accent-hover: #b71c1c;
  --accent-light: #ffcdd2;
  
  /* Table Colors */
  --table-header: #37474f;
  --table-row-odd: #f8f9fa;
  --table-row-even: #ffffff;
  --table-row-hover: #e3f2fd;
  --table-border: #dee2e6;
  
  /* UI Elements */
  --border-color: #dee2e6;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  
  /* Map Elements */
  --map-bg: #ffffff;
  --map-control-bg: rgba(255, 255, 255, 0.9);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2d2d2d;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;
  
  --accent-primary: #ef5350;
  --accent-hover: #ff6659;
  --accent-light: #4a2020;
  
  --table-header: #2d3436;
  --table-row-odd: #242424;
  --table-row-even: #1a1a1a;
  --table-row-hover: #1e3a5f;
  --table-border: #3d3d3d;
  
  --border-color: #3d3d3d;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.5);
  
  --map-bg: #1a1a1a;
  --map-control-bg: rgba(42, 42, 42, 0.95);
}

/* Dark Theme — CORA v2 (metal green / scientific) */
[data-theme="dark1"] {
  /* Backgrounds */
  --bg-primary:   #161b1a;   /* dark metal green */
  --bg-secondary: #1e2423;
  --bg-tertiary:  #262e2d;

  /* Text */
  --text-primary:   #e3f0ed;
  --text-secondary: #b8cfc9;
  --text-muted:     #8fa6a1;

  /* Accent (cool green-cyan) */
  --accent-primary: #4db6ac;   /* teal-green */
  --accent-hover:   #6ed6cb;
  --accent-light:   #1f3d3a;

  /* Accent (cool reddish) */
  --accent-primary: #ef5350;
  --accent-hover: #ff6659;
  --accent-light: #4a2020;

  /* Tables */
  --table-header:     #202a29;
  --table-row-odd:    #1b2221;
  --table-row-even:   #161b1a;
  --table-row-hover:  #2a3f3c;
  --table-border:     #344845;

  /* Borders & shadows */
  --border-color:   #344845;
  --shadow:         rgba(0, 0, 0, 0.35);
  --shadow-hover:   rgba(0, 0, 0, 0.55);

  /* Maps */
  --map-bg:         #161b1a;
  --map-control-bg: rgba(32, 42, 41, 0.96);
}

/* ============================================
   Base Styles
   ============================================ */

/* Avoid FOUC (Flash Of Unstyled Content) / theme flash (fallback, main point is in base.html)
html {
  background: var(--bg-primary);
}
*/

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0 0 30px 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.75em;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }
h6 { font-size: 13px; }

p {
  text-align: left;
  margin: 1em 0;
  white-space: normal;
}

/* ============================================
   Links
   ============================================ */

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

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

a:visited {
  color: var(--accent-primary);
}

/* ============================================
   Header & Logo
   ============================================ */

.cora-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.5px;
}

.cora-content {
  max-width: 1000px;
  margin: 0 auto;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

/* ============================================
   Navigation Menu
   ============================================ */

#hormenu {
  font-size: 18px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin: 20px auto;
  max-width: 95%;
  box-shadow: 0 2px 4px var(--shadow);
}

#hormenu a {
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-block;
}

#hormenu a:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

#hormenu b {
  color: var(--text-primary);
  font-weight: 600;
}

/* ============================================
   Forms & Buttons
   ============================================ */

button,
input[type="submit"],
input[type="button"] {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px var(--shadow);
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px var(--shadow-hover);
  transform: translateY(-1px);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

input[type='checkbox'],
input[type='radio'] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

/* ============================================
   Tables - Optimized for Dense Data
   ============================================ */

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--table-border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  margin: 20px auto;
  font-size: 16px;
}

th {
  background: var(--table-header);
  color: #ffffff;
  font-weight: 600;
  padding: 12px 16px;
  text-align: center;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--table-border);
  color: var(--text-primary);
}

/* Dense table with better alternating rows */
table.occ {
  font-size: 14px;
}

table.occ tr:nth-child(odd) {
  background: var(--table-row-odd);
}

table.occ tr:nth-child(even) {
  background: var(--table-row-even);
}

table.occ tr:hover {
  background: var(--table-row-hover);
  transition: background-color 0.15s ease;
}

.occTable tr {
  font-size: 13px;
}

.noBorder {
  border-collapse: collapse;
  border: none;
}

/* Numeric columns alignment */
td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

/* Text alignment helpers */
.alignLeft { text-align: left; padding-left: 8px; }
.alignRight { text-align: right; padding-right: 8px; }
.alignCenter { text-align: center; }

/* ============================================
   Code & Preformatted Text
   ============================================ */

pre,
tt,
code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  font-size: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
  color: var(--text-primary);
}

.pre {
  white-space: pre;
}

pre-wrap {
        font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace; 
        font-size: 11pt; 
        text-align:left; 
        background: var(--bg-primary);
        color: var(--text-primary);
        overflow-x: auto;
        white-space: pre-wrap;
        white-space: -moz-pre-wrap;
        white-space: -pre-wrap;
        white-space: -o-pre-wrap;
        word-wrap: break-word;
}

/* ============================================
   Leaflet Map Styling
   ============================================ */

#map_pred,
#map_rep {
  width: 800px;
  height: 800px;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  border: 1px solid var(--border-color);
  background: var(--map-bg);
}


/* Dark theme map tiles filter */
[data-theme="dark"] .leaflet-tile {
  filter: brightness(0.7) contrast(1.2) saturate(0.8);
}

/* Map controls */
.ui-control {
  background: var(--map-control-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 8px var(--shadow);
  backdrop-filter: blur(10px);
}

.leaflet-control-layers {
  background: var(--map-control-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px !important;
  backdrop-filter: blur(10px);
}

.leaflet-control-layers label {
  color: var(--text-primary);
  text-align: left;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
}

.leaflet-popup-tip {
  background: var(--bg-primary);
}

.info {
  padding: 12px 16px;
  background: var(--map-control-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
  backdrop-filter: blur(10px);
  font-size: 13px;
}

.info p {
  margin: 8px 0;
  color: var(--text-secondary);
  text-align: left;
}

/* ============================================
   Theme Toggle Button
   ============================================ */

#theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 1000;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#theme-toggle:hover {
  background: var(--bg-tertiary);
  box-shadow: 0 4px 12px var(--shadow-hover);
  transform: translateY(-2px);
}

#theme-toggle::before {
  content: '🌙';
  margin-right: 8px;
}

[data-theme="dark"] #theme-toggle::before {
  content: '☀️';
}

/* ============================================
   Content Container
   ============================================ */

#content {
  width: 95%;
  max-width: 1400px;
  margin: 20px auto;
  padding: 20px;
  background: var(--bg-primary);
}

/* ============================================
   Messages
   ============================================ */

.messages {
  padding: 12px 20px;
  border-radius: 8px;
  margin: 20px auto;
  max-width: 95%;
  border-left: 4px solid var(--accent-primary);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 4px var(--shadow);
}

/* ============================================
   Lists
   ============================================ */

ol, ul {
  line-height: 1.8;
  color: var(--text-primary);
}

.custom-radio-list {
  list-style-type: none;
  padding: 8px;
  margin: 0;
}

/* ============================================
   Worldmap (D3.js)
   ============================================ */

.night0 {
  stroke: #4fc3f7;
  fill: #4fc3f7;
  fill-opacity: 0.3;
}

.night {
  stroke: #4fc3f7;
  fill: #37474f;
  fill-opacity: 0.3;
}

[data-theme="dark"] .night {
  fill: #1a237e;
  stroke: #2196f3;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
  #map_pred,
  #map_rep {
    width: 100%;
    max-width: 800px;
    height: 600px;
  }
  
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px 12px;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 13px;
  }
  
  .cora-title {
    font-size: 20px;
  }
  
  #hormenu {
    font-size: 12px;
    padding: 10px;
  }
  
  #theme-toggle {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 12px;
  }
  
  table {
    font-size: 11px;
  }
  
  th, td {
    padding: 6px 8px;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  #theme-toggle,
  #hormenu {
    display: none;
  }
  
  body {
    background: white;
    color: black;
  }
  
  table {
    box-shadow: none;
    border: 1px solid #000;
  }
}

/* =========================
   Collapsible filter form
   ========================= */

.cora-filter {
  max-width: 1000px;
  margin: 0 auto 20px auto;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.cora-filter summary {
  cursor: pointer;
  font-size: 15px;
  user-select: none;
}

.cora-filter summary::marker {
  color: var(--accent-primary);
}

.cora-filter .filter-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.cora-form-table td {
  padding: 4px 8px;
}

.cora-form-table .help {
  color: var(--text-muted);
  font-size: 12px;
}


/* =========================
   Responsive Leaflet Map
   ========================= */
/* =========================
   Leaflet Container
   ========================= */

.leaflet-container {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3 / 2;               /* responsive height */

  border: 1px solid var(--border-color);
  border-radius: 8px;

  background: var(--map-bg);         /* dedicated map background */

  /* Disable theme shading */
  filter: none !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  backdrop-filter: none !important;
}

.leaflet-container * {
  filter: none !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  backdrop-filter: none !important;
}

.leaflet-wrapper {
  width: 100%;
  max-width: 1000px;          /* same visual width as tables */
  margin: 20px auto;

  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
}


/* CORA action button (anchor-style button) */
.cora-button {
  display: inline-block;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px var(--shadow);
}

.cora-button:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px var(--shadow-hover);
  transform: translateY(-1px);
}

.cora-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px var(--shadow);
}


/* Frame around scientific plots */
.cora-canvas-frame {
  display: inline-block;
  padding: 6px;                         /* small breathing room */
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
}

/* Optional subtle inner frame */
.cora-canvas-frame svg {
  display: block;
  border-radius: 4px;
}

.cora-canvas-frame.export {
  background: #ffffff;
  border-color: #000000;
}

.cora-plot-svg {
  background-color: #2b2b2b;
}

/* Default SVG text color (inherits from theme) */
svg text {
  fill: var(--text-primary);
}

/* Muted SVG text */
svg text.muted {
  fill: var(--text-muted);
}

/* =========================
   CORA Dashboard (Home)
   ========================= */

.cora-dashboard {
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 20px;
}

/* Grid */
.cora-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 30px;
}

/* Generic card */
.cora-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 30px 26px;
  box-shadow: 0 8px 20px var(--shadow);
  transition: all 0.25s ease;
  color: var(--text-primary);
  text-decoration: none;
}

/* Hover effect (shared) */
.cora-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px var(--shadow-hover);
  border-color: var(--accent-primary);
}

/* Headings */
.cora-card h1,
.cora-card h2 {
  margin: 0 0 10px 0;
  font-weight: 400;
  color: var(--text-primary);
}

.cora-card h1 {
  font-size: 26px;
  letter-spacing: 1px;
  text-align: center;
}

.cora-card h2 {
  font-size: 20px;
  text-align: center;
}

/* Text */
.cora-card p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  text-align: center;
}

/* Divider */
.cora-card hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 14px 0;
}

/* ---------- Modifiers ---------- */

/* Clickable cards */
.cora-card.link {
  cursor: pointer;
}

/* Non-clickable dashboard title card */
.cora-card.static {
  cursor: default;
}

.cora-card.static:hover {
  transform: translateY(-4px); /* subtle reaction */
  border-color: var(--border-color);
}

/* Muted / coming soon */
.cora-card.disabled {
  opacity: 0.6;
  cursor: default;
}

.cora-card.disabled:hover {
  transform: none;
  box-shadow: 0 8px 20px var(--shadow);
}

/* Call4Obs highlight */
.cora-card.call4obs {
  border-color: var(--accent-primary);
}

.cora-card.call4obs:hover {
  box-shadow: 0 0 0 1px var(--accent-primary),
              0 16px 32px var(--shadow-hover);
}


/* =========================
   Dashboard Partner Footer
   ========================= */

.cora-dashboard-footer {
  margin-top: 60px;
  padding: 30px 20px 10px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.footer-title {
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}


/* =========================
   Partner Logos (Dashboard)
   ========================= */

/* Logo container */
.partner-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 28px;
}

.partner-logos img {
  max-height: 42px;
  object-fit: contain;
}

.partner-logos a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.partner-logos a:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.partner-logo {
  display: none;                 /* theme-controlled */
  max-height: 42px;
  max-width: 160px;
  filter: grayscale(100%);
  transition: filter 0.2s ease;
}

/* Neutral logos (no theme switching) */
.partner-logo:not(.logo-light):not(.logo-dark) {
  display: inline-block;
}

/* Size modifiers */
.partner-logo.small {
  max-height: 32px;
}

.partner-logo.tiny {
  max-height: 26px;
}

.partner-logo.large { 
  max-height: 48px; 
}

.partner-logo.larger {
  max-height: 96px;
}

.partner-logo.huge {
  max-height: 120px;
}

/* Colorize on hover */
.partner-logos a:hover .partner-logo {
  filter: grayscale(0%);
}

/* Theme switching */
[data-theme="light"] .logo-light {
  display: inline-block;
}

[data-theme="dark"] .logo-dark {
  display: inline-block;
}

/* Aladin Sky Atlas */
.aladin-container {
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 4 / 3;
}


/* =========================
   SVG Globe (Responsive)
   ========================= */

.cora-canvas-frame {
  width: 100%;
  max-width: 1000px;      /* aligns with tables & Leaflet */
  margin: 20px auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px;
  background: transparent;
}

#occ-globe {
  width: 100%; //800px; /* 100%; geht nicht wegen absoluten plot coordinaten */
  height: auto;
  aspect-ratio: 1 / 1;   /* always square */
  display: block;
}
