/* Sidebar background - covers full height */
@media (min-width: 768px) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 25%; /* col-md-3 */
        background-color: #212529;
        z-index: 99;
    }
}

@media (min-width: 992px) {
    body::before {
        width: 16.666667%; /* col-lg-2 */
    }
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: none;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    background-color: #212529;
}

.sidebar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Remove Bootstrap offcanvas border */
.offcanvas-md {
    border: none !important;
}


.sidebar-heading {
    font-size: .75rem;
    text-transform: uppercase;
}

.sidebar .nav-link {
    font-weight: 500;
    color: rgba(255, 255, 255, .75);
    font-size: 0.9rem;
    padding: .5rem 0.75rem;
    border-radius: 0.375rem;
    margin: 0.15rem 0.25rem;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, .1);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, .15);
}

.sidebar .nav-link i {
    color: rgba(255, 255, 255, .5);
}

.sidebar .nav-link.active i,
.sidebar .nav-link:hover i {
    color: inherit;
}

/* Main content */
main {
    padding-top: 1rem;
    border: none !important;
}

@media (max-width: 767.98px) {
    main {
        padding-top: 0.5rem;
    }
    main .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Charts */
.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 2rem;
}

.stat-card {
    border-left: 4px solid #0d6efd;
}

.stat-card.success {
    border-left-color: #198754;
}

.stat-card.warning {
    border-left-color: #ffc107;
}

.stat-card.danger {
    border-left-color: #dc3545;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #212529;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trend-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.trend-up {
    color: #198754;
    background-color: #d1e7dd;
}

.trend-down {
    color: #dc3545;
    background-color: #f8d7da;
}

/* Table customization */
.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Responsive */
@media (max-width: 767.98px) {
    .sidebar {
        top: 0;
    }

    .chart-container {
        height: 300px;
    }
}

/* Loading state */
.loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Compact nav link for longer text */
.nav-link-compact {
    font-size: 0.9rem !important;
    padding-top: 0.6rem !important;
    padding-bottom: 0.6rem !important;
}

/* RCE Analysis Dropdown Submenu */
#rceAnalysisSubmenu .nav-link {
    padding-left: 1.5rem;
    font-size: 0.9rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

#rceAnalysisSubmenu .nav-link.active {
    background-color: rgba(13, 110, 253, 0.15);
    border-left: 3px solid #0d6efd;
}

#rceAnalysisSubmenu .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Chevron rotation animation for dropdown */
.nav-link[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.3s ease;
    float: right;
}

