/**
 * Reports Page Responsive Styles
 * Optimized for mobile, tablet, and desktop
 */

/* Reports Table Responsive */
.reports-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .reports-table-wrapper table {
        font-size: 0.85rem;
    }
    
    .reports-table-wrapper th,
    .reports-table-wrapper td {
        padding: 0.5rem;
    }
    
    .reports-table-wrapper .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

@media (max-width: 480px) {
    .reports-table-wrapper table {
        font-size: 0.75rem;
    }
    
    .reports-table-wrapper th,
    .reports-table-wrapper td {
        padding: 0.4rem 0.3rem;
    }
    
    .reports-table-wrapper .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.3rem;
    }
}

/* Page Header with Actions */
.reports-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .reports-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .reports-page-header > div:last-child {
        width: 100%;
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .reports-page-header .btn {
        flex: 1;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .reports-page-header h1 {
        font-size: 1.25rem;
    }
    
    .reports-page-header .btn {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }
}

/* Report Filter Bar */
.reports-filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .reports-filter-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .reports-filter-bar input,
    .reports-filter-bar select {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .reports-filter-bar {
        gap: 0.5rem;
    }
    
    .reports-filter-bar input,
    .reports-filter-bar select {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }
}

/* Report Cards Grid */
.reports-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .reports-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .reports-cards-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .reports-cards-grid > div {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .reports-cards-grid {
        gap: 0.5rem;
    }
    
    .reports-cards-grid > div {
        padding: 0.6rem;
    }
}

/* Report Summary Stats */
.report-summary-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .report-summary-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .report-summary-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .report-summary-stats > div {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .report-summary-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .report-summary-stats > div {
        padding: 0.6rem;
    }
    
    .report-summary-stats .stat-value {
        font-size: 1.25rem !important;
    }
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
}

@media (max-width: 768px) {
    .chart-container {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 150px;
    }
}

/* Report Actions Bar */
.report-actions-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .report-actions-bar {
        flex-wrap: wrap;
    }
    
    .report-actions-bar .btn {
        flex: 1;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .report-actions-bar {
        gap: 0.4rem;
    }
    
    .report-actions-bar .btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.6rem;
    }
}

/* Compact Table for Mobile */
@media (max-width: 480px) {
    .reports-table-wrapper .hide-mobile {
        display: none;
    }
}

/* Empty State */
.reports-empty-state {
    text-align: center;
    padding: 3rem;
}

@media (max-width: 768px) {
    .reports-empty-state {
        padding: 2rem;
    }
    
    .reports-empty-state svg {
        width: 48px;
        height: 48px;
    }
    
    .reports-empty-state h3 {
        font-size: 1rem;
    }
    
    .reports-empty-state p {
        font-size: 0.85rem;
    }
}

/* Date Range Picker */
.date-range-picker {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .date-range-picker {
        flex-direction: column;
    }
    
    .date-range-picker input {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .date-range-picker input {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }
}

/* Print Styles moved to consolidated block at footer */

/* Export Options */
.export-options {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 480px) {
    .export-options {
        flex-direction: column;
    }
    
    .export-options .btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    /* Hide sidebar/navigation and topbar */
    aside,
    .sidebar,
    .navigation,
    .nav-menu,
    .topbar,
    .sidebar-overlay {
        display: none !important;
        width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide page header buttons and back link, but keep title */
    .page-header a,
    .page-header .flex {
        display: none !important;
    }
    
    /* Hide summary stat cards */
    .summary-cards,
    .report-summary-stats,
    .inventory-stats-grid,
    .card[data-summary="true"] {
        display: none !important;
    }
    
    /* Hide filter forms */
    .card:has(form) {
        display: none !important;
    }
    
    /* Hide tab navigation card */
    .card:has(.tab-btn) {
        display: none !important;
    }
    
    /* Hide tab navigation buttons */
    .tab-btn {
        display: none !important;
    }
    
    /* Hide all tab panes except the active one */
    .tab-pane {
        display: none !important;
    }
    
    /* Show only the active tab pane */
    .tab-pane.active {
        display: block !important;
    }
    
    /* Hide export/print buttons in card headers */
    .card-header .flex {
        display: none !important;
    }
    
    /* Hide Chart.js canvas (charts don't print well) */
    canvas {
        display: none !important;
    }
    
    /* Hide canvas parent if canvas is hidden */
    .p-4:has(canvas) {
        display: none !important;
    }
    
    /* Force single page starting point and reset viewport-related heights */
    html,
    body,
    .app-wrapper,
    .main-content,
    .page-content,
    .content-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        overflow: visible !important;
        float: none !important;
        position: static !important;
    }
    
    body {
        padding: 10px !important;
        font-size: 11pt;
        background: white !important;
    }
    
    .no-print,
    .reports-page-header,
    .reports-filter-bar,
    .report-actions-bar {
        display: none !important;
    }
    
    /* Improve page header for print */
    .page-header {
        border-bottom: 2px solid #333;
        padding-bottom: 10px;
        margin-bottom: 20px;
    }
    
    .page-header h1 {
        font-size: 18pt;
        color: #000;
        margin: 0;
    }
    
    .page-subtitle {
        font-size: 10pt;
        color: #666;
        margin-top: 5px;
    }
    
    /* Improve card styling for print */
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: auto;
        margin-bottom: 20px;
        width: 100% !important;
    }
    
    .card-header {
        background: #f5f5f5;
        border-bottom: 1px solid #ddd;
        padding: 10px;
        page-break-after: avoid;
    }
    
    .card-title {
        font-size: 14pt;
        font-weight: bold;
        color: #000;
        margin: 0;
    }
    
    .card-header .text-muted {
        display: none;
    }
    
    /* Improve table styling for print */
    .data-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt;
    }
    
    .data-table thead {
        background: #f5f5f5;
    }
    
    .data-table th {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
        font-weight: bold;
        color: #000;
    }
    
    .data-table td {
        border: 1px solid #ddd;
        padding: 8px;
        color: #000;
    }
    
    .data-table tfoot {
        background: #f5f5f5;
        font-weight: bold;
    }
    
    /* Remove color classes for print */
    .text-red-600,
    .text-green-600,
    .text-blue-600,
    .text-purple-600,
    .text-orange-600,
    .text-teal-600,
    .text-muted {
        color: #000 !important;
    }
    
    /* Remove badges background for print */
    .badge {
        background: none !important;
        color: #000 !important;
        border: 1px solid #ddd;
    }
    
    .reports-table-wrapper {
        overflow: visible !important;
    }
    
    .reports-table-wrapper table {
        font-size: 10pt;
    }
    
    /* Table pagination */
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    /* Remove links decoration for print */
    a {
        color: #000;
        text-decoration: none;
    }
}
