// main: ./main.less
/* ==========================================
   Fitwhey Sure - Extra Styles
   ========================================== */

/* --- Root-level: Barcode Scanner Modal (outside .lab-test-page) --- */

.barcode-scanner-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.barcode-scanner-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.barcode-scanner-container {
    background: @white;
    border-radius: 5px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.barcode-scanner-header {
    background: @red;
    color: @white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
    }
}

.barcode-scanner-close {
    background: none;
    border: none;
    color: @white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color @lab-transition;

    &:hover {
        background-color: rgba(255, 255, 255, 0.2);
    }
}

.barcode-scanner-content {
    padding: 20px;
    text-align: center;
    position: relative;
}

#qr-reader {
    position: relative;
    z-index: 1;
    max-width: 100%;
    overflow: hidden;
}

#qr-reader video {
    object-fit: cover !important;
    width: 100% !important;
    height: auto !important;
    transform: scaleX(1);
    border-radius: 5px;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    transform: translateZ(0);
}

#qr-reader__scan_region {
    position: relative;
    border: 2px solid @red !important;
    border-radius: 5px;
}

#qr-reader__dashboard_section_csr {
    display: none !important;
}

#qr-reader__scan_region::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    border: 2px dashed rgba(220, 0, 0, 0.5);
    border-radius: @lab-border-radius;
    pointer-events: none;
}

#qr-reader canvas {
    border-radius: 5px;
}

.barcode-scanner-status {
    margin-top: 15px;
    padding: 15px;
    background: @lab-light-bg;
    border-radius: @lab-border-radius;

    p {
        margin: 0;
        color: @dark;
        font-size: 14px;
        line-height: 1.5;
    }

    small {
        display: block;
        margin-top: 5px;
        font-size: 12px;
        color: @light-dark;
    }
}

.barcode-scanner-help {
    margin-top: 15px;
    padding: 10px;
    background: @bg-warning;
    border: 1px solid @yellow;
    border-radius: @lab-border-radius;

    details {
        cursor: pointer;
    }

    summary {
        font-weight: 600;
        color: @yellow-dark;
        padding: 5px;
        user-select: none;

        &:hover {
            color: #533f03;
        }
    }

    ol {
        margin: 10px 0 10px 20px;
        padding: 0;
        color: @yellow-dark;
    }

    li {
        margin: 8px 0;
        line-height: 1.5;
    }

    p {
        margin: 10px 0 0 0;
        color: @yellow-dark;
    }
}

.barcode-scanner-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

.barcode-scanner-cancel {
    background: #6c757d;
    color: @white;
    border: none;
    padding: 10px 20px;
    border-radius: @lab-border-radius;
    cursor: pointer;
    font-size: 14px;
    transition: background-color @lab-transition;

    &:hover {
        background: #5a6268;
    }
}

.fancybox__container {
    z-index: 9999 !important;
}

.fancybox__backdrop {
    background: rgba(0, 0, 0, 0.87) !important;
}

.fancybox__content {
    background: transparent !important;
}

/* --- Page-level styles (inside .lab-test-page) --- */

