/* Matrix Statistics Grid Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
}

.stat-box {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-right: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.stat-box:last-child {
    border-right: none;
}

.stats-grid:last-child .stat-box {
    border-bottom: none;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: white;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #2c3e50;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.stat-date {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-box:nth-child(2n) {
        border-right: none;
    }
    
    .stat-box:nth-last-child(-n+2) {
        border-bottom: none;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-box {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .stat-box:last-child {
        border-bottom: none;
    }
}

/* Info Icon Styles */
.info-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.1);
    color: #495057;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    transition: all 0.2s ease;
    text-decoration: none;
    z-index: 1;
    margin: 0;
    padding: 0;
}

.info-icon.text-muted {
    background-color: rgba(0, 0, 0, 0.05);
    color: #6c757d;
}

.info-icon.text-dark {
    background-color: rgba(0, 0, 0, 0.1);
    color: #212529;
}

.info-icon:hover {
    background-color: rgba(0, 0, 0, 0.15);
    transform: scale(1.1);
}

/* Ensure parent containers have proper positioning */
.card,
.card-header,
.card-body,
.position-relative,
.hourly-summary-row .card,
.summary-stats-column .card {
    position: relative !important;
}

/* Specific positioning for different containers */
.card-header .info-icon {
    top: 12px;
    right: 12px;
}

.card-body .info-icon {
    top: 8px;
    right: 8px;
}

/* For cards in the summary stats column */
.summary-stats-column .card .info-icon {
    top: 8px;
    right: 8px;
}

/* For hourly summary row */
.hourly-summary-row .card .info-icon {
    top: 8px;
    right: 8px;
}

/* For production legend */
.card .card-body .info-icon {
    top: 12px;
    right: 12px;
}

/* Ensure icons in headings are properly positioned */
h3 .info-icon,
.h3 .info-icon,
.h4 .info-icon,
.h5 .info-icon {
    position: absolute;
    top: 0.25rem;
    right: 0;
    margin: 0;
}

/* Position relative for cards with info icons */
.card {
    position: relative;
}

/* Add spacing between System Configuration and results */
#system-configuration-card {
    margin-bottom: 1.5rem !important;
}

/* Font sizes in System Configuration section */
#system-configuration-card {
    font-size: 1.075rem; /* Slightly larger than default */
}

#system-configuration-card .form-label,
#system-configuration-card h4 {
    font-size: 1.15rem; /* Slightly larger for headings */
    margin-bottom: 0.5rem;
}

#system-configuration-card .form-control,
#system-configuration-card .form-select,
#system-configuration-card .form-range,
#system-configuration-card .form-text,
#system-configuration-card small,
#system-configuration-card .text-muted {
    font-size: 1.075rem; /* Match base size */
}

#system-configuration-card .btn {
    font-size: 1.075rem; /* Buttons text */
}

/* Style the results section */
#results-section {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Style the results cards */
#results-section .card {
    height: 100%;
    transition: all 0.3s ease;
}

#results-section .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Ensure consistent card heights in the results row */
#results-section .row > [class*='col-'] {
    display: flex;
    flex-direction: column;
}

#results-section .card-body {
    flex: 1;
}

