/* === CHARGING HISTORY PAGE STYLES === */
/* Adapted from remote-start.css */

.table-section-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* MODIFICATION: Updated table controls styling */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.table-controls-left,
.table-controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.table-controls select,
.table-controls input[type="search"] {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
  color: var(--text-primary);
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  transition: all 0.3s ease;
}

.table-controls input[type="search"] {
  min-width: 250px;
}

.table-controls select:focus,
.table-controls input[type="search"]:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(54, 153, 255, 0.2);
}

.control-btn {
  background-color: var(--active-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 6px;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.control-btn:hover {
  border-color: var(--accent-blue);
  background-color: var(--accent-blue);
  color: #fff;
}

.control-btn.btn-download {
  background-color: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.control-btn.btn-download:hover {
  background-color: #45b879;
  border-color: #45b879;
}

.control-btn.btn-apply-filters {
  /* Style for Apply Filters button in popup */
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.control-btn.btn-apply-filters:hover {
  background-color: #3699ff;
  /* slightly darker blue on hover */
  border-color: #3699ff;
}

/* --- TABLE STYLES --- */
.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.data-table thead th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
  background-color: var(--active-bg);
}

.cell-primary {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.cell-secondary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.td-transaction {
  font-weight: 600;
  color: var(--accent-blue);
}

.td-energy,
.td-cost {
  font-weight: 600;
  color: var(--text-primary);
}

.action-link {
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  color: var(--accent-blue);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.action-link:hover {
  background-color: var(--active-bg);
  text-decoration: underline;
}

.action-link.link-invoice {
  color: var(--accent-green);
}

/* --- PAGINATION STYLES --- */
.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  flex-wrap: wrap;
  /* Allow pagination to wrap on smaller screens */
  gap: 15px;
  /* Spacing between pagination info and controls */
}

.pagination-nav ul {
  display: flex;
  list-style: none;
  gap: 4px;
}

.pagination-nav li a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  text-decoration: none;
  color: var(--text-secondary);
  background-color: var(--active-bg);
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pagination-nav li a:hover {
  background-color: var(--accent-blue);
  color: #fff;
}

.pagination-nav li.active a {
  background-color: var(--accent-blue);
  color: #fff;
  font-weight: 600;
}

.pagination-nav li.disabled a {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--active-bg);
  color: var(--text-muted);
}

.pagination-button {
  background-color: var(--card-bg);
  /* Use card background for buttons */
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  /* Ensure consistent width for page numbers */
}

.pagination-button:hover:not(:disabled) {
  border-color: var(--accent-blue);
  background-color: var(--accent-blue);
  color: #fff;
}

.pagination-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background-color: var(--active-bg);
  /* A slightly different disabled background */
}

.pagination-button.active {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
  font-weight: 600;
}

.pagination-nav span {
  /* Styles for the '...' dots */
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 0;
  /* Align vertically with buttons */
}

/* ================================== */
/* === HISTORY POPUP STYLES === */
/* ================================== */

/* --- Main Container & Backdrop --- */
/* ... (all previous CSS styles are unchanged up to this point) ... */

/* ... (all previous CSS styles for the main page are unchanged up to this point) ... */

/* ================================== */
/* === HISTORY POPUP STYLES (REVISED) === */
/* ================================== */

/* --- Main Container & Backdrop --- */
.history-popup-container,
.filter-popup-container {
  /* Combine styling for both popups */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  visibility: hidden;
  pointer-events: none;
}

.history-popup-container.is-open,
.filter-popup-container.is-open {
  visibility: visible;
  pointer-events: all;
}

.popup-backdrop,
.filter-backdrop {
  /* Combine styling for both backdrops */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.history-popup-container.is-open .popup-backdrop,
.filter-popup-container.is-open .filter-backdrop {
  opacity: 1;
}

/* --- Content & Grid Layout (History Popup) --- */
.popup-content {
  /* Original for history popup */
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  width: 100%;
  max-width: 1100px;
  padding: 24px;
  background: var(--bg-color, #fffbf1);
  border-radius: 20px;
  border: 1px solid var(--border-color, #3a3f51);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: scale(0.95);
  transition:
    transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.3s ease;
}

.history-popup-container.is-open .popup-content {
  opacity: 1;
  transform: scale(1);
}

/* --- Content & Grid Layout (Filter Popup) --- */
.filter-content {
  position: relative;
  display: flex;
  /* Changed to flex for single card layout */
  flex-direction: column;
  width: 100%;
  max-width: 500px;
  /* Smaller max-width for filter popup */
  padding: 20px;
  /* background: var(--bg-color); */
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: scale(0.95);
  transition:
    transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.3s ease;
}

.filter-popup-container.is-open .filter-content {
  opacity: 1;
  transform: scale(1);
}

/* --- Base Card & Close Button (Combined/Modified) --- */
.popup-card,
.filter-card {
  /* Combined card styles, .filter-card specific overrides below */
  background-color: var(--card-bg);
  padding: 20px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.popup-close-btn {
  /* Apply to both history and filter popups */
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--active-bg);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 5;
}

.popup-close-btn:hover {
  background-color: #e53935;
  color: #fff;
  border-color: #e53935;
}

/* --- Headers, Dropdowns, Stats (for History Popup) --- */
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.popup-dropdown {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 8px;
  background-color: var(--accent-green);
  color: #fff;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.popup-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- Station Specs Card --- */
.charging-status-bar {
  background-color: var(--active-bg);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
}

.charging-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.charging-time {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.car-controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-top: auto;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* --- Session Details Card (Progress Bar Changed) --- */
.savings-chart-container {
  margin-top: auto;
}

.chart-labels {
  display: flex;
}

.chart-label-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
  border-left: 1px solid var(--border-color);
}

.chart-label-item:first-child {
  border-left: none;
}

.chart-value {
  font-weight: 600;
  color: var(--text-primary);
  padding-left: 12px;
}

.chart-label {
  font-size: 12px;
  color: var(--text-secondary);
  padding-left: 12px;
  word-break: break-all;
}

/* NEW/REVISED Progress Range Bar */
.progress-range-bar {
  position: relative;
  width: 100%;
  height: 25px;
  background-color: var(--active-bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-range-inner {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #8e2de2, #4a00e0);
  border-radius: 4px;
}

.range-label-start,
.range-label-end {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.range-label-start {
  left: 8px;
}

.range-label-end {
  right: 8px;
}

/* --- Graph Card Styles --- */
.graph-card {
  min-height: 250px;
}

.graph-legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.voltage {
  background-color: #3498db;
}

.legend-dot.soc {
  background-color: #2ecc71;
}

.graph-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
}

/* Hide CanvasJS branding */
.canvasjs-chart-credit {
  display: none !important;
}

/* --- Cost & Billing Card Styles --- */
.cost-billing-card {
  justify-content: space-between;
  /* width: 205%; */
}

.billing-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.billing-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.billing-list li:last-child {
  border-bottom: none;
}

.item-label {
  color: var(--text-secondary);
}

.item-value {
  color: var(--text-primary);
  font-weight: 600;
}

.billing-divider {
  border: none;
  height: 1px;
  background-color: var(--border-color);
  width: 100%;
  margin: 0;
}

.billing-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.total-label {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.total-value {
  font-weight: 700;
  font-size: 20px;
  color: var(--accent-green);
}

/* --- Filter Popup Specific Styles --- */
.filter-card .popup-title {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
}

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-item label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.filter-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--active-bg);
  color: var(--text-primary);
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
  /* Include padding in width calculation */
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(54, 153, 255, 0.2);
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  /* Align buttons to the right */
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  /* Separator */
  margin-top: auto;
  /* Push actions to the bottom */
}

/* --- Responsive Adjustments --- */
@media (max-width: 992px) {
  .popup-content {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow-y: auto;
  }

  .filter-content {
    max-width: 90vw;
    /* Adjust for smaller screens */
  }
}

@media (max-width: 576px) {
  .popup-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  }

  .popup-content {
    padding: 16px;
    gap: 16px;
  }

  .filter-content {
    padding: 16px;
  }

  .filter-actions {
    flex-direction: column;
    /* Stack buttons on very small screens */
  }
}

/* NEW STYLED PROGRESS BAR (from image) */
.styled-progress-bar {
  display: flex;
  width: 100%;
  height: 35px;
  /* Increased height to match image */
  border-radius: 4px;
  overflow: hidden;
  background-color: var(--active-bg, #2a2e3b);
  position: relative;
}

.bar-segment {
  height: 100%;
  position: relative;
}

/* Adds the subtle glowing dividers between segments */
.bar-segment:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 15%;
  right: 0;
  width: 2px;
  height: 70%;
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.1);
  filter: blur(0.5px);
}

/* Section 1: Purple with inner shadow glow */
.bar-segment.purple-glow {
  flex-basis: 50%;
  background: linear-gradient(100deg, #305b93, #448fff);
  box-shadow:
    inset 0 8px 12px -5px rgba(0, 0, 0, 0.5),
    inset 0 -8px 12px -5px rgba(0, 0, 0, 0.5);
}

/* Section 2: Pink with soft diagonal 'wavy' lines */
.bar-segment.pink-wavy {
  flex-basis: 28%;
  background-color: #336d22;
  background-image: repeating-linear-gradient(
    -55deg,
    transparent,
    transparent 2.5px,
    rgba(102, 245, 35, 0.5) 2.5px,
    rgba(149, 255, 128, 0.5) 5px
  );
}

/* Section 3: Yellow vertical lines that fade from the bottom */
.bar-segment.yellow-faded-lines {
  flex-basis: 22%;
  background-image: repeating-linear-gradient(
    to right,
    transparent,
    transparent 2px,
    #ff0707 2px,
    #ff0707 3px
  );
  /* Mask is used to create the fade-out effect */
  mask-image: linear-gradient(to top, rgb(187, 65, 65) 40%, transparent 80%);
  -webkit-mask-image: linear-gradient(
    to top,
    rgb(143, 74, 74) 40%,
    transparent 80%
  );
}