.lab-test-page {

    .scan-barcode-section {
        text-align: center;
        margin-top: 20px;
        padding: 15px 0;
    }

    .scan-barcode-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        background: linear-gradient(135deg, @red 0%, #b30000 100%);
        color: @white;
        border: none;
        padding: 14px 32px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 16px;
        font-weight: 600;
        transition: all @lab-transition;
        box-shadow: 0 4px 12px rgba(220, 0, 0, 0.3);

        &:hover {
            background: linear-gradient(135deg, #b30000 0%, #8b0000 100%);
            box-shadow: 0 6px 16px rgba(220, 0, 0, 0.4);
            transform: translateY(-2px);
        }

        &:active {
            transform: translateY(0);
            box-shadow: 0 2px 8px rgba(220, 0, 0, 0.3);
        }

        svg {
            width: 20px;
            height: 20px;
        }
    }

    .search-controls-container {
        margin: 20px 0;
        background: linear-gradient(135deg, rgba(220, 0, 0, 0.05) 0%, rgba(220, 0, 0, 0.02) 100%);
        padding: 20px;
        border-radius: 5px;
        border: 1px solid rgba(220, 0, 0, 0.08);

        .main-search-wrapper {
            margin-bottom: 15px;
        }

        .search-input-wrapper {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        .search-input-container {
            position: relative;
            flex: 1;
            display: flex;
        }

        .lab-search {
            flex: 1;
            width: 100%;
            padding: 14px 45px 14px 18px;
            border: 2px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
            transition: all @lab-transition;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            box-sizing: border-box;
            background: @white;
            line-height: 1.5;
            color: #2c3e50;

            &::placeholder {
                color: #95a5a6;
            }

            &:focus {
                outline: none;
                border-color: @red;
                box-shadow: 0 4px 16px rgba(220, 0, 0, 0.2);
                transform: translateY(-2px);
            }
        }

        .search-clear-btn {
            position: absolute;
            right: 10px;
            top: 45% !important;
            transform: translateY(-48%);
            background: none;
            border: none;
            color: @light-dark;
            font-size: 20px;
            cursor: pointer;
            padding: 4px 8px;
            transition: all 0.2s ease;
            display: none;
            align-items: center;
            justify-content: center;
            line-height: 1;
            z-index: 10;

            &:hover {
                color: @red;
                transform: translateY(-48%) scale(1.15);
            }

            &:active {
                transform: translateY(-48%) scale(0.95);
            }
        }

        .search-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            height: 48px;
            top: auto;
            right: auto;
            z-index: auto;
            background: linear-gradient(135deg, @red 0%, #b30000 100%);
            color: @white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all @lab-transition;
            box-shadow: 0 2px 8px rgba(220, 0, 0, 0.2);

            &:hover {
                background: linear-gradient(135deg, #b30000 0%, #8b0000 100%);
                box-shadow: 0 4px 12px rgba(220, 0, 0, 0.3);
                transform: translateY(-2px);
            }

            &:active {
                transform: translateY(0);
            }

            svg {
                width: 18px;
                height: 18px;
                stroke: @white;
            }
        }
    }

    .scan-barcode-section-inline {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #f0f0f0;
    }

    .scan-barcode-label {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: @light-dark;
        font-size: 14px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .scan-barcode-btn-inline {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background: linear-gradient(135deg, @red 0%, #b30000 100%);
        color: @white;
        border: none;
        padding: 12px 20px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 15px;
        font-weight: 600;
        transition: all @lab-transition;
        box-shadow: 0 2px 8px rgba(220, 0, 0, 0.2);
        white-space: nowrap;

        &:hover {
            background: linear-gradient(135deg, #b30000 0%, #8b0000 100%);
            box-shadow: 0 4px 12px rgba(220, 0, 0, 0.3);
            transform: translateY(-2px);
        }

        &:active {
            transform: translateY(0);
        }

        svg {
            width: 18px;
            height: 18px;
        }
    }

    .total-items {
        display: block;
        font-size: 0.85em;
        opacity: 0.8;
        margin-top: 2px;
    }

    a.pagination-btn.disabled,
    .pagination-wrapper a.pagination-btn.disabled {
        opacity: 0.6 !important;
        cursor: not-allowed !important;
        pointer-events: none !important;
        background-color: #e9ecef !important;
        border-color: #ced4da !important;
        color: #6c757d !important;
        box-shadow: none !important;
        text-decoration: none !important;

        &:hover {
            background-color: #e9ecef !important;
            border-color: #ced4da !important;
            color: #6c757d !important;
            text-decoration: none !important;
            transform: none !important;
        }

        svg {
            fill: #6c757d !important;
            color: #6c757d !important;
        }
    }

    .lab-video-container {
        max-width: 800px;
        margin: 0 auto 30px;
        padding: 0 20px;
    }

    .lab-video {
        position: relative;
        width: 100%;
        padding-bottom: 56.25%;
        height: 0;
        overflow: hidden;
        border-radius: 5px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

        iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border: 0;
        }
    }

    .intro-toggle-section {
        text-align: center;
        margin: 20px 0;
    }

    .intro-toggle-btn {
        background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
        color: @darker;
        border: 1px solid #ddd;
        padding: 12px 30px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 16px;
        font-weight: 600;
        transition: all @lab-transition;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

        &:hover {
            background: linear-gradient(135deg, #e8e8e8 0%, #d9d9d9 100%);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            transform: translateY(-2px);
        }

        &:active {
            transform: translateY(0);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
        }
    }

    .intro-expandable-content {
        animation: labFadeIn 0.3s ease-in-out;
    }

    @keyframes labFadeIn {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .product-info {
        line-height: 1.6;

        .product-brand {
            font-size: 12px;
            color: @dark;
            margin-bottom: 4px;
        }

        .product-name {
            font-size: 16px;
            font-weight: bold;
            color: @darker;
            margin-bottom: 4px;
        }

        .product-flavour {
            font-size: 13px;
            font-style: italic;
            color: @light-dark;
        }
    }

    .card-product-brand {
        font-size: 12px;
        color: @dark;
        margin-bottom: 5px;
    }

    .card-product-name {
        font-size: 18px;
        font-weight: bold;
        color: @darker;
        margin-bottom: 5px;
    }

    .card-product-flavour {
        font-size: 14px;
        font-style: italic;
        color: @light-dark;
    }

    @media (max-width: 768px) {
        .barcode-scanner-container {
            max-width: 95%;
            margin: 10px;
        }

        .barcode-scanner-overlay {
            padding: 10px;
        }

        #qr-reader {
            max-height: 400px;

            video {
                max-height: 400px;
            }
        }

        .lab-video-container {
            max-width: 100%;
            padding: 0;
            margin-bottom: 20px;
        }

        .lab-video {
            border-radius: 0;
        }

        .intro-toggle-btn {
            padding: 10px 25px;
            font-size: 14px;
        }

        .search-controls-container {
            padding: 15px 12px;

            .search-input-wrapper {
                flex-wrap: nowrap;
                gap: 6px;
            }

            .search-input-container {
                flex: 1;
                min-width: 0;
            }

            .lab-search {
                flex: 1;
                width: 100%;
                min-width: 0;
                margin-bottom: 0;
                padding: 12px 40px 12px 14px;
                font-size: 15px;
                height: 48px;
            }

            .search-btn {
                flex: 0 0 auto;
                width: 48px;
                height: 48px;
                padding: 0;
                flex-shrink: 0;
            }

            .search-clear-btn {
                position: absolute;
                right: 8px;
                top: 48%;
                transform: translateY(-48%);
                font-size: 18px;
                padding: 4px;
                display: none;
                z-index: 10;

                &:hover {
                    transform: translateY(-48%) scale(1.15);
                }

                &:active {
                    transform: translateY(-48%) scale(0.95);
                }
            }
        }

        .scan-barcode-section-inline {
            margin-top: 12px;
            padding-top: 12px;
            flex-direction: column;
            gap: 10px;
        }

        .scan-barcode-label {
            display: none;
        }

        .scan-barcode-btn-inline {
            width: 100%;
        }
    }

    @supports (-webkit-touch-callout: none) {
        #qr-reader video {
            object-fit: cover !important;
        }
    }
}
