/* POS Receipt Styles - Receipt Modal, Print Layout, and Controls */

/* ===================================
   RECEIPT PRINTING OPTIONS STYLES
   =================================== */

.pos-receipt-options {
    margin-bottom: 15px;
}

.pos-receipt-options label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
    font-size: 14px;
}

.print-mode-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #374151;
    transition: border-color 0.2s ease;
}

.print-mode-select:focus {
    outline: none;
    border-color: #31ad75;
    box-shadow: 0 0 0 3px rgba(49, 173, 117, 0.1);
}

/* Print Button Styles */
.btn-print {
    background: #6366f1;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-print:hover:not(:disabled) {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-print:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-print::before {
    content: "🖨";
    font-size: 16px;
}

/* Action Buttons Group */
.action-buttons-group {
    display: flex;
    gap: 8px;
    flex: 1;
}

.action-buttons-group .btn-primary {
    flex: 1;
}

.action-buttons-group .btn-print {
    min-width: 80px;
    flex: 0 0 auto;
}

/* ===================================
   RECEIPT MODAL STYLES
   =================================== */

.pos-receipt-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.receipt-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    max-height: 90vh;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { 
        transform: translateY(-20px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

.receipt-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.receipt-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.receipt-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    transition: all 0.2s ease;
}

.receipt-modal-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.receipt-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    max-height: 60vh;
}

.receipt-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.receipt-modal-footer button {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

#modal-print-btn {
    background: #31ad75;
    color: white;
}

#modal-print-btn:hover {
    background: #2d9968;
}

#modal-close-btn {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

#modal-close-btn:hover {
    background: #e5e7eb;
}

/* ===================================
   RECEIPT CONTENT STYLES
   =================================== */

.receipt-content {
    padding: 20px;
}

.pos-receipt-print {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    color: #000;
    background: white;
    max-width: 100%;
    margin: 0 auto;
}

/* Business Header */
.receipt-business-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #000;
}

.business-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.business-address,
.business-contact,
.business-tax {
    font-size: 12px;
    margin-bottom: 2px;
    color: #333;
}

/* Transaction Header */
.receipt-transaction-header {
    margin-bottom: 15px;
}

.transaction-separator {
    border-top: 1px dashed #000;
    margin: 8px 0;
}

.transaction-info {
    margin: 10px 0;
}

.transaction-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
    align-items: center;
}

.transaction-row .label {
    font-weight: bold;
    min-width: 80px;
}

.transaction-row .value {
    text-align: right;
    flex: 1;
}

/* Items List */
.receipt-items-list {
    margin-bottom: 15px;
}

.receipt-item {
    margin-bottom: 8px;
    padding-bottom: 5px;
}

.item-name {
    font-weight: bold;
    margin-bottom: 2px;
    word-wrap: break-word;
}

.item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.item-qty-price {
    color: #666;
}

.item-total {
    font-weight: bold;
}

/* Totals Section */
.receipt-totals-section {
    margin-bottom: 15px;
}

.totals-separator {
    border-top: 2px solid #000;
    margin: 8px 0;
}

.receipt-totals {
    margin: 10px 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
    align-items: center;
}

.total-row.grand-total {
    font-size: 14px;
    font-weight: bold;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 5px 0;
    margin: 8px 0;
}

.total-row .label {
    font-weight: bold;
}

.total-row .value {
    font-weight: bold;
}

/* Receipt Footer */
.receipt-footer {
    text-align: center;
    font-size: 12px;
    font-style: italic;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #000;
}

.receipt-print-info {
    text-align: center;
    font-size: 10px;
    color: #666;
    margin-top: 10px;
    padding-top: 5px;
}

.print-timestamp {
    font-size: 10px;
    color: #999;
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    /* Hide everything except receipt content when printing */
    body * {
        visibility: hidden;
    }
    
    .pos-receipt-print,
    .pos-receipt-print * {
        visibility: visible;
    }
    
    .pos-receipt-print {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        font-size: 12px;
    }
    
    /* Hide modal and non-print elements */
    .pos-receipt-modal,
    .receipt-modal-content,
    .receipt-modal-header,
    .receipt-modal-footer,
    .no-print {
        display: none !important;
    }
    
    /* Optimize for thermal printer width (58mm or 80mm) */
    @page {
        size: 80mm auto;
        margin: 0;
        padding: 0;
    }
    
    .pos-receipt-print {
        width: 80mm;
        padding: 2mm;
        margin: 0;
        font-size: 11px;
    }
    
    .business-name {
        font-size: 14px;
    }
    
    .transaction-row,
    .total-row {
        font-size: 11px;
    }
    
    .total-row.grand-total {
        font-size: 12px;
    }
    
    .item-details {
        font-size: 10px;
    }
    
    .receipt-footer {
        font-size: 10px;
    }
    
    .print-timestamp {
        font-size: 8px;
    }
}

