/**
 * CPET Reports Main Stylesheet
 */

/* --- WooCommerce Notices Customization --- */
.woocommerce-notices-wrapper .woocommerce-message,
.woocommerce-notices-wrapper .woocommerce-error,
.woocommerce-notices-wrapper .woocommerce-info {
    margin-bottom: 20px !important;
}

/* Fix for expiration notice icon overlap */
.cpet-purged-notice {
    background: #fff8e5;
    border-left: 4px solid #ffb900;
    padding: 15px 15px 15px 45px; /* Added left padding for icon */
    margin-bottom: 20px;
    font-size: 14px; /* Slightly larger text */
    position: relative;
}

.cpet-purged-notice::before {
    content: "\f153"; /* Dashicons warning icon */
    font-family: dashicons;
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffb900;
    font-size: 20px;
}

/* --- User Dashboard --- */
.woocommerce-account.woocommerce-page .woocommerce {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
}

.woocommerce-account .woocommerce-MyAccount-navigation {
    flex: 0 0 250px;
    margin-bottom: 30px;
}

.woocommerce-account .woocommerce-MyAccount-content {
    flex: 1;
    min-width: 300px;
}

/* Hide default WC dashboard text */
.woocommerce-MyAccount-content > p:not(.cpet-exclude) {
    display: none !important;
}

.cpet-user-dashboard {
    margin-top: 0;
}

.cpet-dashboard-hub {
    background: #f9f9f9;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-bottom: 30px;
}

.cpet-dashboard-hub h3 {
    margin-top: 0;
}

.cpet-org-info {
    color: #666;
    margin-bottom: 20px;
}

.cpet-stats-row {
    display: flex !important;
    gap: 20px;
    margin-bottom: 25px;
}

.cpet-stat-box {
    flex: 1;
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    text-align: center;
}

.cpet-stat-box h4 {
    margin: 0 0 10px;
    font-size: 14px;
    text-transform: uppercase;
    color: #888;
}

.cpet-stat-value {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    color: #2271b1;
}

.cpet-actions-row {
    display: flex !important;
    gap: 15px;
}

.cpet-actions-row .button {
    padding: 10px 25px;
    height: auto;
    line-height: 1.5;
}

.cpet-hipaa-notice {
    background: #fff8e5;
    border-left: 4px solid #ffb900;
    padding: 15px;
    margin-bottom: 30px;
}

.cpet-hipaa-notice p {
    margin: 0;
    font-size: 14px;
    color: #856404;
}

/* Credits Page */
.cpet-credits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cpet-credits-summary {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #eee;
}

.cpet-credits-summary-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cpet-balance-text {
    font-size: 1.2em;
    margin-bottom: 5px;
}

.cpet-expiration-text {
    color: #666;
    font-size: 0.9em;
    margin: 0;
}

.cpet-purged-notice {
    background: #fff8e5;
    border-left: 4px solid #ffb900;
    padding: 10px 15px;
    margin-bottom: 20px;
    font-size: 13px;
}

/* --- Admin Dashboard --- */
.cpet-admin-dashboard .welcome-panel {
    padding: 30px;
    margin-top: 20px;
    background: #fff;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.cpet-admin-dashboard h2 {
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 10px;
    color: #1d2327;
}

.cpet-admin-dashboard .about-description {
    font-size: 16px;
    margin: 0 0 30px;
    color: #50575e;
}

.cpet-admin-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.cpet-admin-stat-card {
    flex: 1;
    background: #f6f7f7;
    padding: 25px;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    text-align: center;
}

.cpet-admin-stat-card h3 {
    margin: 0 0 10px;
    color: #1d2327;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cpet-admin-stat-value {
    font-size: 36px;
    margin: 0;
    font-weight: 700;
    color: #2271b1;
    line-height: 1;
}

.cpet-admin-stat-label {
    color: #646970;
    margin: 10px 0 0;
    font-size: 13px;
}

.cpet-admin-actions {
    display: flex;
    gap: 15px;
    border-top: 1px solid #dcdcde;
    padding-top: 30px;
}

.cpet-admin-actions .button-hero {
    padding: 0 30px;
    height: 46px;
    line-height: 44px;
    font-size: 15px;
}

