/**
 * User Product Affiliate Links - Styles
 * Version: 1.0.0
 */

/* ===============================================
   Affiliate Link Box on Product Page
   =============================================== */

.upal-affiliate-box {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.upal-affiliate-box .upal-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
}

.upal-affiliate-box .upal-title:before {
    content: "🔗";
    margin-right: 8px;
    font-size: 20px;
}

.upal-link-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.upal-link-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    color: #555;
    font-family: monospace;
}

.upal-link-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

.upal-copy-button {
    padding: 10px 20px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.upal-copy-button:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.upal-copy-button:active {
    transform: translateY(0);
}

.upal-copy-feedback {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #46b450;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upal-copy-feedback.show {
    opacity: 1;
}

/* ===============================================
   My Account Navigation - Menu Icon
   =============================================== */

/* Add dashicons icon to the Affiliate Product Links menu item - aligned to the right */
.woocommerce-MyAccount-navigation-link--affiliate-product-links a {
    position: relative;
    padding-right: 25px; /* space for icon */
}

.woocommerce-MyAccount-navigation-link--affiliate-product-links a::after {
    content: "\f237"; /* dashicons-share */
    font-family: dashicons;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    line-height: 1;
}


/* Ensure dashicons are loaded */
body .woocommerce-MyAccount-navigation-link--affiliate-product-links {
    /* This ensures the icon displays properly */
}

/* ===============================================
   My Account Page - Affiliate Product Links
   =============================================== */

.upal-account-page {
    padding: 20px 0;
}

.upal-account-page h2 {
    margin-bottom: 10px;
    font-size: 24px;
    color: #333;
}

.upal-account-page > p {
    margin-bottom: 25px;
    color: #666;
    font-size: 14px;
}

.upal-products-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.upal-products-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.upal-products-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upal-products-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s ease;
}

.upal-products-table tbody tr:hover {
    background-color: #f8f9fa;
}

.upal-products-table tbody tr:last-child {
    border-bottom: none;
}

.upal-products-table td {
    padding: 15px;
    font-size: 14px;
    color: #555;
    vertical-align: middle;
}

.upal-product-name a {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.upal-product-name a:hover {
    color: #005a87;
    text-decoration: underline;
}

.upal-product-link .upal-link-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.upal-link-input-small {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
    background: #f9f9f9;
    color: #555;
    font-family: monospace;
}

.upal-link-input-small:focus {
    outline: none;
    border-color: #007cba;
    background: #fff;
}

.upal-copy-button-small {
    padding: 8px 16px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.upal-copy-button-small:hover {
    background: #005a87;
}

.upal-copy-button-small:active {
    transform: scale(0.95);
}

.upal-visits-count {
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    color: #007cba;
}

/* ===============================================
   Pagination Styles
   =============================================== */

.upal-pagination-info {
    margin: 0 0 15px 0;
    padding: 10px 15px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.upal-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    padding: 20px 0;
}

.upal-pagination-wrapper {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.upal-pagination-numbers {
    display: flex;
    gap: 5px;
    align-items: center;
}

.upal-pagination-link,
.upal-pagination a {
    display: inline-block;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #007cba;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
    text-align: center;
    cursor: pointer;
}

.upal-pagination-link:hover,
.upal-pagination a:hover {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.2);
}

.upal-pagination-link.upal-current,
.upal-pagination .current {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
    cursor: default;
    font-weight: 600;
}

.upal-pagination-link.upal-current:hover,
.upal-pagination .current:hover {
    transform: none;
    box-shadow: none;
}

.upal-pagination-link.upal-disabled {
    background: #f5f5f5;
    color: #ccc;
    border-color: #e0e0e0;
    cursor: not-allowed;
    pointer-events: none;
}

.upal-pagination-link.upal-disabled:hover {
    transform: none;
    box-shadow: none;
}

.upal-pagination-link.upal-prev,
.upal-pagination-link.upal-next,
.upal-pagination .prev,
.upal-pagination .next {
    padding: 8px 18px;
    font-weight: 600;
}

.upal-pagination-ellipsis,
.upal-pagination .dots {
    padding: 8px 6px;
    color: #999;
    font-size: 14px;
    font-weight: 600;
}

/* ===============================================
   Loading Overlay & Spinner
   =============================================== */

.upal-account-page {
    position: relative;
    min-height: 300px;
}

.upal-loading-overlay {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    border-radius: 4px;
}

.upal-account-page.upal-loading #upal-products-container {
    opacity: 0.5;
    pointer-events: none;
}

.upal-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #007cba;
    border-radius: 50%;
    animation: upal-spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes upal-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.upal-loading-overlay p {
    margin: 0;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* ===============================================
   Error Message Styles
   =============================================== */

.upal-error-message {
    padding: 30px;
    background: #ffebee;
    border: 2px solid #f44336;
    border-radius: 4px;
    text-align: center;
    margin: 20px 0;
}

.upal-error-message p {
    color: #c62828;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 15px;
}

.upal-retry-button {
    padding: 10px 20px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upal-retry-button:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
}

.upal-retry-button:active {
    transform: translateY(0);
}

/* ===============================================
   Fade Transition for Content Updates
   =============================================== */

#upal-products-container {
    transition: opacity 0.2s ease;
}

#upal-products-container.upal-fade-out {
    opacity: 0;
}

/* ===============================================
   Responsive Design
   =============================================== */

@media screen and (max-width: 768px) {
    .upal-link-container {
        flex-direction: column;
    }
    
    .upal-link-input {
        min-width: 100%;
    }
    
    .upal-copy-button {
        width: 100%;
    }
    
    .upal-products-table {
        font-size: 12px;
    }
    
    .upal-products-table th,
    .upal-products-table td {
        padding: 10px;
    }
    
    .upal-link-input-small {
        min-width: 150px;
        font-size: 11px;
    }
    
    .upal-copy-button-small {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .upal-pagination {
        gap: 5px;
    }
    
    .upal-pagination-link {
        padding: 6px 10px;
        font-size: 13px;
        min-width: 35px;
    }
    
    .upal-pagination-link.upal-prev,
    .upal-pagination-link.upal-next {
        padding: 6px 12px;
    }
}

@media screen and (max-width: 600px) {
    .upal-products-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .upal-products-table thead {
        display: none;
    }
    
    .upal-products-table tbody,
    .upal-products-table tr,
    .upal-products-table td {
        display: block;
    }
    
    .upal-products-table tr {
        margin-bottom: 15px;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        padding: 10px;
    }
    
    .upal-products-table td {
        padding: 8px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .upal-products-table td:last-child {
        border-bottom: none;
    }
    
    .upal-products-table td:before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 5px;
        color: #333;
        font-size: 12px;
        text-transform: uppercase;
    }
    
    .upal-product-link .upal-link-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .upal-link-input-small {
        width: 100%;
    }
    
    .upal-copy-button-small {
        width: 100%;
    }
}

/* ===============================================
   Admin Page Styles
   =============================================== */

.upal-admin-page {
    max-width: 1200px;
}

.upal-admin-page .card {
    margin-top: 20px;
    padding: 20px;
}

.upal-admin-page .card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.upal-admin-page .card ul {
    list-style: none;
    padding-left: 0;
}

.upal-admin-page .card ul li {
    padding: 8px 0;
    font-size: 14px;
}
