/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 2rem;
  border-bottom: 2px solid #f0f0f0;
  padding: 0 20px;
}

#directComparisonMode,
#yoyMode {
  padding: 0 20px 40px;
}

/* Compare-specific loading overlay */
.compare-loading-overlay {
  position: absolute;
  width: calc(100% - 20px);
  left: 10px;
  transform: none;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255);
  border: 2px solid #ccc;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  font-size: 3rem;
  color: #f5a623;
}

.compare-loading-overlay.active {
  display: flex;
}
.controls button:disabled,
.controls select:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.mode-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  color: #666;
  border-bottom: 3px solid transparent;
  font-family: inherit;
}
.mode-tab:hover:not(:disabled) {
  color: #333;
}
.mode-tab.active {
  color: #0066cc;
  border-bottom-color: #0066cc;
}
.mode-tab:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Controls */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.controls-left,
.controls-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Forces building dropdowns onto their own line in the controls bar */
.controls-break {
  flex: 0 0 100%;
  height: 0;
}

/* Groups all building selectors + add button as a single flex unit */
.building-controls-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Each building's label+select stays paired */
#buildingAControls,
#buildingBControls,
#buildingCControls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Card Container & Cards */
#cardContainer {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
#buildingCardA,
#buildingCardB,
#buildingCardC {
  flex: 1 1 300px;
  min-width: 300px;
}
.building-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 20px 24px;
  margin-top: 20px;
  width: 100%;
  min-height: 180px;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.card-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}
.card-info {
  flex: 1;
}
.card-data {
  flex: 1;
  text-align: right;
}
.card-data hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 8px 0;
}
.building-card h2 {
  margin: 0 0 12px 0;
  font-size: 1.4em;
}
.building-card p {
  margin: 6px 0;
  font-size: 1em;
  color: #333;
}

/* Solar Tooltip stolen from LUKE. Thanks Luke! */
.tt {
  position: relative;
  display: inline-block;
  min-width: 24px;
  min-height: 24px;
  margin-left: 6px;
}

.tt .solar-icon {
  font-size: 20px;
}
.tt-bubble {
  position: absolute;
  left: 50%;
  bottom: 140%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  background: #222;
  color: #fff;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 9999;
}
.tt-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #222;
}
.tt:hover .tt-bubble,
.tt:focus .tt-bubble {
  opacity: 1;
  visibility: visible;
}

/* EUI Highlighting for most efficient and least efficient buildings */
#eui-display-A,
#eui-display-B,
#eui-display-C {
  padding: 4px 8px;
  border-radius: 4px;
}
.eui-best {
  background-color: #d4edda;
  color: #155724;
  font-weight: 600;
}
.eui-worst {
  background-color: #f8d7da;
  color: #721c24;
  font-weight: 600;
}

/* Charts Container */
#chartsContainer,
#yoyChartsContainer {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
  align-items: stretch;
}
/* Shared chart card base styles */
#kwhCard,
#euiCard,
#yoyKwhEuiCard,
#yoyTrendCard {
  flex: 1 1 calc(50% - 12px);
  min-width: 450px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 20px;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
#kwhCard h3,
#euiCard h3 {
  margin: 0 0 12px 0;
  font-size: 1.1em;
  color: #333;
}

/* Data Table Styles */
.data-table-details {
  margin-top: 16px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  background: #f9f9f9;
}

.data-table-details summary {
  cursor: pointer;
  font-weight: 600;
  color: #0066cc;
  user-select: none;
  padding: 4px 0;
}

.data-table-details summary:hover {
  text-decoration: underline;
}

.data-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 0.9em;
}

.data-table thead {
  background-color: #f5f5f5;
}

.data-table th {
  text-align: left;
  padding: 10px 8px;
  font-weight: 600;
  border-bottom: 2px solid #ddd;
  color: #333;
}

.data-table td {
  padding: 8px;
  border-bottom: 1px solid #eee;
}

.data-table tbody tr.row-odd {
  background-color: #fafafa;
}

