/**
 * Frontend Styles for COA Reports
 * Designed to match Elementor theme styling
 * All selectors prefixed with .coa- to avoid conflicts
 */

/* ═══════════════════════════════════════════════
   CUSTOMIZATION — Tab button size normalization
   Fixes oversized Description / COA tab buttons
   on all screen sizes (desktop → mobile)
   ═══════════════════════════════════════════════ */

/* Reset any theme-inflated padding on the list item itself */
.wc-tabs li {
    padding: 0 !important;
    margin: 0 2px 0 0 !important;
}

/* Normalize the anchor (tab button) size */
.wc-tabs li a {
    display: inline-block !important;
    padding: 0.5em 1em !important;
    font-size: 0.875em !important;
    /* ~14px */
    line-height: 1.5 !important;
    box-sizing: border-box !important;
}

/* ─── Small tablet / large phone (≤ 768px) ─── */
@media screen and (max-width: 768px) {
    .wc-tabs li a {
        padding: 0.45em 0.9em !important;
        font-size: 0.8125em !important;
        /* ~13px */
    }
}

/* ─── Small screen (≤ 600px) ─── */
@media screen and (max-width: 600px) {
    .wc-tabs li a {
        padding: 0.4em 0.75em !important;
        font-size: 0.8em !important;
        /* ~12.8px */
    }
}

/* ─── Mobile (≤ 480px) ─── */
@media screen and (max-width: 480px) {
    .wc-tabs li {
        margin: 0 1px 4px 0 !important;
    }

    .wc-tabs li a {
        padding: 0.35em 0.65em !important;
        font-size: 0.75em !important;
        /* 12px */
        white-space: nowrap !important;
    }
}

/*
 * Historical COA tab — inherits native WooCommerce tab styling.
 * Defensive overrides to avoid conflicts.
 */

/* Pointer cursor + prevent text-decoration conflicts */
.wc-tabs .coa_archived_tab a {
    cursor: pointer;
    text-decoration: none;
}

/* Prevent WooCommerce from highlighting this tab as "active" with a visible panel */
.wc-tabs .coa_archived_tab a:focus {
    outline: none;
}

/* Hide the wrapper rendered in the footer (JS moves the link into tabs) */
.coa-historical-button-wrapper {
    display: none;
}

/* ─── Responsive: Tablet ─── */
@media screen and (max-width: 768px) {
    .wc-tabs .coa_archived_tab a {
        font-size: 14px;
        white-space: nowrap;
    }
}

/* ─── Responsive: Mobile ─── */
@media screen and (max-width: 480px) {
    .wc-tabs .coa_archived_tab a {
        font-size: 13px;
        white-space: normal;
        word-break: normal;
    }
}

/* Popup Overlay */
.coa-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(92, 88, 80, 0.85);
    /* Theme color overlay */
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Popup Container */
.coa-popup-container {
    background: #fff;
    border-radius: 8px;
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    animation: popupSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Popup Header */
.coa-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
}

.coa-popup-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #5C5850;
    /* Theme color */
    letter-spacing: -0.2px;
}

.coa-history-close {
    position: relative;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: #50575e !important;
    border-radius: 50% !important;
    color: #fff !important;
    font-size: 0;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0 !important;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.2s;
    overflow: hidden;
}

/* Use a pseudo-element so the × is always dead-center regardless of theme overrides */
.coa-history-close::after {
    content: '\00D7';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    line-height: 1;
    color: #fff;
}

.coa-history-close:focus,
.coa-history-close:active {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.coa-history-close:hover {
    background: #1d2327 !important;
}

.coa-history-close:active {
    transform: scale(0.95);
}

/* Popup Content */
.coa-popup-content {
    padding: 24px 28px;
    max-height: calc(85vh - 85px);
    overflow-y: auto;
    background: #fff;
}

/* Scrollbar styling */
.coa-popup-content::-webkit-scrollbar {
    width: 8px;
}

.coa-popup-content::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.coa-popup-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.coa-popup-content::-webkit-scrollbar-thumb:hover {
    background: #5C5850;
}

/* Loading State */
.coa-loading {
    text-align: center;
    padding: 60px 20px;
}

.coa-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #5C5850;
    /* Theme color */
    border-radius: 50%;
    animation: coaSpin 0.8s linear infinite;
}

