/**
 * Shop Notices for WooCommerce
 * Version: 2.1.1
 * Author: AXM Digital (https://axmdigital.com)
 */

/* Admin UI card styling - remove max-width restriction */
.tab-content-card {
    position: relative;
    margin-top: 20px;
    padding: .7em 2em 1em;
    min-width: 255px;
    max-width: 100%;
    border: 1px solid #c3c4c7;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
    background: #fff;
    box-sizing: border-box;
}

/* Default container styling */
.help-tip-container {
    margin: 15px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f8f8f8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 250px; /* Ensure minimum width for small contents */
    /* Use transform for better performance */
    transform: translateZ(0);
    will-change: opacity, height;
}

/* Notice content styling - Improved positioning for dismiss button */
.returning-customer-tip {
    position: relative;
    padding-right: 2px; /* Increased space for dismiss button */
    min-height: 80px; /* Minimum height to ensure dismiss button has space */
}

.returning-customer-tip h3 {
    margin-top: 0;
    margin-right: 60px; /* Ensure title doesn't overlap with dismiss button */
    color: #333;
    font-size: 1.2em;
    padding-bottom: 15px; /* Add some space below title */
}

.notice-content {
    margin-bottom: 10px;
    color: #555;
    line-height: 1.5;
}

/* Dismiss button styling - Fixed positioning with transform */
.dismiss-notice {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 0.8em;
    padding: 3px 8px;
    border-radius: 3px;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-width: 60px; /* Ensure button has minimum width */
    text-align: center;
    /* Improve performance with hardware acceleration */
    transform: translateZ(0);
}

.dismiss-notice:hover {
    background-color: #f1f1f1;
    color: #333;
}

.dismiss-notice:focus {
    outline: 1px dotted #333;
    background-color: #f1f1f1;
}

/* Modal specific styling - optimize for scroll performance */
.shop-notice-modal-container {
    /* Default styling for the modal container class */
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

.shop-notice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Use will-change for hardware acceleration */
    will-change: opacity;
    /* Prevent scroll-linked effects */
    transform: translateZ(0);
}

.shop-notice-modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 5px;
    max-width: 80%;
    max-height: 80%;
    min-width: 300px; /* Minimum width for modal */
    overflow: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    /* Use hardware acceleration */
    transform: translateZ(0);
}

