/* =========================================
   ATLAS DECISION ENGINE STYLES
   (Adapted for Consoe Tech B&W System)
   ========================================= */

/* Use variables defined in style.css: var(--ct-bg), etc. */

/* Atlas Adjustments */
.atlas-wrapper {
  background-color: var(--ct-bg);
  color: var(--ct-text);
  min-height: 100vh;
}

/* Grid Layout */
.grid-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 980px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

/* Cards (Specific to Layout) */
.card {
  background: var(--ct-panel);
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--ct-shadow);
}

.card h2 {
  margin: 0 0 20px;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: var(--ct-muted);
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 1px solid var(--ct-border);
  padding-bottom: 12px;
}

/* Metrics */
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric {
  background: #fafafa;
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius);
  padding: 16px;
  position: relative;
  transition: all 0.2s ease;
}

.metric.editable:hover {
  border-color: #000;
  background: #fff;
  cursor: pointer;
}

.metric .k {
  color: var(--ct-muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric .v {
  font-size: 24px;
  margin-top: 8px;
  font-weight: 700;
  color: var(--ct-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.metric .hint {
  color: var(--ct-muted);
  font-size: 12px;
  margin-top: 8px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 12px;
  background: #f4f4f4;
  color: var(--ct-text);
  border: 1px solid var(--ct-border);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ct-muted);
}

.dot.bad {
  background: var(--ct-bad);
}

.dot.good {
  background: var(--ct-good);
}

.dot.warn {
  background: var(--ct-warn);
}

/* Action Buttons Specific to Atlas Panels */
.btn-action {
  background: #fafafa;
  border: 1px solid var(--ct-border);
  color: var(--ct-text);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 12px;
  transition: border-color 0.2s;
}

.btn-action:hover {
  border-color: #000;
  background: #fff;
}

.btn-link {
  background: none;
  border: none;
  color: var(--ct-text);
  text-decoration: underline;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

/* Danger Zone */
.danger-zone {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: var(--ct-radius);
  padding: 24px;
  margin-bottom: 24px;
}

.danger-header h3 {
  color: var(--ct-bad);
  font-size: 18px;
  margin: 0 0 4px;
}

.danger-header p {
  color: var(--ct-muted);
  font-size: 14px;
}

/* Strategy Cards */
.strategies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.strategy-card {
  background: #ffffff;
  border: 1px solid var(--ct-border);
  border-radius: var(--ct-radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.strategy-card.recommended {
  border: 2px solid var(--ct-good);
  background: #f0fdf4;
}

.rec-badge {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--ct-good);
  color: #fff;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 99px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Journal */
.entry-content {
  background: #fafafa;
  border: 1px solid var(--ct-border);
  color: var(--ct-text);
}

/* Simulation Results */
.simulation-result {
  background: #f0fdf4;
  border: 1px solid var(--ct-good);
  border-radius: var(--ct-radius);
  padding: 16px;
  margin-top: 16px;
}

.sim-val {
  color: var(--ct-good);
}

.sim-label {
  color: var(--ct-muted);
}

.metric.editable {
  pointer-events: auto !important;
  cursor: pointer;
  position: relative;
  z-index: 20;
}

.metric.editable * {
  pointer-events: none;
}

/* ================================
   MODAL FIX PACK (CSS ONLY)
   Put this at the VERY BOTTOM of atlas.css
   ================================ */

/* Ensure overlays are real overlays (not page content) */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  display: none;
  /* JS toggles to flex */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999 !important;
  pointer-events: auto !important;
}

/* When JS sets display:flex, keep it flex */
.modal-overlay[style*="display: flex"] {
  display: flex !important;
}

/* Modal box clickable */
.modal-overlay .modal {
  pointer-events: auto !important;
  max-height: 90vh;
  overflow: auto;
}

/* Stop background scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

/* Make header buttons always clickable */
button,
.btn-primary,
.btn-ghost,
.btn-action {
  pointer-events: auto !important;
}

button {
  pointer-events: auto !important;
  position: relative;
  z-index: 500;
}

header,
header * {
  pointer-events: auto !important;
}

/* --- Mobile Optimization --- */
@media (max-width: 768px) {
  .grid-layout {
    display: block;
  }

  .metric-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .strategies-grid {
    grid-template-columns: 1fr;
  }

  .btn-primary,
  .btn-ghost,
  .btn-action {
    width: 100%;
    min-height: 44px;
    /* Touch target size */
  }

  /* Stack modal actions if needed */
  .modal-actions {
    flex-direction: column;
  }
}

/* --- Mobile Optimization --- */
@media (max-width: 768px) {
  .grid-layout {
    display: block;
  }

  .metric-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .strategies-grid {
    grid-template-columns: 1fr;
  }

  .btn-primary,
  .btn-ghost,
  .btn-action {
    width: 100%;
    min-height: 44px;
    /* Touch target size */
  }

  /* Stack modal actions if needed */
  .modal-actions {
    flex-direction: column;
  }
}
}

.modal-overlay {
  pointer-events: none;
}

.modal-overlay[style*='display: flex'] {
  pointer-events: auto;
}

.pos-option {
  cursor: pointer;
}