.nav-link[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Mobile Header */
.mobile-header {
    z-index: 1031;
}

/* Offcanvas Sidebar */
@media (max-width: 767.98px) {
    .offcanvas-start {
        width: 280px !important;
    }

    .offcanvas-body .sidebar {
        position: static;
        height: auto;
    }

    /* Chart heights on mobile */
    .chart-container {
        height: 400px;
    }

    /* Touch-friendly sizing */
    .btn {
        min-height: 44px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Compact cards on mobile */
    .card-body {
        padding: 1rem;
    }

    /* Typography adjustments */
    h1, .h1 {
        font-size: 1.5rem;
    }

    h2, .h2 {
        font-size: 1.25rem;
    }

    /* Stat values */
    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .chart-container {
        height: 200px;
    }
}

/* Footer Styles */
.footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 150;
}

@media (min-width: 768px) {
    .footer {
        margin-left: 25%; /* col-md-3 width */
    }
}

@media (min-width: 992px) {
    .footer {
        margin-left: 16.666667%; /* col-lg-2 width */
    }
}

.footer-link:hover {
    color: #fff !important;
}

/* Certificate badges */
.cert-badge {
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.cert-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

a.cert-badge:hover {
    background-color: var(--bs-primary) !important;
    color: white !important;
}

a.cert-badge:hover i {
    color: white !important;
}

/* Breadcrumbs - using native Bootstrap styles */

/* ============================================
   MPPT Range Visualization Styles
   ============================================ */
.mppt-range-container {
    padding: 0.5rem 0;
}

.mppt-bar-wrapper {
    padding: 0.5rem 0;
}

.mppt-bar-container {
    position: relative;
    height: 28px;
    margin-bottom: 0.5rem;
}

.mppt-bar-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}

.mppt-zone {
    position: absolute;
    top: 0;
    height: 100%;
}

.mppt-zone-inactive {
    background: #dee2e6;
}

.mppt-zone-active {
    background: linear-gradient(90deg, #20c997 0%, #198754 50%, #20c997 100%);
}

.mppt-zone-warning {
    background: linear-gradient(90deg, #fd7e14 0%, #dc3545 100%);
    opacity: 0.6;
}

.mppt-marker {
    position: absolute;
    top: -2px;
    width: 3px;
    height: 32px;
    transform: translateX(-50%);
    border-radius: 2px;
}

.mppt-marker-mppt {
    background: #198754;
}

.mppt-marker-max {
    background: #dc3545;
}

.mppt-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.mppt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8rem;
    color: #495057;
}

.mppt-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: help;
}

.mppt-zone[data-bs-toggle="tooltip"],
.mppt-marker[data-bs-toggle="tooltip"] {
    cursor: help;
}

.mppt-range-container .badge[data-bs-toggle="tooltip"] {
    cursor: help;
}

.mppt-legend-color {
    display: inline-block;
    width: 20px;
    height: 12px;
    border-radius: 3px;
}

/* ============================================
   Variant & Similar Inverter Card Styles
   ============================================ */
.variant-card {
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
}

.variant-card:hover {
    border-color: #0d6efd;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.similar-inverter-card {
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
}

.similar-inverter-card:hover {
    border-color: #0d6efd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.similar-inverter-card .card-body {
    padding: 1rem;
}

.similar-inverter-card .card-title {
    color: #212529;
}

/* ============================================
   Hover Card Effect (shared across pages)
   ============================================ */
.hover-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Responsive adjustments for MPPT chart */
@media (max-width: 575.98px) {
    .mppt-legend {
        font-size: 0.7rem;
        gap: 0.5rem;
    }
}

/* ============================================
   Search Highlighting
   ============================================ */
.dropdown-item mark,
.search-result mark {
    background-color: #fff3cd;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: inherit;
}

/* ============================================
   Stats Page Hero
   ============================================ */
.stats-hero {
    background: linear-gradient(135deg, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.55) 50%, rgba(0,0,0,0.65) 100%),
                url('/static/images/pv-bg1.webp') center/cover no-repeat;
    border-radius: 12px;
    padding: 2rem;
    color: white;
}

.stats-hero-title {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 0.5rem;
}

.stats-hero-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

@media (max-width: 767.98px) {
    .stats-hero {
        padding: 1.25rem;
    }

    .stats-hero-title {
        font-size: 1.5rem;
    }

    .stats-hero-subtitle {
        font-size: 0.875rem;
    }
}

/* Offer Compare Hero Variant */
.offer-compare-hero {
    background: linear-gradient(135deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.2) 100%),
                url('/static/images/bgs/bg-01.webp') center/cover no-repeat;
}

/* ============================================
   Comparison Page Panel Colors
   ============================================ */
:root {
    --compare-panel1-color: #3B82F6;
    --compare-panel1-light: rgba(59, 130, 246, 0.1);
    --compare-panel2-color: #F59E0B;
    --compare-panel2-light: rgba(245, 158, 11, 0.1);
}

/* Winner Cell Highlighting */
.winner-cell {
    background-color: rgba(16, 185, 129, 0.15) !important;
    position: relative;
}
.winner-cell::after {
    content: '\2713';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #10B981;
    font-weight: bold;
}

/* Chart Container Sizing */
.chart-container-md {
    position: relative;
    min-height: 300px;
    width: 100%;
}

@media (max-width: 767.98px) {
    .chart-container-md {
        min-height: 250px;
    }
}

