/* === 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;
}

/* --- 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;
}

/* ================================== */
/* === 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 {
    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 {
    visibility: visible;
    pointer-events: all;
}

.popup-backdrop {
    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 {
    opacity: 1;
}

/* --- Content & Grid Layout --- */
.popup-content {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    width: 100%;
    max-width: 1100px;
    padding: 24px;
    background: var(--bg-color, #fffbf1);
    /* Corrected dark mode fallback */
    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);
}

/* --- Base Card & Close Button --- */
.popup-card {
    background-color: var(--card-bg, #2a2e3b);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.popup-close-btn {
    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 --- */
.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;
}

/* Font size adjusted */
.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;
}

.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);
}

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

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

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


/* 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%);
}

/* ... (all your existing CSS is unchanged) ... */


/* ===================================================== */
/* === NEW & IMPROVED: TIME-BASED PRICING STYLES ======= */
/* ===================================================== */

/* --- Main Section Layout --- */
.pricing-section {
    margin-top: 24px;
}

.pricing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

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

.btn-save-changes {
    background-color: #EF4444; /* Red color from image */
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.btn-save-changes:hover {
    background-color: #DC2626; /* Darker red on hover */
}

/* --- Grid Container --- */
.pricing-grid {
    display: grid;
    /* This creates a responsive grid that fits as many cards as possible */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* --- Time Slot Card Styling --- */
.time-slot-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px; /* More pronounced rounded corners */
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.time-slot-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.slot-title {
    font-size: 16px;
    font-weight: 700; /* Bolder title */
    color: var(--text-primary);
    margin: 0;
}

.delete-slot-btn {
    background: none;
    border: none;
    color: #F87171; /* Softer red for delete icon */
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.delete-slot-btn:hover {
    color: #EF4444;
}

/* --- Form Fields & Inputs --- */
.slot-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--active-bg);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

/* Positioning for icons inside inputs */
.input-icon {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    pointer-events: none; /* Allows clicking through the icon */
}

.currency-symbol {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
}

/* Add padding to input text to avoid overlapping the symbol */
.input-with-symbol {
    padding-left: 28px !important;
}


/* --- "Add Time Slot" Card --- */
.add-slot-card {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    background-color: transparent;
    cursor: pointer;
    min-height: 210px; /* Ensures it aligns with other cards */
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    width: 100%;
    padding: 20px;
    font-family: 'Poppins', sans-serif;
}

.add-slot-card span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.add-slot-card:hover {
    border-color: var(--accent-blue);
    background-color: var(--active-bg);
}

.add-slot-card:hover span {
    color: var(--accent-blue);
}

/* ... (all your existing CSS is unchanged) ... */


/* ===================================================== */
/* === NEW: TARIFF CONTEXT CARD STYLES ================= */
/* ===================================================== */

.tariff-context-card {
    display: grid;
    /* Creates 3 columns on larger screens, and wraps to 1 on smaller screens */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px; /* Creates space between this card and the pricing section */
}

.context-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: var(--active-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.context-icon-wrapper {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Color coding for each icon for better visual distinction */
.context-icon-wrapper.station {
    background-color: rgba(54, 153, 255, 0.15);
    color: #3699FF;
}

.context-icon-wrapper.charge-point {
    background-color: rgba(26, 188, 156, 0.15);
    color: #1ABC9C;
}

.context-icon-wrapper.location {
    background-color: rgba(241, 196, 15, 0.15);
    color: #F1C40F;
}

.context-text {
    overflow: hidden; /* Prevents long text from breaking the layout */
}

.context-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    display: block; /* Ensures it sits on its own line */
}

.context-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 4px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds '...' if the text is too long */
}

/* ... (all your existing CSS is unchanged) ... */

/* ===================================================== */
/* === NEW: HEADER & BACK BUTTON STYLES ================ */
/* ===================================================== */

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 16px; /* Creates space between the button and the title */
}

.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.back-btn:hover {
     background: radial-gradient(ellipse at top, #580b1d, var(--main-bg) 100%);
    border-color: var(--accent-blue);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(54, 153, 255, 0.2);
}

.back-btn i {
    font-size: 13px; /* Slightly smaller icon */
}

.main-title {
    margin: 0; /* Ensures proper vertical alignment */
}