/* Unified Responsive Receipt Styles */
/* This file replaces mobile-receipt-fix.css with a single responsive design */

/* CSS Variables for consistent theming */
:root {
    --receipt-bg: #ffffff;
    --receipt-border: #e9ecef;
    --receipt-text: #212529;
    --receipt-muted: #6c757d;
    --receipt-primary: #0d6efd;
    --receipt-success: #198754;
    --receipt-shadow: rgba(0, 0, 0, 0.1);
    --receipt-radius: 12px;
    --receipt-spacing: 1rem;
}

/* Base Receipt Modal Styles */
.receipt-modal .modal-dialog {
    max-width: min(90vw, 800px);
    margin: 1rem auto;
    transition: all 0.3s ease;
}

.receipt-modal .modal-content {
    border: none;
    border-radius: var(--receipt-radius);
    box-shadow: 0 10px 30px var(--receipt-shadow);
    background: var(--receipt-bg);
}

.receipt-modal .modal-header {
    background: var(--receipt-bg);
    border-bottom: 1px solid var(--receipt-border);
    padding: var(--receipt-spacing);
    border-radius: var(--receipt-radius) var(--receipt-radius) 0 0;
}

.receipt-modal .modal-body {
    background: var(--receipt-bg);
    padding: var(--receipt-spacing);
    max-height: 70vh;
    overflow-y: auto;
}

.receipt-modal .modal-footer {
    background: var(--receipt-bg);
    border-top: 1px solid var(--receipt-border);
    padding: var(--receipt-spacing);
    border-radius: 0 0 var(--receipt-radius) var(--receipt-radius);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

/* Receipt Container - Responsive Base */
.receipt-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--receipt-text);
    line-height: 1.5;
    background: var(--receipt-bg);
}

/* Receipt Header - Responsive */
.receipt-header {
    text-align: center;
    margin-bottom: clamp(1rem, 3vw, 2rem);
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--receipt-border);
}

.receipt-header img {
    max-height: clamp(40px, 8vw, 80px);
    width: auto;
    margin-bottom: 0.75rem;
}

.receipt-header h3 {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 600;
    color: var(--receipt-primary);
    margin-bottom: 0.5rem;
}

.receipt-header p {
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    color: var(--receipt-muted);
    margin-bottom: 0.25rem;
}

/* Receipt Info Section - Responsive Grid */
.receipt-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: clamp(0.75rem, 3vw, 1.25rem);
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.receipt-info-item {
    display: flex;
    flex-direction: column;
}

.receipt-info-item strong {
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    color: var(--receipt-text);
    margin-bottom: 0.25rem;
}

.receipt-info-item span {
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    color: var(--receipt-muted);
}

.receipt-info-item .badge {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    padding: 0.25em 0.6em;
    color: white !important;
    background-color: var(--bs-success) !important;
}