/* Customer Management */
.cpet-admin-container {
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.cpet-customer-email {
    color: #646970;
}

.cpet-dept-label {
    color: #646970;
}

.cpet-credit-value {
    font-weight: 600;
    font-size: 1.1em;
}

.cpet-adjustment-box {
    margin-top: 10px;
    padding: 15px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
}

.cpet-adjustment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cpet-adjustment-inputs {
    display: flex;
    gap: 5px;
}

/* Status Badges */
.cpet-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.cpet-badge-active {
    background: #e7f4e9;
    color: #1e4620;
}

.cpet-badge-exhausted {
    background: #fcf0f1;
    color: #d63638;
}

/* Settings */
.cpet-settings-container {
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 30px;
    margin-top: 20px;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    max-width: 800px;
}

.cpet-settings-footer {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

/* Agreements */
.cpet-agreements-flex {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.cpet-agreement-current {
    flex: 1;
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 25px;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.cpet-agreement-editor {
    flex: 1.5;
    background: #fff;
    border: 1px solid #ccd0d4;
    padding: 25px;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.cpet-agreement-info {
    background: #f6f7f7;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.cpet-agreement-preview {
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid #dcdcde;
    background: #fff;
}

.cpet-agreement-preview :first-child {
    margin-top: 0;
}

.cpet-agreement-preview h1,
.cpet-agreement-preview h2,
.cpet-agreement-preview h3 {
    margin: 1em 0 0.5em;
    line-height: 1.3;
}

.cpet-agreement-preview p {
    margin: 0.75em 0;
}

.cpet-agreement-preview ol,
.cpet-agreement-preview ul {
    margin: 0.75em 0;
    padding-left: 1.5em;
}

/* Checkout + report: read / view agreement controls */
.cpet-checkout-license-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
    margin: 0.75rem 0 0;
}

.cpet-checkout-license-actions .button:focus,
.cpet-license-dialog-open:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.cpet-blocks-license-consent .cpet-checkout-license-title-link:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/*
 * WooCommerce Checkout block — license field:
 * (A) Newer markup: <label class="cpet-license-checkout-field"> holds input +
 *     SVG + .wc-block-components-checkbox__label; description is a sibling <p>.
 * (B) Older markup: .wc-block-components-checkbox-control wrapper.
 */
.wc-block-checkout label.cpet-license-checkout-field {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.65rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    cursor: pointer;
}

.wc-block-checkout label.cpet-license-checkout-field .wc-block-components-checkbox__input {
    flex-shrink: 0;
    margin-top: 0.2em;
}

.wc-block-checkout label.cpet-license-checkout-field svg.wc-block-components-checkbox__mark {
    flex-shrink: 0;
    margin-top: 0.12em;
}

.wc-block-checkout label.cpet-license-checkout-field .wc-block-components-checkbox__label {
    flex: 1 1 auto;
    min-width: 0;
    margin-inline-start: 0;
    text-align: start;
}

.wc-block-checkout label.cpet-license-checkout-field + .cpet-checkout-license-field-desc {
    margin: 0.5rem 0 0;
    padding-inline-start: 0;
    font-size: 0.92em;
    line-height: 1.45;
    color: inherit;
    max-width: 100%;
    box-sizing: border-box;
}

.wc-block-checkout .cpet-license-checkout-field > .wc-block-components-checkbox-control,
.wc-block-checkout .cpet-license-checkout-field .wc-block-components-checkbox-control {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.65rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.wc-block-checkout .cpet-license-checkout-field .wc-block-components-checkbox-control input[type="checkbox"] {
    flex-shrink: 0;
    margin-top: 0.2em;
}

.wc-block-checkout .cpet-license-checkout-field .wc-block-components-checkbox-control label,
.wc-block-checkout .cpet-license-checkout-field .wc-block-components-checkbox-control > label {
    flex: 1 1 auto;
    min-width: 0;
    margin-inline-start: 0;
    text-align: start;
}

.wc-block-checkout .cpet-license-checkout-field .wc-block-components-checkbox-control__label {
    margin-inline-start: 0 !important;
    margin-left: 0 !important;
}

.cpet-license-checkout-field .cpet-checkout-license-field-desc {
    margin: 0.5rem 0 0;
    padding-inline-start: calc(1.125rem + 0.65rem);
    font-size: 0.92em;
    line-height: 1.45;
    color: inherit;
    max-width: 100%;
    box-sizing: border-box;
}

.cpet-checkout-license-field-desc .cpet-checkout-license-title-link:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Native <dialog> — full text, scrollable, readable width (WCAG-friendly) */
.cpet-license-dialog {
    max-width: min(92vw, 48rem);
    width: 100%;
    padding: 0;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.cpet-license-dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.cpet-license-dialog-scroll {
    max-height: min(78vh, 42rem);
    overflow-y: auto;
    padding: 1.25rem 1.5rem 0.5rem;
}

.cpet-license-dialog-title {
    margin: 0 0 1rem;
    font-size: 1.35rem;
    line-height: 1.3;
}

.cpet-license-dialog-body {
    font-size: 1rem;
    line-height: 1.6;
}

.cpet-license-dialog-body :first-child {
    margin-top: 0;
}

.cpet-license-dialog-body p {
    margin: 0.85em 0;
}

.cpet-license-dialog-body h1,
.cpet-license-dialog-body h2,
.cpet-license-dialog-body h3 {
    margin: 1.1em 0 0.5em;
    line-height: 1.3;
}

.cpet-license-dialog-body ol,
.cpet-license-dialog-body ul {
    margin: 0.85em 0;
    padding-left: 1.5em;
}

.cpet-license-dialog-footer {
    margin: 0;
    padding: 0.75rem 1.5rem 1.25rem;
    border-top: 1px solid #e5e5e5;
    background: #f6f7f7;
}

.cpet-license-dialog-footer .button:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Public license page shortcode */
.cpet-license-agreement-article {
    xmax-width: 42rem;
    margin: 0 auto 3rem;
    padding: 40px 1rem;
}

.cpet-license-agreement-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e5e5;
}

.cpet-license-agreement-title {
    margin: 0 0 0.35rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.25;
}

.cpet-license-agreement-meta {
    margin: 0;
    color: #555;
    font-size: 0.95rem;
}

.cpet-license-agreement-body {
    font-size: 1.05rem;
    line-height: 1.65;
}

.cpet-license-agreement-body p {
    margin: 0.9em 0;
}

.cpet-license-agreement-body h1,
.cpet-license-agreement-body h2,
.cpet-license-agreement-body h3 {
    margin: 1.25em 0 0.5em;
    line-height: 1.3;
}

.cpet-license-agreement-body ol,
.cpet-license-agreement-body ul {
    margin: 0.9em 0;
    padding-left: 1.5em;
}

.cpet-agreement-read-link {
    margin: 0.75rem 0 0;
}

.cpet-agreement-read-link a {
    font-weight: 600;
}

/* --- Report Generator Form --- */
.cpet-generator-container {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    max-width: 600px;
    margin: 20px 0;
}

.cpet-credits-info {
    background: #f0f7ff;
    padding: 15px 20px;
    border-radius: 6px;
    border-left: 4px solid #2271b1;
    margin-bottom: 25px;
}

.cpet-credits-info p {
    margin: 0;
    font-size: 16px;
    color: #1e4620;
}

.cpet-credits-info strong {
    color: #2271b1;
    font-size: 1.1em;
}

#cpet-report-form .form-row {
    margin-bottom: 20px;
}

#cpet-report-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

#cpet-report-form select,
#cpet-report-form input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
}

#cpet-report-form select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.file-input-row {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    border: 1px dashed #ccc;
}

.form-actions {
    margin-top: 30px;
}

#cpet-submit-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
}

#cpet-status-message {
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
    font-weight: 500;
}