@keyframes coaSpin {
    to {
        transform: rotate(360deg);
    }
}

.coa-loading p {
    margin: 16px 0 0 0;
    color: #666;
    font-size: 15px;
}

/* Certificate List Container */
.coa-certificates-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    margin: 0;
}

/* List Item */
.coa-certificate-list-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    transition: all 0.25s ease;
}

.coa-certificate-list-item:hover {
    border-color: #5C5850;
    /* Theme color */
    box-shadow: 0 3px 12px rgba(92, 88, 80, 0.12);
    transform: translateY(-1px);
}

.coa-certificate-list-item.current {
    border-color: #5C5850;
    /* Theme color */
    background: #f9f9f8;
    box-shadow: 0 0 0 1px #5C5850 inset;
}

/* Certificate Content */
.coa-certificate-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Title Row */
.coa-certificate-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.coa-certificate-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #5C5850;
    /* Theme color */
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
    transition: color 0.2s ease;
}

.coa-certificate-link:hover {
    color: #3a3834;
    /* Darker theme color */
    text-decoration: none;
}

.coa-certificate-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
}

.coa-title-text {
    line-height: 1.4;
}

/* Date Row */
.coa-certificate-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #888;
}

.coa-date-label {
    font-style: italic;
    font-weight: 500;
    color: #5C5850;
    letter-spacing: 0.01em;
}

.coa-date-value {
    font-weight: 600;
    color: #3a3834;
}

/* Batch Number */
.coa-batch-separator {
    color: #ccc;
    margin: 0 2px;
}

.coa-batch-label {
    font-weight: 500;
    color: #666;
}

.coa-batch-value {
    color: #5C5850;
    font-weight: 600;
}

/* Current Badge - Theme color */
.coa-current-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: #5C5850;
    /* Theme color */
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Delete Button for List */
.coa-delete-btn-list {
    position: absolute;
    right: 16px;
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    background: #fff;
    color: #5C5850;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.coa-certificate-list-item:hover .coa-delete-btn-list {
    opacity: 1;
}

.coa-delete-btn-list:hover {
    background: #5C5850;
    color: #fff;
    border-color: #5C5850;
    transform: scale(1.1);
}

/* No Certificates */
.coa-no-certificates {
    text-align: center;
    padding: 60px 20px;
}

.coa-no-certificates p {
    margin: 0;
    color: #888;
    font-size: 15px;
}

/* Lightbox */
.coa-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.coa-lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
}

.coa-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.coa-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 44px;
    height: 44px;
    border: none;
    background: #fff;
    border-radius: 50%;
    font-size: 28px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.coa-lightbox-close:hover {
    background: #5C5850;
    color: #fff;
    transform: scale(1.1);
}

/* Responsive Design - Tablet */
@media screen and (max-width: 768px) {
    .coa-popup-overlay {
        padding: 10px;
        align-items: center;
    }

    .coa-popup-container {
        max-width: 95%;
        max-height: 80vh;
        border-radius: 12px;
    }

    .coa-popup-header {
        padding: 18px 20px;
    }

    .coa-popup-header h2 {
        font-size: 18px;
    }


    .coa-popup-content {
        padding: 18px 20px;
        max-height: calc(80vh - 80px);
    }

    .coa-certificate-list-item {
        padding: 14px 16px;
    }

    .coa-certificate-link {
        font-size: 15px;
    }

    .coa-certificate-date-row {
        font-size: 13px;
    }

    .coa-delete-btn-list {
        opacity: 1;
        width: 36px;
        height: 36px;
        font-size: 18px;
        min-width: 36px;
    }

    .coa-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

}

/* Responsive Design - Mobile */
@media screen and (max-width: 480px) {
    .coa-popup-overlay {
        padding: 20px;
        align-items: center;
        justify-content: center;
    }

    .coa-popup-container {
        max-width: 90%;
        width: 90%;
        max-height: 70vh;
        height: auto;
        border-radius: 12px;
    }

    .coa-popup-header {
        padding: 16px;
    }

    .coa-popup-header h2 {
        font-size: 16px;
    }


    .coa-popup-content {
        padding: 16px;
        max-height: calc(70vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .coa-certificate-list-item {
        padding: 12px 14px;
    }

    .coa-certificate-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

}