/* Reports-specific styles */
#reportSection.report-card,
#fuelAnalysisSection.report-card {
    background: #f3f4f6;
    backdrop-filter: blur(20px);
    border-radius: 0;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    display: none !important;
}

#reportSection.report-card.show,
#fuelAnalysisSection.report-card.show {
    display: block !important;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.report-title h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.report-meta {
    color: #6b7280;
    font-weight: 500;
    text-align: left;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-item {
    background: linear-gradient(135deg, #ffffff, #f9fafb);
    padding: 1.5rem;
    border-radius: 0;
    text-align: center;
    border: 1px solid #e5e7eb;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.summary-label {
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
}

.table-container {
    background: #ffffff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    border: 1px solid #e5e7eb;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: linear-gradient(135deg, #1f2937, #374151);
    color: white;
    padding: 1rem;
    text-align: center;
    font-weight: 600;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 11px;
    color: #374151;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}

.loading-overlay.show {
    display: flex !important;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #000000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-overlay h3 {
    color: #1f2937;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.loading-overlay p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.cancel-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
}

.cancel-btn:hover {
    background: #dc2626;
}

.print-header {
    display: none;
}

.print-footer {
    display: none;
}

/* Mobile-specific report styles */
@media (max-width: 768px) {
    .report-card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .report-header {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Print styles for reports */
@media print {
    body {
        background: white !important;
        margin: 0;
        padding: 0;
    }

    /* Hide everything by default */
    * {
        visibility: hidden;
    }

    /* Show only the report section and its contents */
    #reportSection,
    #reportSection *,
    #fuelAnalysisSection,
    #fuelAnalysisSection * {
        visibility: visible;
    }

    /* Hide unwanted elements within report section */
    .report-header {
        display: none !important;
    }

    .config-card,
    .nav-menu,
    .header-card,
    .main-container > *:not(#reportContent),
    #reportContent > *:not(#reportSection):not(#fuelAnalysisSection) {
        display: none !important;
    }

    /* Hide specific elements from printing */
    .header-card,
    .nav-menu,
    .config-card {
        display: none !important;
        visibility: hidden !important;
    }

    /* Style the elements we want to show */
    #reportSection,
    #fuelAnalysisSection {
        position: static !important;
        display: block !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        page-break-inside: avoid;
    }

    .print-header {
        display: block !important;
/*        text-align: center; */
        margin-bottom: 20px;
        visibility: visible !important;
    }

    .print-header h1 {
        font-size: 24px !important;
        text-align: center;
        color: #333 !important;
        margin-bottom: 10px !important;
    }

    .print-header .device-name,
    .print-header .report-date {
        font-size: 12px !important;
        color: #666 !important;
        margin: 5px 0 !important;
        text-align: left !important;
    }

    #printReportPeriod {
        font-size: 12px !important;
        color: #666 !important;
        margin: 5px 0 !important;
        text-align: left !important;
    }


    .summary-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        margin: 20px 0 !important;
        page-break-inside: avoid;
        visibility: visible !important;
    }

    .summary-item {
        background: #f5f5f5 !important;
        border: 1px solid #ddd !important;
        padding: 10px !important;
        text-align: center !important;
        border-radius: 0 !important;
        visibility: visible !important;
    }

    .summary-value {
        font-size: 16px !important;
        font-weight: bold !important;
        color: #333 !important;
    }

    .summary-label {
        font-size: 11px !important;
        color: #666 !important;
    }

    .table-container {
        background: white !important;
        border: 1px solid #333 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 20px 0 !important;
        visibility: visible !important;
    }

    .data-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 8px !important;
        table-layout: fixed !important;
        visibility: visible !important;
    }

    .data-table th {
        background: #333 !important;
        color: white !important;
        padding: 6px 2px !important;
        text-align: left !important;
        font-weight: bold !important;
        border: 1px solid #333 !important;
        font-size: 8px !important;
    }

    .data-table td {
        padding: 4px 2px !important;
        border: 1px solid #ddd !important;
        color: #333 !important;
        word-wrap: break-word;
        font-size: 8px !important;
        max-width: 120px;
    }

    /* Column width distribution for print */
    .data-table th:nth-child(1),
    .data-table td:nth-child(1) { /* Start Time */
        width: 15% !important;
        max-width: 100px !important;
    }

    .data-table th:nth-child(2),
    .data-table td:nth-child(2) { /* End Time */
        width: 15% !important;
        max-width: 100px !important;
    }

    .data-table th:nth-child(3),
    .data-table td:nth-child(3) { /* Start Location */
        width: 20% !important;
        max-width: 120px !important;
    }

    .data-table th:nth-child(4),
    .data-table td:nth-child(4) { /* End Location */
        width: 20% !important;
        max-width: 120px !important;
    }

    .data-table th:nth-child(5),
    .data-table td:nth-child(5) { /* Distance */
        width: 10% !important;
        max-width: 70px !important;
    }

    .data-table th:nth-child(6),
    .data-table td:nth-child(6) { /* Duration */
        width: 10% !important;
        max-width: 70px !important;
    }

    .data-table th:nth-child(7),
    .data-table td:nth-child(7) { /* Refueling */
        width: 10% !important;
        max-width: 60px !important;
        min-width: 40px !important;
        visibility: visible !important;
        display: table-cell !important;
    }

    /* Print-specific styling for refueling badges */
    .refuel-event,
    .refuel-multiple {
        background-color: #f0f0f0 !important;
        color: #333 !important;
        padding: 1px 2px !important;
        border: 1px solid #ddd !important;
        border-radius: 2px !important;
        font-size: 7px !important;
        font-weight: bold !important;
        display: inline-block !important;
        line-height: 1.2 !important;
    }

    .data-table tbody tr:nth-child(even) {
        background: #f9f9f9 !important;
    }

    .print-footer {
        display: block !important;
        text-align: center;
        margin-top: 20px;
        border-top: 1px solid #ddd;
        padding-top: 10px;
        visibility: visible !important;
    }

    .print-footer img {
        height: 30px !important;
        width: auto;
    }
}