/* CSS Variables for Theme */
:root {
  --primary-blue: #007bff;
  --secondary-blue: #e6f2ff;
  --accent-blue: #0056b3;
  --success-green: #28a745;
  --warning-yellow: #ffc107;
  --danger-red: #dc3545;
  --bg-color: #f8fbff;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text-main: #2c3e50;
  --text-muted: #6c757d;
  --border-radius: 12px;
  --box-shadow: 0 8px 32px rgba(0, 123, 255, 0.08);
  --glass-border: 1px solid rgba(255, 255, 255, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
}

/* Layout */
.dashboard-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px;
}

/* Header & Tabs */
.header {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background: var(--card-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  margin-bottom: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  font-size: 1.8rem;
}
.logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
}
.highlight {
  color: var(--primary-blue);
}

.tab-ribbon {
  display: flex;
  gap: 15px;
}
.tab-btn {
  padding: 10px 25px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
}
.tab-btn:hover {
  color: var(--primary-blue);
  background: var(--secondary-blue);
}
.tab-btn.active {
  background: var(--primary-blue);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

/* Content Sections */
.tab-content {
  display: none;
  animation: fadeIn 0.5s ease-out forwards;
}
.tab-content.active {
  display: block;
}

/* Cards & Panels */
.glass-panel {
  background: var(--card-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 15px;
  margin-bottom: 15px;
}

h2 {
  font-size: 1.4rem;
  color: var(--text-main);
  margin-bottom: 5px;
}
.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Top Control Bar Match */
.top-control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: white;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.control-left {
  display: flex;
  align-items: center;
  gap: 15px;
}
.control-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: #111827;
}

.power-mode-list {
  display: flex;
  background-color: #F9FAFB;
  border-radius: 6px;
  padding: 4px;
  gap: 4px;
}

.pm-radio {
  cursor: pointer;
}
.pm-radio input[type="radio"] {
  display: none;
}
.pm-text {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6B7280;
  transition: all 0.2s;
}
.pm-radio input[type="radio"]:checked + .pm-text {
  background-color: white;
  color: #111827;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.control-center .auto-draining-text {
  color: #6B7280;
  font-size: 0.9rem;
  font-weight: 500;
}

.start-system-btn {
  background-color: #DBEAFE;
  color: #2563EB;
  border: 1px solid #BFDBFE;
  border-radius: 6px;
  padding: 8px 20px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.start-system-btn:hover {
  background-color: #BFDBFE;
}

/* Battery Grid Elements */
.battery-grid {
  display: -webkit-grid;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.battery-card {
  background: var(--card-bg);
  border: var(--glass-border);
  border-radius: var(--border-radius);
  padding: 15px;
  box-shadow: var(--box-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}
.battery-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 123, 255, 0.15);
}

.gray-bg {
  background-color: #f1f4f8;
  padding: 10px 15px;
  border-radius: 8px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.card-header h3 {
  font-size: 1.2rem;
  color: var(--text-main);
}
.status-badge {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}
.status-healthy { background: var(--success-green); color: white; }
.status-warning { background: var(--warning-yellow); color: #333; }
.status-critical { background: var(--danger-red); color: white; }
.status-unknown { background: var(--text-muted); color: white; }

/* The Battery Tank Visual */
.battery-layout {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 25px;
}

.battery-tank-wrapper {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.battery-tip {
  width: 25px;
  height: 10px;
  background: #ccc;
  border-radius: 4px 4px 0 0;
}

.battery-tank {
  width: 60px;
  height: 120px;
  border: 3px solid #ccc;
  border-radius: 6px;
  position: relative;
  background: #f0f0f0;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Glowing tank states */
.tank-healthy {
  border-color: var(--success-green);
  box-shadow: 0 0 15px var(--success-green), inset 0 2px 5px rgba(0,0,0,0.1);
}
.tank-warning {
  border-color: var(--warning-yellow);
  box-shadow: 0 0 15px var(--warning-yellow), inset 0 2px 5px rgba(0,0,0,0.1);
}
.tank-critical {
  border-color: var(--danger-red);
  box-shadow: 0 0 20px var(--danger-red), inset 0 2px 5px rgba(0,0,0,0.1);
}
.tank-unknown {
  border-color: var(--text-muted);
  box-shadow: 0 0 10px var(--text-muted), inset 0 2px 5px rgba(0,0,0,0.1);
}

.battery-level-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, var(--primary-blue), #4db8ff);
  transition: height 1s ease-in-out;
  border-radius: 0 0 3px 3px;
}

.battery-charge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 1.1rem;
  color: #333;
  z-index: 2;
  text-shadow: 0px 0px 4px rgba(255, 255, 255, 0.8);
}

.battery-metrics-table {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 2px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.05);
}
.metric-label {
  color: var(--text-muted);
  font-weight: 500;
}
.metric-value {
  color: var(--text-main);
  font-weight: 600;
}

/* Removed legacy charge controls and slider */

/* Maintenance Cards */
.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.maintenance-card {
  background: var(--card-bg);
  border: var(--glass-border);
  border-radius: var(--border-radius);
  padding: 25px;
  box-shadow: var(--box-shadow);
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.m-metric {
  text-align: center;
  padding: 15px;
  background: var(--secondary-blue);
  border-radius: 8px;
}
.m-metric h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.m-metric p {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-blue);
}

/* Toast Notification */
.toast {
  visibility: hidden;
  min-width: 250px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  font-weight: 500;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.toast.show {
  visibility: visible;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadein {
  from { bottom: 0; opacity: 0; }
  to { bottom: 30px; opacity: 1; }
}
@keyframes fadeout {
  from { bottom: 30px; opacity: 1; }
  to { bottom: 0; opacity: 0; }
}

/* -------------------------------------
   MOCKUP MATCHING STYLES 
   ------------------------------------- */

/* Colors specific to mockup */
.color-healthy { color: #10B981; }
.color-warning { color: #F59E0B; }
.color-critical { color: #EF4444; }
.color-unknown { color: #6B7280; }

.m-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a202c;
  white-space: nowrap;
}

/* Custom Status Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background-color: #F3F4F6;
  color: #4B5563;
  white-space: nowrap;
}
.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #9CA3AF;
}
.status-pill.status-healthy .dot { background-color: #10B981; }
.status-pill.status-warning .dot { background-color: #F59E0B; }
.status-pill.status-critical .dot { background-color: #EF4444; }

/* Operational Status Pills */
.status-pill.status-inuse    { background: #EFF6FF; color: #1D4ED8; }
.status-pill.status-inuse    .dot { background-color: #2563EB; }
.status-pill.status-full     { background: #ECFDF5; color: #065F46; }
.status-pill.status-full     .dot { background-color: #10B981; }
.status-pill.status-charging { background: #F0FDFA; color: #0F766E; }
.status-pill.status-charging .dot { background-color: #14B8A6; }
.status-pill.status-cooling  { background: #FFF7ED; color: #9A3412; }
.status-pill.status-cooling  .dot { background-color: #F97316; }

/* 2-Column Battery Flex Layout */
.battery-flex-container {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: center;
  align-items: center;
  margin-top: 15px;
  gap: 15px;
}

/* Left Column - Tank */
.battery-left-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
}
.battery-percent-text {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 12px;
}

/* Redefine Tank to match simpler visual (no inset shadows) */
.battery-tank {
  width: 45px;
  height: 90px;
  border: 2px solid #E5E7EB;
  border-radius: 6px;
  background: white;
  box-shadow: none; 
  padding: 2px;
}
.battery-tip {
  width: 18px;
  height: 6px;
  background: #E5E7EB;
  border-radius: 3px 3px 0 0;
}
.battery-level-fill {
  width: 100%;
  border-radius: 3px;
  background: #10B981; /* Default to mockup green */
}
.tank-healthy .battery-level-fill { background: #10B981; }
.tank-warning .battery-level-fill { background: #F59E0B; }
.tank-critical .battery-level-fill { background: #EF4444; }

/* Remove previous text overlay on tank */
.battery-charge-text { display: none; }

/* Override glowing borders for cleaner look */
.battery-tank.tank-healthy, .battery-tank.tank-warning, .battery-tank.tank-critical {
  border-color: #E5E7EB;
  box-shadow: none;
}

/* Right Column - Metrics Grid */
.gray-metrics-box {
  background-color: #F9FAFB;
  border-radius: 8px;
  padding: 12px;
  flex-grow: 1;
}

.metrics-grid-2x2 {
  display: flex;
  justify-content: space-between;
}
.metrics-cell {
  display: flex;
  flex-direction: column;
  width: 48%;
}

.m-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #9CA3AF;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.m-value {
  font-size: 1rem;
  font-weight: 700;
}
.m-value-large {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}
.m-value-small {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111827;
}

.metrics-row-single {
  display: flex;
  flex-direction: column;
}
.mt-2 {
  margin-top: 10px;
}

/* Disabled Setting Button at Bottom */
.mockup-btn-container {
  margin-top: 20px;
  border-top: 1px solid #F3F4F6;
  padding-top: 15px;
}
.mockup-btn {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #F3F4F6;
  color: #6B7280;
  text-align: center;
}

/* Chart Containers */
.charts-container {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 25px;
}
.chart-box {
  -webkit-flex: 1 1 calc(50% - 10px);
  flex: 1 1 calc(50% - 10px);
  max-width: calc(50% - 10px);
  min-width: 280px;
  background: var(--card-bg);
  border: var(--glass-border);
  border-radius: var(--border-radius);
  padding: 15px;
  box-shadow: var(--box-shadow);
  box-sizing: border-box;
}
.chart-box h3 {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 10px;
  text-align: center;
}

/* AI Analytics Modal — use visibility/opacity instead of display:none for Safari compat */
.modal-overlay {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  max-width: 400px;
  width: 90%;
  padding: 25px;
  text-align: center;
}
.modal-header h3 {
  color: var(--danger-red);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}
.modal-body {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 25px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--primary-blue);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-blue);
}
.btn-secondary {
  background: #E5E7EB;
  color: #4B5563;
}
.btn-secondary:hover {
  background: #D1D5DB;
}

/* Custom Checkbox & Overheating Styles */
.custom-select-wrapper {
  margin-top: 10px;
  display: none;
}
.custom-select-wrapper.show {
  display: flex;
}
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #4B5563;
  cursor: pointer;
}
.custom-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}


/* Active battery card border */
.battery-card.is-active {
  border-color: #10B981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.battery-card.is-overheating {
  border-color: #EF4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  animation: pulse-danger 2s infinite;
}
@keyframes pulse-danger {
  0% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 25px rgba(239, 68, 68, 0.7); }
  100% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }
}

/* Start/Stop Button Power States */
.start-system-btn.power-on {
  background-color: #FEE2E2;
  color: #DC2626;
  border-color: #FECACA;
}
.start-system-btn.power-on:hover {
  background-color: #FECACA;
}

/* ---- In Use Indicator: inline below header (no absolute position) ---- */
.in-use-indicator {
  position: static; /* override previous absolute */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  color: #10B981;
  border: 1px solid #10B981;
  margin-bottom: 10px;
}
.in-use-indicator.overheating {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  border-color: #EF4444;
}

/* ---- Maintenance Card: Suggestion Tier Glows ---- */
.maintenance-card.maint-healthy {
  border: 2px solid #10B981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
}
.maintenance-card.maint-warning {
  border: 2px solid #FBBF24;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.4);
}
.maintenance-card.maint-orange {
  border: 2px solid #F97316;
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.4);
}
.maintenance-card.maint-critical {
  border: 2px solid #EF4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.45);
}

/* ---- Suggestion Banner row inside maintenance card ---- */
.maint-suggestion-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 5px;
}
.maint-healthy-bg   { background: rgba(16, 185, 129, 0.1);  color: #065F46; }
.maint-warning-bg   { background: rgba(251, 191, 36, 0.15); color: #92400E; }
.maint-orange-bg    { background: rgba(249, 115, 22, 0.12); color: #9A3412; }
.maint-critical-bg  { background: rgba(239, 68, 68, 0.12);  color: #991B1B; }

.suggestion-icon { font-size: 1rem; }