/* Tooltip Styles */
.tooltip-inner {
    max-width: 250px;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Custom Typography - Inconsolata for headings, Fira Code for body */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.card-title,
.page-title,
.navbar-brand,
.btn {
    font-family: 'Inconsolata', monospace !important;
    font-weight: 500 !important;
}

body,
p, span, div,
.form-control,
.form-label,
.text-muted,
.small,
td, th,
.alert,
.badge {
    font-family: 'Fira Code', monospace !important;
    font-weight: 400 !important;
    line-height: 1.6 !important;
}

/* Matrix Table Styling */
.matrix-table {
    font-size: 0.75rem;
    border-collapse: separate;
    border-spacing: 1px;
}

.matrix-cell {
    width: 40px;
    height: 30px;
    padding: 2px;
    text-align: center;
    vertical-align: middle;
    font-weight: 500;
    font-size: 0.7rem;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.date-cell {
    position: sticky;
    left: 0;
    background: #f8f9fa;
    font-weight: 600;
    min-width: 60px;  /* Reduced from 80px */
    max-width: 60px;  /* Added to prevent expansion */
    width: 60px;      /* Fixed width */
    padding: 0 4px;   /* Reduced padding */
    font-size: 0.7rem; /* Slightly smaller font */
    white-space: nowrap; /* Keep text on one line */
    overflow: hidden;  /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis if text is too long */
    z-index: 10;
    border-right: 2px solid #dee2e6;
    text-align: center; /* Center the date text */
}

/* Energy Color Classes - Enhanced Green Scale */
.matrix-table td.energy-very-high,
.table-responsive .matrix-table td.energy-very-high {
    background-color: #166534 !important; /* Dark green - highest production */
    color: #f0fdf4 !important;
    font-weight: 700 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-high,
.table-responsive .matrix-table td.energy-high {
    background-color: #15803d !important; /* Dark green */
    color: #f0fdf4 !important;
    font-weight: 600 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-medium-high,
.table-responsive .matrix-table td.energy-medium-high {
    background-color: #16a34a !important; /* Medium dark green */
    color: #f0fdf4 !important;
    font-weight: 600 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-medium,
.table-responsive .matrix-table td.energy-medium {
    background-color: #22c55e !important; /* Medium green */
    color: #f0fdf4 !important;
    font-weight: 500 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-medium-low,
.table-responsive .matrix-table td.energy-medium-low {
    background-color: #4ade80 !important; /* Medium light green */
    color: #052e16 !important;
    font-weight: 500 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-low,
.table-responsive .matrix-table td.energy-low {
    background-color: #86efac !important; /* Light green */
    color: #052e16 !important;
    font-weight: 500 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-very-low,
.table-responsive .matrix-table td.energy-very-low {
    background-color: #bbf7d0 !important; /* Very light green */
    color: #052e16 !important;
    font-weight: 400 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-minimal,
.table-responsive .matrix-table td.energy-minimal {
    background-color: #dcfce7 !important; /* Pale green */
    color: #052e16 !important;
    font-weight: 400 !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05) inset !important;
}

.matrix-table td.energy-none,
.table-responsive .matrix-table td.energy-none {
    background-color: #f8fafc !important; /* Very light gray */
    color: #94a3b8 !important;
    font-style: italic !important;
    font-weight: 300 !important;
    box-shadow: none !important;
}

/* Matrix cell hover effects */
.matrix-cell:hover {
    transform: scale(1.1);
    z-index: 5;
    border: 2px solid #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Hour headers */
.hour-header {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 8;
}

/* Tilt info styling */
.tilt-info {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
    font-weight: 500;
    padding: 4px 8px;
    background: rgba(107, 114, 128, 0.1);
    border-radius: 4px;
    border-left: 3px solid #3b82f6;
}

/* Matrix summary cards */
#matrix-summary .text-center {
    padding: 1rem;
}

#matrix-summary .card {
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .matrix-cell {
        width: 30px;
        height: 25px;
        font-size: 0.6rem;
        padding: 1px;
    }
    
    .date-cell {
        min-width: 60px;
        font-size: 0.7rem;
    }
}

/* Custom styles for logo and app name */
.navbar-brand {
    font-size: 1.75rem !important; /* Increase font size for the brand name */
}

.navbar-brand .icon {
    width: 36px !important; /* Increase icon width */
    height: 36px !important; /* Increase icon height */
}

/* Hourly Summary Table - IMPROVED VERSION */
.hourly-summary-row .summary-stats-column .card {
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease-in-out;
}

.hourly-summary-row .summary-stats-column .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.hourly-summary-row .summary-stats-column .card .info-icon {
    background-color: rgba(0, 0, 0, 0.05);
    color: #6c757d;
}

.hourly-summary-row .summary-stats-column .card .info-icon:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.hourly-summary-row .summary-stats-column .card.bg-blue-lt {
    background-color: #e0f2fe !important; /* Light blue */
    border-color: #90cdf4 !important;
}

.hourly-summary-row .summary-stats-column .card.bg-orange-lt {
    background-color: #fff7ed !important; /* Light orange */
    border-color: #fed7aa !important;
}

.hourly-summary-row .summary-stats-column .card.border-dark {
    border-color: #343a40 !important;
}

.hourly-summary-row .summary-stats-column .card .h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hourly-summary-row .summary-stats-column .card .h5 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.hourly-summary-row .summary-stats-column .card .small {
    font-size: 0.75rem;
}

.hourly-summary-row .summary-stats-column .card .text-muted {
    color: #6c757d !important;
}

.hourly-summary-row .summary-stats-column .card .info-icon {
    color: #495057;
}

.hourly-summary-row .summary-stats-column .card .info-icon:hover {
    color: #212529;
}

/* Ensure the main content container respects the max-width and padding */
.main-grid-container {
    max-width: 900px; /* Fixed width as per user preference */
    padding-left: var(--tblr-body-padding-x, 1rem); /* Dynamic padding */
    padding-right: var(--tblr-body-padding-x, 1rem); /* Dynamic padding */
    margin-left: auto; /* Center the container */
    margin-right: auto; /* Center the container */
}

header.navbar {
    margin-bottom: 0 !important;
}

/* Quick Start / Advanced Mode Styles */
.advanced-only {
    display: none !important;
}

body[data-mode='advanced'] .advanced-only {
    display: block !important;
}

/* Mode selector styling */
.btn-check:checked + .btn-outline-success {
    background-color: #198754;
    border-color: #198754;
    color: white;
}

.btn-check:checked + .btn-outline-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}


/* Quick Start / Advanced Mode Styles */
.advanced-only {
    display: none !important;
}

body[data-mode='advanced'] .advanced-only {
    display: block !important;
}

/* Mode selector styling */
.btn-check:checked + .btn-outline-success {
    background-color: #198754;
    border-color: #198754;
    color: white;
}

.btn-check:checked + .btn-outline-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

/* Key Metrics Font Size Enhancements */
.card-body .row .col-md-3 .h5 {
    font-size: 2rem !important;
    font-weight: 700 !important;
}

.card-body .row .col-md-3 .text-muted {
    font-size: 1rem !important;
    font-weight: 500 !important;
}

/* Energy Balance Matrix Color Coding */
.balance-excess-high {
    background-color: #22c55e !important;
    color: white !important;
    font-weight: 600;
}

.balance-excess-medium {
    background-color: #65f47a !important;
    color: #166534 !important;
    font-weight: 500;
}

.balance-excess-low {
    background-color: #bbf7d0 !important;
    color: #166534 !important;
}

.balance-deficit-high {
    background-color: #ef4444 !important;
    color: white !important;
    font-weight: 600;
}

.balance-deficit-medium {
    background-color: #f87171 !important;
    color: white !important;
    font-weight: 500;
}

.balance-deficit-low {
    background-color: #fecaca !important;
    color: #991b1b !important;
}

.balance-neutral {
    background-color: #f3f4f6 !important;
    color: #6b7280 !important;
}

/* Balance Matrix Table Styling */
#balance-matrix-table {
    font-size: 0.6rem;
    width: 100%;
    table-layout: fixed;
}

#balance-matrix-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    text-align: center;
    padding: 0.2rem 0.1rem;
    width: 3.8%;
    font-size: 0.55rem;
}

#balance-matrix-table th:first-child {
    width: 8%;
    font-size: 0.6rem;
}

#balance-matrix-table td {
    text-align: center;
    padding: 0.15rem 0.05rem;
    border: 1px solid #dee2e6;
    width: 3.8%;
    font-size: 0.55rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#balance-matrix-table td:first-child {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    left: 0;
    z-index: 1;
    width: 8%;
    font-size: 0.6rem;
}

/* Balance Matrix Container */
.balance-matrix-container {
    width: 100%;
    overflow-x: hidden;
}

.balance-matrix-container .table-responsive {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Responsive adjustments for balance matrix */
@media (max-width: 1200px) {
    #balance-matrix-table {
        font-size: 0.55rem;
    }
    
    #balance-matrix-table th,
    #balance-matrix-table td {
        padding: 0.1rem 0.05rem;
        font-size: 0.5rem;
    }
    
    #balance-matrix-table th:first-child,
    #balance-matrix-table td:first-child {
        font-size: 0.55rem;
    }
}

@media (max-width: 768px) {
    #balance-matrix-table {
        font-size: 0.5rem;
    }
    
    #balance-matrix-table th,
    #balance-matrix-table td {
        padding: 0.1rem 0.02rem;
        font-size: 0.45rem;
    }
    
    #balance-matrix-table th:first-child,
    #balance-matrix-table td:first-child {
        font-size: 0.5rem;
        width: 10%;
    }
}

/* Self-Consumption Analysis Box Values */
#annual-self-consumption,
#energy-independence,
#excess-energy,
#grid-consumption {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    line-height: 1.2;
}

/* Responsive adjustments for self-consumption values */
@media (max-width: 1200px) {
    #annual-self-consumption,
    #energy-independence,
    #excess-energy,
    #grid-consumption {
        font-size: 2.2rem !important;
    }
}

@media (max-width: 768px) {
    #annual-self-consumption,
    #energy-independence,
    #excess-energy,
    #grid-consumption {
        font-size: 1.8rem !important;
    }
}