/* Touch Targets for Mobile */
@media (max-width: 767.98px) {
    .temp-scenario-btn,
    .btn-icon {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Panel Color Classes */
.panel1-text { color: var(--compare-panel1-color) !important; }
.panel2-text { color: var(--compare-panel2-color) !important; }
.panel1-bg { background-color: var(--compare-panel1-color) !important; }
.panel2-bg { background-color: var(--compare-panel2-color) !important; }
.panel1-border { border-color: var(--compare-panel1-color) !important; }
.panel2-border { border-color: var(--compare-panel2-color) !important; }

/* Panel Header Cards */
.panel-header-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.panel-header-card:hover {
    transform: translateY(-2px);
}
.panel1-card { border-color: var(--compare-panel1-color); border-width: 2px; }
.panel2-card { border-color: var(--compare-panel2-color); border-width: 2px; }

.panel-preview-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #1a1a2e;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    z-index: 0;
    opacity: 0.15;
    filter: blur(2px);
}
.panel-header-card .card-body {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 0.375rem;
}

/* Manufacturer Logo */
.manufacturer-logo-container {
    width: 64px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.manufacturer-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
/* Typography */
.manufacturer-name { font-size: 16px; font-weight: 600; }
.model-name { font-size: 14px; }

/* Power Badge */
.power-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    color: white;
    min-width: 70px;
}
.power-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.power-unit { font-size: 0.75rem; opacity: 0.9; }

/* Spec Badges Row */
.spec-badges-row {
    gap: 8px;
}
.spec-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
}
.spec-badge i {
    color: #64748b;
    font-size: 0.9rem;
}
.spec-badge .spec-label {
    color: #64748b;
    font-weight: 500;
}
.spec-badge .spec-value {
    color: #1e293b;
    font-weight: 600;
}

/* BEST SPECS Badge */
.best-value-ribbon {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    padding: 4px 10px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 4px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Icon Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Quick Compare Table */
.quick-compare-table th,
.quick-compare-table td {
    padding: 12px 16px;
}
.quick-compare-table .panel1-header { background: var(--compare-panel1-light); }
.quick-compare-table .panel2-header { background: var(--compare-panel2-light); }

/* Temperature Scenario Buttons */
.temp-scenario-btn {
    display: flex;
    align-items: center;
    text-align: left;
    padding: 12px 16px;
    min-height: 48px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease;
}
.temp-scenario-btn:hover {
    border-color: var(--compare-panel1-color);
    background: var(--compare-panel1-light);
}
.temp-scenario-btn.active {
    border-color: var(--compare-panel1-color);
    background: var(--compare-panel1-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.temp-scenario-btn .temp-value {
    font-weight: 600;
    margin-right: 8px;
}
.temp-scenario-btn .temp-label {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Recommendation Card */
#recommendationCard.winner-1 {
    background: linear-gradient(135deg, var(--compare-panel1-light) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-color: var(--compare-panel1-color);
}
#recommendationCard.winner-2 {
    background: linear-gradient(135deg, var(--compare-panel2-light) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-color: var(--compare-panel2-color);
}
#recommendationCard.tie {
    background: linear-gradient(135deg, rgba(108, 117, 125, 0.1) 0%, rgba(108, 117, 125, 0.05) 100%);
    border-color: #6c757d;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s, opacity 0.2s;
}
.back-to-top:hover {
    transform: scale(1.1);
}
.back-to-top.visible {
    display: flex;
}

/* Fade-in Animation */
.chart-fade-in {
    animation: chartFadeIn 0.5s ease-out;
}
@keyframes chartFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsive - Panel Cards */
@media (max-width: 767.98px) {
    .panel-header-card .card-body {
        padding: 16px;
    }
    .manufacturer-logo-container {
        width: 48px;
        height: 36px;
    }
    .power-badge {
        padding: 6px 10px;
        min-width: 60px;
    }
    .power-value { font-size: 1.25rem; }
    .temp-scenario-btn { min-height: 44px; padding: 10px 12px; }
}

/* Print Styles for Comparison Page */
@media print {
    .back-to-top,
    .dropdown,
    #backToTop {
        display: none !important;
    }

    .panel-header-card {
        break-inside: avoid;
    }

    .chart-container-md {
        min-height: 200px;
    }
}
