/* ===== Base Layout ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: #f9f9f9;
  margin: 0;
  padding: 0;
}

.top-bar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 999;
}

/* ===== Page Switch ===== */

.page-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 90px 40px 0;
  background: #f2f3f5;
}

.page-buttons a {
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  transition: transform .12s ease, filter .12s ease;
}


.page-buttons .optimize-btn { background:#5555; }
.page-buttons .metrics-btn { background:#2196f3; }
.page-buttons .accuracy-btn { background:#5555; }

.page-buttons a:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* ===== Action Buttons ===== */

.buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 40px 8px;
  margin-top: -32px;
  background: #f2f3f5;
}

/* Circular icon buttons */
#optimize-and-save,
#run-optimizer-button,
#pd-close {
  --size: 30px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 1px solid #c9cdd3;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

#optimize-and-save:hover,
#run-optimizer-button:hover,
#pd-close:hover {
  transform: translateY(-1px);
  filter: brightness(1.12);
  box-shadow: 0 3px 6px rgba(0,0,0,.12);
}

#optimize-and-save { background:#2196F3; }

#run-optimizer-button { background:#4caf50; }
#run-optimizer-button:disabled {
  background:#9e9e9e;
  cursor: not-allowed;
  opacity: 0.6;
}

#pd-close { background:#5555; }
#pd-close::before { content:"×"; font-size:18px; font-weight:700; color:#fff; }

/* ===== Main Layout ===== */

.optimize-layout {
  display: flex;
  gap: 24px;
  padding: 16px 40px 40px;
  height: calc(100vh - 130px);
  overflow: hidden;
}

.left-panel,
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

/* ===== Cards ===== */

.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #dcdfe3;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.card-header h2,
.card-header h3 {
  margin: -2;
  font-size: .95rem;
  font-weight: 700;
}

/* ===== Graph ===== */

.graph-card {
  flex: 3;
  min-height: 30px;
  display: flex;
  min-height: 0;
}

.graph-card .card-body {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 12px;
}

.graph-placeholder {
  flex: 1;
  min-height: 0;
  height: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 1px dashed #d1d5db;
  background: repeating-linear-gradient(
    -45deg,
    #f9fafb,
    #f9fafb 8px,
    #f3f4f6 8px,
    #f3f4f6 16px
  );
  display: flex;
  overflow: hidden;
  align-items: stretch;
  justify-content: stretch;
}

.graph-placeholder canvas {
  flex: 1;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ===== Model Inputs ===== */

.graph-meta-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.graph-meta-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-height: 45px;
}

.graph-meta-card .card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  padding-top: 0px;
}

.meta-list,
#point-details,
#default-details,
#pd-body {
  margin: 0;
  padding: 2px;
}

.meta-list {
  list-style: none;
  display: grid;
  row-gap: 8px;
}

.meta-label {
  font-size: .8rem;
  text-transform: uppercase;
  color: #6b7280;
}

.meta-value {
  font-size: .9rem;
  color: #111827;
}

/* ===== Table ===== */

.table-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-card .card-body {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
}

.recommendations-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: .9rem;
}

.recommendations-table thead {
  background:#f5f5f5;
  position: sticky;
  top: 0;
  z-index: 1;
}

.recommendations-table th,
.recommendations-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recommendations-table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #6b7280;
  text-align: left;
}

.recommendations-table tbody tr:nth-child(even) {
  background:#f9fafb;
}

/* ✅ REMOVED hover highlight */
/* .recommendations-table tbody tr:hover {
  background:#d0f0ff;
} */

/* ✅ Selected row styling */
.recommendations-table tbody tr.row-selected {
  background:#d0f0ff;
  font-weight:600;
}

/* Ensure hover never overrides selection */
.recommendations-table tbody tr.row-selected:hover {
  background:#d0f0ff;
}

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

@media (max-width: 960px) {
  .optimize-layout {
    flex-direction: column;
    height: auto;
  }

  .table-card .card-body {
    max-height: 300px;
  }
}

@media (max-width: 720px) {
  .page-buttons {
    padding: 68px 16px 0;
    flex-wrap: wrap;
    gap: 8px;
  }

  .buttons {
    padding: 0 16px 8px;
    margin-top: -28px;
  }

  .optimize-layout {
    padding: 16px 16px 40px;
    overflow-y: auto;
  }

  .scenario-controls {
    padding: 12px 16px;
  }

  .graph-card {
    min-height: 220px;
  }

  .table-card .card-body {
    overflow-x: auto;
  }

  .recommendations-table {
    min-width: 480px;
  }
}

/* ===== Scenario Controls ===== */

.scenario-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 40px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.scenario-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.scenario-select-group label {
  font-weight: 600;
  color: #333;
}

#scenario-selector {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  min-width: 250px;
  cursor: pointer;
}

#scenario-selector:focus {
  outline: none;
  border-color: #4CAF50;
}

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #f5f5f5;
  border-color: #4CAF50;
  color: #4CAF50;
}

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

/* ===== Restaurant Metrics Cards ===== */

.metrics-card {
  margin-bottom: 16px;
}

.metrics-card .card-body {
  padding: 16px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.metric {
  text-align: center;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
}

.metric-label {
  font-size: 12px;
  color: #666;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: #333;
  margin-bottom: 4px;
}

.metric-change {
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

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

  .scenario-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .scenario-select-group {
    flex-direction: column;
    align-items: stretch;
  }

  #scenario-selector {
    min-width: 100%;
  }
}


/* ===== Forecast Metrics Display ===== */

.forecast-metrics {
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-top: 12px;
}

.forecast-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #dee2e6;
}

.forecast-header h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 700;
  color: #212529;
}

.forecast-summary {
  margin: 0;
  font-size: 13px;
  color: #6c757d;
}

.metrics-section {
  margin-bottom: 16px;
}

.metrics-section:last-child {
  margin-bottom: 0;
}

.metrics-section h5 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e9ecef;
}

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

.metric-label {
  font-weight: 600;
  color: #495057;
  font-size: 13px;
}

.metric-value {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #212529;
  text-align: right;
}

.metric-lift {
  font-weight: 600;
  margin-left: 8px;
  font-size: 12px;
}

.metric-lift.positive {
  color: #28a745;
}

.metric-lift.negative {
  color: #dc3545;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .forecast-metrics {
    padding: 12px;
  }

  .metric-row {
    flex-direction: column;
    gap: 4px;
  }

  .metric-value {
    text-align: left;
  }
}

@media (max-width: 1000px) {
  .page-buttons { padding-top: 120px; }
  .page-buttons a { font-size: 22px; padding: 10px 16px; border-radius: 8px; }
  .buttons { margin-top: -46px; gap: 16px; }
  #optimize-and-save, #pd-close { --size: 50px; }
  #optimize-and-save::before, #pd-close::before { font-size: 28px; }
  th, td { font-size: 20px; padding: 16px 14px; }
}