/* Receipt Items Table - Responsive */
.receipt-items {
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.receipt-items h5 {
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--receipt-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive Table Container */
.receipt-table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    background: var(--receipt-bg);
}

.receipt-table th {
    background: #f8f9fa;
    padding: clamp(0.5rem, 2vw, 0.75rem);
    font-weight: 600;
    text-align: left;
    border-bottom: 2px solid var(--receipt-border);
    white-space: nowrap;
}

.receipt-table td {
    padding: clamp(0.5rem, 2vw, 0.75rem);
    border-bottom: 1px solid var(--receipt-border);
    vertical-align: middle;
}

.receipt-table .text-center {
    text-align: center;
}

.receipt-table .text-end {
    text-align: right;
}

.receipt-table .fw-bold {
    font-weight: 600;
}

/* Receipt Totals - Responsive Card */
.receipt-totals {
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.receipt-totals-card {
    background: var(--receipt-bg);
    border: 1px solid var(--receipt-border);
    border-radius: 10px;
    padding: clamp(0.75rem, 3vw, 1.25rem);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.receipt-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
}

.receipt-total-row:last-child {
    margin-bottom: 0;
}

.receipt-total-row.final {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    font-weight: 600;
    color: var(--receipt-primary);
    padding-top: 0.75rem;
    border-top: 2px solid var(--receipt-border);
    margin-top: 0.75rem;
}

/* Receipt Footer */
.receipt-footer {
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
    padding: clamp(0.75rem, 3vw, 1.25rem);
    margin-top: clamp(1rem, 3vw, 1.5rem);
}

.receipt-footer strong {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: var(--receipt-text);
    display: block;
    margin-bottom: 0.5rem;
}

.receipt-footer small {
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    color: var(--receipt-muted);
    line-height: 1.4;
}

/* Modal Footer Buttons - Responsive */
.receipt-modal .modal-footer .btn {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.75rem, 3vw, 1rem);
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.receipt-modal .modal-footer .btn i {
    margin-right: 0.5rem;
}

/* Responsive Breakpoints */

/* Small Mobile (320px - 480px) */
@media (max-width: 480px) {
    .receipt-modal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    
    .receipt-info {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .receipt-table th,
    .receipt-table td {
        padding: 0.375rem 0.25rem;
    }
    
    .receipt-table th:first-child,
    .receipt-table td:first-child {
        padding-left: 0.5rem;
    }
    
    .receipt-table th:last-child,
    .receipt-table td:last-child {
        padding-right: 0.5rem;
    }
    
    .receipt-modal .modal-footer {
        flex-direction: column;
    }
    
    .receipt-modal .modal-footer .btn {
        flex: none;
        width: 100%;
        margin: 0.125rem 0;
    }
}

/* Medium Mobile (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .receipt-modal .modal-dialog {
        margin: 0.75rem;
        max-width: calc(100vw - 1.5rem);
    }
    
    .receipt-info {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .receipt-modal .modal-footer .btn {
        flex: 0 1 calc(50% - 0.25rem);
    }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .receipt-modal .modal-dialog {
        max-width: 700px;
    }
    
    .receipt-info {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (1025px+) */
@media (min-width: 1025px) {
    .receipt-modal .modal-dialog {
        max-width: 800px;
    }
    
    .receipt-info {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .receipt-modal .modal-footer .btn {
        flex: 0 1 auto;
        min-width: 140px;
    }
}

/* Print Styles - Unified for all devices */
@media print {
    .receipt-modal .modal-header,
    .receipt-modal .modal-footer {
        display: none !important;
    }
    
    .receipt-modal .modal-dialog {
        margin: 0;
        max-width: 100%;
        width: 100%;
    }
    
    .receipt-modal .modal-content {
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    
    .receipt-modal .modal-body {
        padding: 0;
        max-height: none;
        overflow: visible;
    }
    
    .receipt-container {
        font-size: 12pt;
        color: black;
        background: white;
    }
    
    .receipt-header img {
        max-height: 60px;
    }
    
    .receipt-table {
        font-size: 10pt;
    }
    
    .receipt-totals-card {
        border: 1px solid #000;
    }
    
    .receipt-footer {
        font-size: 9pt;
        background: white;
        border: 1px solid #000;
    }
    
    /* Ensure proper page breaks */
    .receipt-container {
        page-break-inside: avoid;
    }
    
    .receipt-items {
        page-break-inside: avoid;
    }
}

/* PDF Export Optimization */
.pdf-export .receipt-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    color: black;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --receipt-bg: #ffffff;
        --receipt-border: #e9ecef;
        --receipt-text: #212529;
        --receipt-muted: #6c757d;
    }
    
    /* Keep receipt always light for better printing */
    .receipt-modal .modal-content,
    .receipt-container,
    .receipt-totals-card,
    .receipt-info {
        background: #ffffff !important;
        color: #212529 !important;
    }
    
    /* Ensure badges remain visible in dark mode */
    .receipt-info .badge {
        color: white !important;
        background-color: #198754 !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --receipt-border: #000000;
        --receipt-shadow: rgba(0, 0, 0, 0.3);
    }
    
    .receipt-table th,
    .receipt-table td {
        border-color: #000000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .receipt-modal .modal-dialog,
    .receipt-modal .modal-footer .btn {
        transition: none;
    }
}

/* Focus Management for Accessibility */
.receipt-modal .modal-content:focus {
    outline: 2px solid var(--receipt-primary);
    outline-offset: 2px;
}

.receipt-modal .btn:focus {
    outline: 2px solid var(--receipt-primary);
    outline-offset: 2px;
}

/* Loading State */
.receipt-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    font-size: 1rem;
    color: var(--receipt-muted);
}

.receipt-loading .spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--receipt-border);
    border-top: 3px solid var(--receipt-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

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

/* Error State */
.receipt-error {
    text-align: center;
    padding: 2rem;
    color: #dc3545;
}

.receipt-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}