#cpet-status-message.success {
    background: #e7f4e9;
    color: #1e4620;
    border: 1px solid #c3e6cb;
}

#cpet-status-message.error {
    background: #fcf0f1;
    color: #d63638;
    border: 1px solid #f5c6cb;
}

#cpet-progress-bar {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

/* --- WooCommerce Product Page Overrides --- */
.single-product .woocommerce-product-gallery {
    margin-left: 0 !important;
    pointer-events: none !important; /* Disable zoom/lightbox interaction */
    width: 300px !important; /* Force 300px width */
    max-width: 100% !important;
    float: left !important;
    clear: none !important;
}

.single-product .woocommerce-product-gallery__trigger {
    display: none !important; /* Hide zoom mag lens icon */
}

.single-product .posted-on {
    display: none !important; /* Eliminate date display */
}

/* Adjust Summary Width to match 300px image */
.single-product div.product div.summary {
    float: right !important;
    width: calc(100% - 340px) !important; /* 300px image + 40px gap */
    clear: none !important;
}

@media (max-width: 768px) {
    .single-product div.product div.summary {
        width: 100% !important;
        float: none !important;
    }
}

/* Neutralize the theme's inline grid gap and overlap */
div[style*="display: grid"][style*="grid-template-columns"],
div[style*="display:grid"][style*="grid-template-columns"] {
    display: block !important; 
    gap: 0 !important;
    grid-template-columns: none !important;
}

