/* Regular screen styles */
.print-container { 
    display: none; 
}

/* Table specific styles for better content handling */
.overflow-x-auto {
    position: relative;
    margin: 0 auto;
    max-width: 100%;
}

/* Base table styles */
table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

/* Column widths and cell styles */
table th,
table td {
    text-wrap: auto !important;
    padding: 0.75rem 1rem;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    min-width: 100px;
}

/* Specific column widths */
table th:nth-child(1), table td:nth-child(1) { width: 12%; } /* Branch */
table th:nth-child(2), table td:nth-child(2) { width: 10%; } /* Brand */
table th:nth-child(3), table td:nth-child(3) { width: 15%; } /* Product */
table th:nth-child(4), table td:nth-child(4) { width: 12%; } /* SKU */
table th:nth-child(5), table td:nth-child(5) { width: 12%; } /* Batch Code */
table th:nth-child(6), table td:nth-child(6) { width: 12%; } /* Expiry Date */
table th:nth-child(7), table td:nth-child(7) { width: 12%; } /* Category */
table th:nth-child(8), table td:nth-child(8) { width: 7%; }  /* Status */
table th:nth-child(9), table td:nth-child(9) { width: 8%; }  /* Actions */

/* Cell content styling */
.text-cell {
    max-height: 4.5em;
    line-height: 1.5;
    overflow: hidden;
    position: relative;
}

/* Show ellipsis for overflowing content */
.text-cell::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30%;
    height: 1.5em;
    background: linear-gradient(to right, transparent, white 50%);
}

/* Hover state to show full content */
td:hover .text-cell {
    max-height: none;
    overflow: visible;
    z-index: 1;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 4px;
    border-radius: 4px;
}

td:hover .text-cell::after {
    display: none;
}