.data-table tbody tr.row-even {
  background-color: #fff;
}

.data-table tbody tr:hover {
  background-color: #f0f7ff;
}
#euiCard {
  flex: 0 1 400px;
}
/* YoY building card sizes to content, not full width */
#yoyCardContainer {
  display: flex;
  justify-content: flex-start;
}

#yoyCardContainer .building-card {
  width: auto;
  min-width: 280px;
  max-width: 400px;
  flex: none;
}

/* YoY tabbed cards (KWH/EUI + Trend) */
#yoyKwhEuiCard,
#yoyTrendCard {
  max-width: 700px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.yoy-chart-tabs {
  display: flex;
  gap: 0;
  padding: 0 0 0 12px;
  margin: 0;
  min-height: 36px;
  align-items: flex-end;
  background: #f0f0f0;
  border-bottom: 1px solid #ddd;
}
.yoy-chart-tab {
  padding: 8px 20px 10px;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  color: #555;
  margin-right: 2px;
  font-family: inherit;
}
.yoy-chart-tab:hover {
  color: #333;
  background: #e8e8e8;
}
.yoy-chart-tab.active {
  color: #0066cc;
  font-weight: 600;
  background: #fff;
  margin-bottom: -1px;
  padding-bottom: 11px;
  position: relative;
  z-index: 1;
  border-bottom: 1px solid #fff;
}
.yoy-chart-card-body {
  background: #fff;
  padding: 20px;
}
.yoy-chart-panel {
  display: block;
}
.yoy-chart-panel.hidden {
  display: none;
}

/* YoY calendar popup */
#yoyCalendar .calendar-grid {
  grid-template-columns: repeat(4, 1fr);
}

/* Building name styling for building cards */
h2 {
  color: var(--button-color);
}

.direct-container,
.yoy-container {
  position: relative;
  min-height: 200px;
}

@media (max-width: 1024px) and (min-width: 769px) {
  .controls {
    gap: 10px;
    padding: 16px;
  }

  .controls select {
    max-width: 200px;
  }
}

@media (max-width: 768px) {
  .compare-loading-overlay {
    width: calc(100% - 20px);
    left: 10px;
    top: 0;
    bottom: 0;
    height: auto;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 16px;
  }

  .calendar-dropdown {
    width: 100%;
    margin-right: 0;
  }

  .cal-nav-group {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-toggle {
    flex: 1;
  }

  .tag-filter {
    width: 100%;
  }

  .tag-filter-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .controls label {
    margin-top: 4px;
  }

  .controls select {
    width: 100%;
    box-sizing: border-box;
  }

  .building-controls-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  #buildingAControls,
  #buildingBControls:not([style*="none"]),
  #buildingCControls:not([style*="none"]) {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
    white-space: normal;
  }

  #addBuildingBtn {
    width: 100%;
    box-sizing: border-box;
  }

  #buildingCardA,
  #buildingCardB,
  #buildingCardC {
    flex: none;
    min-width: unset;
    width: 100%;
  }

  #yoyCardContainer .building-card {
    min-width: unset;
    max-width: 100%;
    width: 100%;
  }

  #cardContainer {
    flex-direction: column;
  }

  #directComparisonMode,
  #yoyMode {
    overflow-x: hidden;
  }

  .direct-container,
  .yoy-container {
    width: 100%;
    min-width: 0;
  }

  #chartsContainer,
  #yoyChartsContainer {
    flex-direction: column;
    width: 100%;
    min-width: 0;
  }

  #kwhCard,
  #euiCard,
  #yoyKwhEuiCard,
  #yoyTrendCard {
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  canvas {
    width: 100% !important;
    height: auto !important;
  }

  .building-card {
    margin-top: 0px;
  }

  .data-table-details {
    overflow-x: auto;
  }
}

/* Text fields inside building cards */
.building-card .card-info strong,  /* SQFT/TYPE */
.building-card .card-data strong {
  /* Monthly/Annual/KWH/EUI */
  color: var(--button-color);
}