div[style*="display: grid"][style*="grid-template-columns"] > div,
div[style*="display:grid"][style*="grid-template-columns"] > div {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 30px !important;
    float: none !important;
}

/* Ensure related products and description clear the layout */
.cpet-product-description,
.related.products,
.upsells.products,
.woocommerce-tabs,
.woocommerce-product-details__short-description,
.woocommerce div.product .woocommerce-tabs {
    clear: both !important;
    display: block !important;
    width: 100% !important;
    margin-top: 40px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.cpet-product-description {
    padding: 20px 0 !important;
    border-top: 1px solid #eee !important;
}

/* Quantity Widget Styling */
.single-product .quantity input.qty,
.woocommerce .quantity input.qty,
.woocommerce-page .quantity input.qty {
    border: 2px solid #2271b1 !important;
    border-radius: 4px !important;
    padding: 8px !important;
    font-weight: 700 !important;
    background: #fff !important;
    color: #333 !important;
    width: 4em !important;
    min-width: 65px !important;
    height: 45px !important;
    text-align: center !important;
    display: inline-block !important;
    -moz-appearance: textfield !important;
}

.single-product .quantity,
.woocommerce .quantity,
.woocommerce-page .quantity {
    display: inline-block !important;
    margin-right: 15px !important;
    vertical-align: middle !important;
}

/* Hide redundant elements */
.single-product .product_meta,
.single-product .woocommerce-tabs ul.tabs,
.single-product .woocommerce-product-details__short-description + h2,
.single-product #tab-description h2:first-child,
.single-product .cpet-product-description h2:first-child {
    display: none !important;
}

/* Ensure description content is visible even if tabs are hidden */
.single-product .woocommerce-tabs #tab-description {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .woocommerce-account .woocommerce {
        flex-direction: column;
    }
    .woocommerce-account .woocommerce-MyAccount-navigation {
        flex: 1 0 auto;
        width: 100%;
    }
    .cpet-stats-row, .cpet-admin-stats, .cpet-agreements-flex {
        flex-direction: column;
    }
}

/* --- Admin: Customer Management (search, sortable columns, license) --- */
.cpet-customers-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

.cpet-customers-toolbar-spacer {
    flex: 1;
    min-width: 0;
}

.cpet-customer-search {
    max-width: 280px;
    width: 100%;
}

#cpet-customers-table th.cpet-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

#cpet-customers-table th.cpet-sortable .cpet-sort-label {
    position: relative;
    padding-right: 1.25em;
}

#cpet-customers-table th.cpet-sortable .cpet-sort-label::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid #787c82;
    opacity: 0.35;
    margin-top: -3px;
}

#cpet-customers-table th.cpet-sortable .cpet-sort-label::before {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #787c82;
    opacity: 0.35;
    margin-top: 4px;
}

#cpet-customers-table th.cpet-sortable.is-asc .cpet-sort-label::after {
    opacity: 1;
    border-bottom-color: #1d2327;
}

#cpet-customers-table th.cpet-sortable.is-asc .cpet-sort-label::before {
    opacity: 0.2;
}

#cpet-customers-table th.cpet-sortable.is-desc .cpet-sort-label::before {
    opacity: 1;
    border-top-color: #1d2327;
}

#cpet-customers-table th.cpet-sortable.is-desc .cpet-sort-label::after {
    opacity: 0.2;
}

.cpet-license-current {
    color: #00a32a;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cpet-license-current .dashicons {
    color: #00a32a;
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.cpet-license-none {
    color: #787c82;
}