/* Filter inputs styling */
.column-filter {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

/* Time filter pills container */
.time-filters {
    padding: 1rem 0;
    border-radius: 0.5rem;
}

/* Individual pill styling */
.time-filter-pill {
    color: #6c7180;
    font-size: 12px;
    background: #ffffff;
    outline: 0;
    transition: all 0.2s ease-in-out;
    border: 1px solid #00000024;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

/* Hover state */
.time-filter-pill:hover {
    outline: none;
    color: #fff;
    background: #000000;
    box-shadow: 0 0 0 1px rgb(5 5 5);
}

/* Active/Selected state */
.time-filter-pill.active {
    outline: none;
    color: #fff;
    background: #000000;
    box-shadow: 0 0 0 1px rgb(5 5 5);
}

/* Click animation */
.time-filter-pill:active {
    outline: none;
    color: #fff;
    background: #000000;
    box-shadow: 0 0 0 1px rgb(5 5 5);
}

/* Focus state */
.time-filter-pill:focus {
    outline: none;
    color: #fff;
    background: #000000;
    box-shadow: 0 0 0 1px rgb(5 5 5);
}

/* Ripple effect */
.time-filter-pill::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform .5s, opacity 1s;
}

.time-filter-pill:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* Disabled state */
.time-filter-pill:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Container gap and wrap handling */
.time-filters .flex {
    gap: 0.5rem;
}

/* Make sure active state is prominent */
.time-filter-pill[data-timeframe="all"].active {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* Responsive adjustments */
@media screen and (max-width: 1024px) {
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 1000px;
    }
    
    th, td {
        min-width: 120px;
    }
    
    .text-cell {
        max-height: 6em;
    }
    
    .time-filters .flex {
        flex-wrap: wrap;
    }
    
    .time-filter-pill {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Print styles */
@page {
    size: 100mm 50mm;
    margin: 0;
}

@media print {
    body * {
        display: none;
    }
    
    .print-container,
    .print-container * {
        display: block !important;
        visibility: visible !important;
    }
    
    .print-container {
        text-transform: capitalize !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100mm !important;
        height: 50mm !important;
        margin: 10px !important;
        padding: 3mm !important;
        box-sizing: border-box !important;
        background-color: white !important;
        font-family: Arial, sans-serif !important;
    }

    .product-header {
        font-size: 10px !important;
        line-height: 1.2 !important;
        margin-bottom: 1mm !important;
    }

    #printBrand {
        font-weight: bold !important;
        margin-top: 8px !important;
    }

    .qr-container {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 1mm !important;
        margin-top: 1mm !important;
        height: 35mm !important;
    }

    .qr-section {
        width: 45mm !important;
        text-align: left !important;
        position: relative !important;
        margin: 5px 0 !important;
    }

    .qr-code {
        width: 65px !important;
        height: 65px !important;
        margin: 0 auto !important;
        float: left !important;
        left: 0 !important;
        border-radius: 3px;
        border: 0px solid #000;
        padding: 4px
    }

    .qr-code img {
        color: red;
        width: 10px !important;
        height: 10px !important;
        display: none !important;
        float: left !important;
        left: 0 !important;
        padding: 4px !important;
        border: 0px solid #000 !important;
    }

    .qr-divider {
        width: 0.5mm !important;
        background-color: #000 !important;
        height: 35mm !important;
        margin: 0 1mm !important;
    }

    .code-text {
        font-size: 10px !important;
        font-weight: bold !important;
        margin-top: 68px !important;
        text-align: left !important;
    }

    .batch-code {
        font-size: 10px !important;
        font-weight: bold !important;
        margin-top: 68px !important;
        text-align: left !important;
    }

    .logo {
        background: red;
        height: 40px !important;
        weight: 40px !important;
        position: absolute;
        float: right;
        right: 30px;
        top: 0px
    }

    .logo img {
        height: 40px !important;
        weight: 40px !important;
    }

    .expiry-date {
        font-size: 10px !important;
        margin-top: 0px !important;
        text-align: left !important;
        bottom: 15px !important;
    }
}

/* A4 Print styles */
@media print {
    .print-container-a4 {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 297mm !important;
        height: 210mm !important;
        margin: 10mm !important;
        padding: 10mm !important;
        box-sizing: border-box !important;
        background-color: white !important;
        font-family: Arial, sans-serif !important;
        page: a4-landscape;
    }

    .print-container-a4 .product-header {
        position: relative !important;
        margin-bottom: 20mm !important;
        padding: 5mm !important;
    }

    .print-container-a4 #printBranchA4 {
        font-size: 24pt !important;
        margin-bottom: 5mm !important;
        color: #000 !important;
        display: block !important;
    }

    .print-container-a4 #printBrandA4 {
        font-size: 28pt !important;
        font-weight: bold !important;
        margin-bottom: 5mm !important;
        color: #000 !important;
        display: block !important;
    }

    .print-container-a4 #printProductA4 {
        font-size: 24pt !important;
        color: #000 !important;
        display: block !important;
    }

    .print-container-a4 .qr-container-a4 {
        display: flex !important;
        justify-content: space-around !important;
        align-items: flex-start !important;
        width: 100% !important;
        margin-top: 20mm !important;
    }

    .print-container-a4 .qr-section-a4 {
        width: 45% !important;
        text-align: center !important;
    }

    .print-container-a4 .qr-code-a4 {
        width: 80mm !important;
        height: 80mm !important;
        margin: 0 auto 10mm auto !important;
    }

    .print-container-a4 .qr-code-a4 img {
        width: 100% !important;
        height: 100% !important;
    }

    .print-container-a4 #printSKUA4 {
        font-size: 20pt !important;
        margin-top: 5mm !important;
        color: #000 !important;
        display: block !important;
    }

    .print-container-a4 #printBatchCodeA4 {
        font-size: 20pt !important;
        font-weight: bold !important;
        margin-top: 5mm !important;
        color: #000 !important;
        display: block !important;
    }

    .print-container-a4 #printExpiryDateA4 {
        font-size: 20pt !important;
        margin-top: 5mm !important;
        color: #000 !important;
        display: block !important;
    }

    .print-container-a4 .qr-divider-a4 {
        width: 1mm !important;
        background-color: #000 !important;
        height: 100mm !important;
        margin: 0 5mm !important;
    }

    .print-container-a4 * {
        visibility: visible !important;
        display: block !important;
        color: #000 !important;
    }
}