/* ============================================================
   ARaymond Energy Dashboard – Styles
   ============================================================ */
:root {
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --success: #0d904f;
  --danger: #d93025;
  --warning: #f9ab00;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #202124;
  --text-light: #5f6368;
  --border: #dadce0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---- Layout ---- */
.navbar {
  background: var(--primary);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.navbar h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.navbar-links {
  display: flex;
  gap: 16px;
}

.navbar-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.2s;
}

.navbar-links a:hover,
.navbar-links a.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ---- Section Headers ---- */
.section-header {
  margin-bottom: 16px;
  margin-top: 8px;
  padding: 16px 24px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border-left: 5px solid var(--primary);
  box-shadow: var(--shadow);
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.section-header .section-desc {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
}

.section-header .section-desc a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.section-header .section-desc a:hover {
  text-decoration: underline;
}

/* ---- Controls Bar ---- */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls-bar label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
}

.controls-bar input[type="date"],
.controls-bar select,
.controls-bar input[type="number"] {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  outline: none;
}

.controls-bar input:focus,
.controls-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #1557b0;
}

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

/* ---- Period Tabs ---- */
.period-tabs {
  display: flex;
  gap: 4px;
  background: #e8eaed;
  border-radius: 8px;
  padding: 3px;
}

.period-tabs button {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  transition: all 0.2s;
}

.period-tabs button.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ---- KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}

.kpi-card.success::before { background: var(--success); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.warning::before { background: var(--warning); }

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.kpi-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-light);
  margin-left: 4px;
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

.kpi-change.up {
  background: #fce8e6;
  color: var(--danger);
}

.kpi-change.down {
  background: #e6f4ea;
  color: var(--success);
}

.kpi-change.neutral {
  background: #e8eaed;
  color: var(--text-light);
}

.kpi-desc {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 6px;
  font-style: italic;
}

/* ---- Chart Cards ---- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-grid.full {
  grid-template-columns: 1fr;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.chart-desc {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 14px;
  line-height: 1.5;
}

.chart-card canvas {
  width: 100% !important;
  max-height: 320px;
}

.chart-card.tall canvas {
  max-height: 400px;
}

/* ---- Classification ---- */
.classification-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.classification-donut {
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

/* ---- Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f8f9fa;
}

.data-table tr:hover {
  background: var(--primary-light);
}

/* ---- Status Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-production { background: #e8f0fe; color: #1a73e8; }
.badge-operational { background: #fef7e0; color: #e37400; }
.badge-unclassified { background: #e8eaed; color: #5f6368; }
.badge-exceeded { background: #fce8e6; color: #d93025; }

/* ---- Settings Page ---- */
.settings-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.settings-card h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.place-list {
  list-style: none;
}

.place-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.place-item:last-child {
  border-bottom: none;
}

.place-item label {
  font-weight: 500;
}

.place-item .place-sub {
  color: var(--text-light);
  font-size: 13px;
}

.place-item select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

/* ---- Loader ---- */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Full-page loading overlay ---- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.3s;
}
.loading-overlay.hidden {
  display: none;
}
.loading-spinner {
  width: 48px; height: 48px;
  border: 5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  margin-top: 14px;
  font-size: 15px;
  color: var(--text-light);
  font-weight: 500;
}

/* ---- Placeholder sections ---- */
.placeholder-section {
  background: var(--card-bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-light);
  margin-bottom: 24px;
}

.placeholder-section h3 {
  margin-bottom: 8px;
  color: var(--text);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .classification-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 12px; }
  .controls-bar { flex-direction: column; align-items: stretch; }
}

/* ---- Limit line indicator ---- */
.limit-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.limit-indicator.ok {
  background: #e6f4ea;
  color: var(--success);
}

.limit-indicator.exceeded {
  background: #fce8e6;
  color: var(--danger);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 8px;
  background: #323232;
  color: white;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ---- Weather current ---- */
.weather-current {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 0;
}

.weather-stat {
  flex: 1;
  min-width: 120px;
  text-align: center;
  padding: 16px 12px;
  background: var(--bg);
  border-radius: 10px;
}

.weather-stat .ws-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.weather-stat .ws-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.weather-stat .ws-label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ---- Analysis tables ---- */
.analysis-table-wrap {
  overflow-x: auto;
}

.analysis-table-wrap .data-table {
  font-size: 13px;
}

.analysis-table-wrap .data-table th {
  font-size: 11px;
  white-space: nowrap;
}

.analysis-table-wrap .data-table td {
  padding: 8px 12px;
}