.shop-notice-modal .returning-customer-tip h3 {
    font-size: 1.4em;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.shop-notice-modal .dismiss-notice {
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    background-color: #f1f1f1;
}

/* Body class when modal is open - only apply when modal is actually visible */
body.modal-open {
    overflow: hidden;
    /* Use direct property changes instead of complicated calculations */
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Common class for all notice containers for targeting */
.shop-notice-container {
    /* Use transform and opacity for better performance */
    transition: opacity 0.3s ease-out;
    transform: translateZ(0);
    will-change: opacity;
    /* Initially hide all notices to prevent flash of content */
    opacity: 0;
    visibility: hidden;
    min-width: 250px; /* Ensure minimum width for all notice containers */
}

/* Only show notices that have been explicitly marked as visible by JS */
.shop-notice-container.shop-notice-visible {
    opacity: 1;
    visibility: visible;
}

/* Transition effect for dismiss action - optimize for performance */
.shop-notice-container.dismissing {
    opacity: 0;
    /* Replace multiple property transitions with opacity only */
    /* Avoid height animations that can trigger reflows */
    pointer-events: none;
}

/* Modal dismiss animation - optimize for performance */
.shop-notice-modal.modal-dismissing {
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Customer message action buttons - optimized for all screen sizes */
.customer-messages-list .button.button-small {
    padding: 0 5px;
    height: 24px;
    line-height: 22px;
    font-size: 11px;
    text-align: center;
    min-width: 60px;
    box-sizing: border-box;
    white-space: nowrap;
    display: inline-block;
}

/* Ensure table cells have proper spacing and wrapping */
.customer-messages-list table td {
    padding: 8px;
    vertical-align: middle;
    word-break: break-word;
}

/* Edit and Remove columns should have fixed width */
.customer-messages-list th:nth-child(4),
.customer-messages-list th:nth-child(5) {
    width: 100px;
}

/* Copy Buttons */
.copy-block {
    position: relative;
    background: #f6f6f6;
    border: 1px solid #ccc;
    padding: 1em;
    margin: 1em 0;
    font-family: monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 4px;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary, #1D2F4F);
    color: white;
    border: none;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
}

/* Image styling in shop notices */
.shop-notice-container img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/* Image alignment classes */
.shop-notice-container img.alignleft {
    float: left;
    margin: 0 15px 10px 0;
}

.shop-notice-container img.alignright {
    float: right;
    margin: 0 0 10px 15px;
}

.shop-notice-container img.aligncenter {
    display: block;
    margin: 10px auto;
}

/* Image captions */
.shop-notice-container .wp-caption {
    max-width: 100%;
    margin-bottom: 1em;
}

.shop-notice-container .wp-caption img {
    display: block;
    margin: 0 auto;
}

.shop-notice-container .wp-caption-text {
    font-size: 0.9em;
    font-style: italic;
    text-align: center;
    margin-top: 5px;
    color: #666;
}

/* Clear floats inside notice containers to prevent layout breaks */
.shop-notice-container::after {
    content: "";
    display: table;
    clear: both;
}

/* Shop Message Active/Expired status indicators */
.shop-message-active {
    color: #46b450;
    font-weight: bold;
}
.shop-message-expired {
    color: #dc3232;
}

/* Mobile-specific styles */
@media (max-width: 782px) {
    /* Adjust table for mobile view */
    .customer-messages-list table.wp-list-table {
        table-layout: fixed;
    }
    
    /* Make customer column wider */
    .customer-messages-list th:first-child {
        width: 30%;
    }
    
    /* Make status and expiry columns narrower */
    .customer-messages-list th:nth-child(2),
    .customer-messages-list th:nth-child(3) {
        width: 15%;
    }
    
    /* Make action columns minimum width */
    .customer-messages-list th:nth-child(4),
    .customer-messages-list th:nth-child(5) {
        width: 80px;
    }
    
    /* Make buttons smaller on mobile */
    .customer-messages-list .button.button-small {
        padding: 0 4px;
        font-size: 10px;
        min-width: 50px;
        height: 22px;
        line-height: 20px;
    }
    
    /* Email address styling */
    .customer-messages-list td:first-child span {
        display: block;
        margin-top: 3px;
    }
    
    /* Ensure text in cells doesn't overflow */
    .customer-messages-list td {
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Extra small screens */
@media (max-width: 600px) {
    /* Stack columns differently for very small screens */
    .customer-messages-list table.wp-list-table {
        table-layout: fixed;
    }
    
    /* Adjust column widths for smaller screens */
    .customer-messages-list th:first-child {
        width: 35%;
    }
    
    .customer-messages-list th:nth-child(2) {
        width: 15%;
    }
    
    .customer-messages-list th:nth-child(3) {
        width: 20%;
    }
    
    .customer-messages-list th:nth-child(4),
    .customer-messages-list th:nth-child(5) {
        width: 15%;
    }
    
    /* Smaller text for very small screens */
    .customer-messages-list td,
    .customer-messages-list th {
        font-size: 12px;
        padding: 5px 3px;
    }
    
    /* Extra compact buttons */
    .customer-messages-list .button.button-small {
        padding: 0 3px;
        font-size: 10px;
        min-width: 40px;
        height: 20px;
        line-height: 18px;
    }
    
    /* Hide email address on very small screens */
    .customer-messages-list td:first-child span {
        display: none;
    }
    
    /* Show shorter version of expiry date */
    .customer-messages-list td:nth-child(3) {
        font-size: 10px;
    }
}