/* ===================================
   RESPONSIVE STYLES
   =================================== */

/* Mobile Styles */
@media (max-width: 768px) {
    .pos-receipt-modal {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .receipt-modal-content {
        width: 100%;
        max-width: none;
        max-height: calc(100vh - 40px);
        margin: 0;
        border-radius: 8px;
    }
    
    .receipt-modal-header,
    .receipt-modal-footer {
        padding: 15px 20px;
    }
    
    .receipt-modal-header h3 {
        font-size: 16px;
    }
    
    .receipt-content {
        padding: 15px;
    }
    
    .pos-receipt-print {
        font-size: 12px;
    }
    
    .business-name {
        font-size: 14px;
    }
    
    .receipt-modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .receipt-modal-footer button {
        width: 100%;
        padding: 12px;
    }
    
    /* Adjust action buttons for mobile */
    .action-buttons-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .action-buttons-group .btn-primary,
    .action-buttons-group .btn-print {
        flex: none;
        width: 100%;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .receipt-modal-header,
    .receipt-modal-footer {
        padding: 12px 16px;
    }
    
    .receipt-content {
        padding: 12px;
    }
    
    .pos-receipt-print {
        font-size: 11px;
    }
    
    .business-name {
        font-size: 13px;
    }
    
    .print-mode-select {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* ===================================
   ACCESSIBILITY STYLES
   =================================== */

/* Focus styles for keyboard navigation */
.receipt-modal-close:focus,
#modal-print-btn:focus,
#modal-close-btn:focus,
.print-mode-select:focus {
    outline: 2px solid #31ad75;
    outline-offset: 2px;
}

.receipt-modal-close:focus:not(:focus-visible),
#modal-print-btn:focus:not(:focus-visible),
#modal-close-btn:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pos-receipt-print {
        background: white;
        color: black;
    }
    
    .receipt-business-header,
    .transaction-separator,
    .totals-separator {
        border-color: black;
    }
    
    .receipt-modal-content {
        border: 2px solid black;
    }
    
    .receipt-modal-header,
    .receipt-modal-footer {
        background: white;
        border-color: black;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pos-receipt-modal,
    .receipt-modal-content {
        animation: none;
    }
    
    * {
        transition-duration: 0.01ms !important;
    }
}

/* ===================================
   PRINT WINDOW STYLES
   =================================== */

/* Styles for the dedicated print window */
.receipt-print-window {
    font-family: 'Courier New', monospace;
    margin: 0;
    padding: 10px;
    background: white;
}

.receipt-print-controls {
    text-align: center;
    margin: 20px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 5px;
}

.receipt-print-controls button {
    margin: 0 5px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.receipt-print-controls button:first-child {
    background: #31ad75;
    color: white;
}

.receipt-print-controls button:last-child {
    background: #6b7280;
    color: white;
}

.receipt-print-controls button:hover {
    opacity: 0.9;
}

/* ===================================
   LOADING STATES
   =================================== */

.receipt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6b7280;
}

.receipt-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #31ad75;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

.receipt-loading-text {
    font-size: 14px;
    color: #6b7280;
}

/* ===================================
   ERROR STATES
   =================================== */

.receipt-error {
    padding: 20px;
    text-align: center;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin: 20px;
}

.receipt-error-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.receipt-error-message {
    font-weight: 500;
    margin-bottom: 5px;
}

.receipt-error-details {
    font-size: 12px;
    color: #991b1b;
}

/* ===================================
   THERMAL PRINTER OPTIMIZATIONS
   =================================== */

/* Optimize for common thermal printer widths */
@media print and (max-width: 58mm) {
    .pos-receipt-print {
        width: 58mm;
        font-size: 10px;
    }
    
    .business-name {
        font-size: 12px;
    }
    
    .transaction-row,
    .total-row {
        font-size: 9px;
    }
    
    .item-details {
        font-size: 8px;
    }
    
    .receipt-footer {
        font-size: 8px;
    }
}

/* ===================================
   UTILITY CLASSES
   =================================== */

.receipt-text-center {
    text-align: center;
}

.receipt-text-left {
    text-align: left;
}

.receipt-text-right {
    text-align: right;
}

.receipt-bold {
    font-weight: bold;
}

.receipt-italic {
    font-style: italic;
}

.receipt-underline {
    text-decoration: underline;
}

.receipt-no-print {
    display: none;
}

@media screen {
    .receipt-print-only {
        display: none;
    }
}