/**
 * Fabcrush Multi-Address Manager Styles
 * 
 * Modern, accessible styling for the multiple shipping addresses interface.
 * Follows the existing design system while providing a world-class user experience.
 * 
 * SAMURAI CODING PRINCIPLES:
 * - PRODUCTION READINESS: Responsive design with accessibility support
 * - SYSTEMATIC APPROACH: Consistent spacing and color variables
 * - MODERN DESIGN: Clean, intuitive interface that even a kid could understand
 */

/* ===== CSS VARIABLES ===== */
:root {
    --fabcrush-primary-color: #2c3e50;
    --fabcrush-secondary-color: #3498db;
    --fabcrush-success-color: #27ae60;
    --fabcrush-warning-color: #f39c12;
    --fabcrush-error-color: #e74c3c;
    --fabcrush-border-color: #ddd;
    --fabcrush-light-bg: #f8f9fa;
    --fabcrush-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --fabcrush-border-radius: 8px;
    --fabcrush-transition: all 0.3s ease;
}

/* ===== MAIN CONTAINER ===== */
.fabcrush-addresses-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.fabcrush-addresses-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--fabcrush-border-color);
}

.fabcrush-addresses-title {
    font-size: 1.8rem;
    color: var(--fabcrush-primary-color);
    margin: 0;
    font-weight: 600;
}

.fabcrush-addresses-subtitle {
    color: #666;
    font-size: 1rem;
    margin-top: 5px;
}

/* ===== ADDRESS GRID ===== */
.fabcrush-addresses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ===== ADDRESS ITEM ===== */
.fabcrush-address-item {
    background: white;
    border: 1px solid var(--fabcrush-border-color);
    border-radius: var(--fabcrush-border-radius);
    padding: 20px;
    box-shadow: var(--fabcrush-shadow);
    transition: var(--fabcrush-transition);
    position: relative;
    cursor: pointer;
}

.fabcrush-address-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.fabcrush-address-item.fabcrush-address-default {
    border-color: var(--fabcrush-success-color);
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.05) 0%, white 100%);
}

.fabcrush-address-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.fabcrush-address-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--fabcrush-primary-color);
    margin: 0;
}

.fabcrush-default-badge {
    background: var(--fabcrush-success-color);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fabcrush-address-content {
    color: #555;
    line-height: 1.6;
    margin-bottom: 15px;
}

.fabcrush-address-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.fabcrush-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--fabcrush-border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--fabcrush-transition);
    line-height: 1;
}

.fabcrush-btn:hover {
    transform: translateY(-1px);
}

.fabcrush-btn-primary {
    background: var(--fabcrush-secondary-color);
    color: white;
}

.fabcrush-btn-primary:hover {
    background: #2980b9;
}

.fabcrush-btn-secondary {
    background: #95a5a6;
    color: white;
}

.fabcrush-btn-secondary:hover {
    background: #7f8c8d;
}

.fabcrush-btn-success {
    background: var(--fabcrush-success-color);
    color: white;
}

.fabcrush-btn-success:hover {
    background: #229954;
}

.fabcrush-btn-danger {
    background: var(--fabcrush-error-color);
    color: white;
}

.fabcrush-btn-danger:hover {
    background: #c0392b;
}

.fabcrush-btn-outline {
    background: transparent;
    border: 1px solid var(--fabcrush-border-color);
    color: var(--fabcrush-primary-color);
}

.fabcrush-btn-outline:hover {
    background: var(--fabcrush-light-bg);
}

/* ===== ADD ADDRESS SECTION ===== */
.fabcrush-add-address-container {
    text-align: center;
    padding: 40px 20px;
    background: var(--fabcrush-light-bg);
    border: 2px dashed var(--fabcrush-border-color);
    border-radius: var(--fabcrush-border-radius);
    margin-bottom: 30px;
    transition: var(--fabcrush-transition);
}

.fabcrush-add-address-container:hover {
    border-color: var(--fabcrush-secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

.fabcrush-add-address-btn {
    background: var(--fabcrush-secondary-color);
    color: white;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: var(--fabcrush-border-radius);
    border: none;
    cursor: pointer;
    transition: var(--fabcrush-transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.fabcrush-add-address-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.fabcrush-add-address-btn::before {
    content: "➕";
    font-size: 0.9rem;
}

/* ===== FORM STYLES ===== */
.fabcrush-form-container {
    background: white;
    border: 1px solid var(--fabcrush-border-color);
    border-radius: var(--fabcrush-border-radius);
    padding: 30px;
    margin: 20px 0;
    box-shadow: var(--fabcrush-shadow);
}

.fabcrush-form-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--fabcrush-border-color);
}

.fabcrush-form-header h3 {
    margin: 0;
    color: var(--fabcrush-primary-color);
    font-size: 1.4rem;
}

.fabcrush-address-form {
    max-width: 800px;
    margin: 0 auto;
}

.fabcrush-form-row {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.fabcrush-form-row-half {
    grid-template-columns: 1fr 1fr;
}

.fabcrush-form-row-third {
    grid-template-columns: 1fr 1fr 1fr;
}

.fabcrush-form-field {
    display: flex;
    flex-direction: column;
}

.fabcrush-form-field label {
    font-weight: 500;
    color: var(--fabcrush-primary-color);
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.fabcrush-form-field input,
.fabcrush-form-field select {
    padding: 12px;
    border: 1px solid var(--fabcrush-border-color);
    border-radius: var(--fabcrush-border-radius);
    font-size: 1rem;
    transition: var(--fabcrush-transition);
    background: white;
}

.fabcrush-form-field input:focus,
.fabcrush-form-field select:focus {
    outline: none;
    border-color: var(--fabcrush-secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.fabcrush-field-error-input {
    border-color: var(--fabcrush-error-color) !important;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1) !important;
}

.fabcrush-field-error {
    color: var(--fabcrush-error-color);
    font-size: 0.85rem;
    margin-top: 5px;
    display: none;
}

.fabcrush-checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.fabcrush-checkbox-field label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.fabcrush-checkbox-field input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.fabcrush-form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--fabcrush-border-color);
}

/* ===== NOTIFICATIONS ===== */
.fabcrush-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: var(--fabcrush-border-radius);
    color: white;
    font-weight: 500;
    z-index: 10000;
    max-width: 300px;
    box-shadow: var(--fabcrush-shadow);
    display: none;
}

.fabcrush-notification-success {
    background: var(--fabcrush-success-color);
}

.fabcrush-notification-error {
    background: var(--fabcrush-error-color);
}

.fabcrush-notification-warning {
    background: var(--fabcrush-warning-color);
}

/* ===== LOADING STATES ===== */
.fabcrush-loading {
    opacity: 0.6;
    pointer-events: none;
}

.fabcrush-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .fabcrush-addresses-container {
        padding: 15px;
    }
    
    .fabcrush-addresses-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .fabcrush-addresses-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .fabcrush-form-row-half,
    .fabcrush-form-row-third {
        grid-template-columns: 1fr;
    }
    
    .fabcrush-form-container {
        padding: 20px;
        margin: 15px 0;
    }
    
    .fabcrush-address-actions {
        justify-content: center;
    }
    
    .fabcrush-form-actions {
        flex-direction: column;
    }
    
    .fabcrush-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .fabcrush-addresses-title {
        font-size: 1.4rem;
    }
    
    .fabcrush-address-item {
        padding: 15px;
    }
    
    .fabcrush-add-address-container {
        padding: 30px 15px;
    }
    
    .fabcrush-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .fabcrush-add-address-btn {
        padding: 14px 20px;
        font-size: 0.95rem;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.fabcrush-address-item:focus {
    outline: 2px solid var(--fabcrush-secondary-color);
    outline-offset: 2px;
}

.fabcrush-btn:focus {
    outline: 2px solid var(--fabcrush-secondary-color);
    outline-offset: 2px;
}

/* ===== INTEGRATION WITH EXISTING WOOCOMMERCE STYLES ===== */
.woocommerce .fabcrush-addresses-container {
    margin-top: 20px;
}

.woocommerce-MyAccount-content .fabcrush-addresses-container {
    padding: 0;
}

/* ===== EMPTY STATE STYLES ===== */
.fabcrush-empty-addresses {
    text-align: center !important;
    padding: 60px 20px !important;
    background: #f8f9fa !important;
    border-radius: 8px !important;
    margin-bottom: 30px !important;
}

.fabcrush-empty-addresses-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.fabcrush-empty-addresses-icon {
    font-size: 3rem !important;
    margin-bottom: 20px !important;
    text-align: center !important;
}

.fabcrush-empty-addresses h3 {
    color: #2c3e50 !important;
    margin-bottom: 10px !important;
    text-align: center !important;
}

.fabcrush-empty-addresses p {
    color: #666 !important;
    max-width: 500px !important;
    margin: 0 auto !important;
    line-height: 1.6 !important;
    text-align: center !important;
    padding: 0 !important;
}

/* ===== STANDARDIZED ADDRESS TITLE STYLING ===== */
.fabcrush-standard-address-title {
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    color: var(--fabcrush-primary-color) !important;
    margin: 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* Standard address edit button styling */
.fabcrush-standard-edit-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: var(--fabcrush-secondary-color) !important;
    color: white !important;
    text-decoration: none !important;
    transition: var(--fabcrush-transition) !important;
    border: none !important;
    cursor: pointer !important;
}

.fabcrush-standard-edit-btn:hover {
    background: #2980b9 !important;
    transform: translateY(-1px) !important;
    color: white !important;
    text-decoration: none !important;
}

.fabcrush-standard-edit-btn i {
    font-size: 14px !important;
}

/* ===== ICON BUTTON STYLES ===== */
.fabcrush-icon-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer !important;
    transition: var(--fabcrush-transition) !important;
    font-size: 16px !important;
    margin: 0 4px !important;
}

.fabcrush-icon-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.fabcrush-icon-btn i {
    font-size: 16px !important;
}

/* Primary icon button (Edit) */
.fabcrush-icon-btn.fabcrush-btn-primary {
    background: var(--fabcrush-secondary-color) !important;
    color: white !important;
}

.fabcrush-icon-btn.fabcrush-btn-primary:hover {
    background: #2980b9 !important;
    color: white !important;
}

/* Success icon button (Set Default) */
.fabcrush-icon-btn.fabcrush-btn-success {
    background: var(--fabcrush-success-color) !important;
    color: white !important;
}

.fabcrush-icon-btn.fabcrush-btn-success:hover {
    background: #229954 !important;
    color: white !important;
}

/* Danger icon button (Delete) */
.fabcrush-icon-btn.fabcrush-btn-danger {
    background: var(--fabcrush-error-color) !important;
    color: white !important;
}

.fabcrush-icon-btn.fabcrush-btn-danger:hover {
    background: #c0392b !important;
    color: white !important;
}

/* ===== CREATOR DASHBOARD INTEGRATION ===== */
.creator-dashboard-account-section .fabcrush-addresses-container {
    background: white;
    border-radius: var(--fabcrush-border-radius);
    padding: 30px;
    box-shadow: var(--fabcrush-shadow);
    margin-top: 20px;
}

.creator-dashboard-account-section .fabcrush-addresses-header {
    border-bottom-color: var(--fabcrush-border-color);
}

/* ===== ANIMATION KEYFRAMES ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fabcrush-address-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 1000px;
        transform: translateY(0);
    }
}

.fabcrush-form-container {
    animation: slideDown 0.3s ease-out;
}

/* ===== CHECKOUT & CART ADDRESS SELECTOR BUTTONS ===== */
.fabcrush-checkout-addresses,
.fabcrush-cart-addresses {
    margin: 15px 0;
}

.fabcrush-checkout-addresses-list,
.fabcrush-cart-addresses-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 8px; /* 10px vertical gap, 8px horizontal gap */
    align-items: flex-start;
}

/* High specificity selectors to override WooCommerce default button styles */
.woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn,
.woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn,
.fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn,
.fabcrush-cart-addresses .button.fabcrush-cart-address-btn,
button.fabcrush-checkout-address-btn,
button.fabcrush-cart-address-btn {
    /* Base WooCommerce button styling overrides */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.2s ease-out !important;
    
    /* Custom styling */
    padding: 10px 16px !important;
    margin: 0 !important; /* Remove default margins since we use flexbox gap */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    background-color: #667eea !important; /* Fallback for older browsers */
    color: #ffffff !important;
    border: 1px solid transparent !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2) !important;
    
    /* Text styling */
    text-transform: none !important;
    letter-spacing: 0.02em !important;
    font-family: inherit !important;
    
    /* Responsive sizing */
    min-width: auto !important;
    width: auto !important;
    height: auto !important;
    white-space: nowrap !important;
    
    /* Override any theme-specific styles */
    text-shadow: none !important;
    box-sizing: border-box !important;
}

/* Hover states with high specificity */
.woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn:hover,
.woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn:hover,
.fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn:hover,
.fabcrush-cart-addresses .button.fabcrush-cart-address-btn:hover,
button.fabcrush-checkout-address-btn:hover,
button.fabcrush-cart-address-btn:hover {
    transform: translateY(-1px) !important;
    filter: brightness(1.05) !important;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3) !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    background-color: #667eea !important;
    text-decoration: none !important;
    border-color: transparent !important;
}

/* Active states with high specificity */
.woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn:active,
.woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn:active,
.fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn:active,
.fabcrush-cart-addresses .button.fabcrush-cart-address-btn:active,
button.fabcrush-checkout-address-btn:active,
button.fabcrush-cart-address-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25) !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    background-color: #667eea !important;
}

/* Default button states with high specificity */
.woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn.is-default,
.woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn.is-default,
.fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn.is-default,
.fabcrush-cart-addresses .button.fabcrush-cart-address-btn.is-default,
button.fabcrush-checkout-address-btn.is-default,
button.fabcrush-cart-address-btn.is-default {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%) !important;
    background-color: #27ae60 !important;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.2) !important;
    border-color: transparent !important;
}

/* Default button hover states with high specificity */
.woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn.is-default:hover,
.woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn.is-default:hover,
.fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn.is-default:hover,
.fabcrush-cart-addresses .button.fabcrush-cart-address-btn.is-default:hover,
button.fabcrush-checkout-address-btn.is-default:hover,
button.fabcrush-cart-address-btn.is-default:hover {
    background: linear-gradient(135deg, #229954 0%, #1e8449 100%) !important;
    background-color: #229954 !important;
    box-shadow: 0 4px 16px rgba(39, 174, 96, 0.3) !important;
}

/* Focus states for accessibility with high specificity */
.woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn:focus,
.woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn:focus,
.fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn:focus,
.fabcrush-cart-addresses .button.fabcrush-cart-address-btn:focus,
button.fabcrush-checkout-address-btn:focus,
button.fabcrush-cart-address-btn:focus {
    outline: 2px solid #667eea !important;
    outline-offset: 2px !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2), 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .fabcrush-checkout-addresses-list,
    .fabcrush-cart-addresses-list {
        gap: 12px 6px; /* Increase vertical gap on mobile for better touch targets */
    }
    
    /* High specificity for mobile button styles */
    .woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn,
    .woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn,
    .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn,
    .fabcrush-cart-addresses .button.fabcrush-cart-address-btn,
    button.fabcrush-checkout-address-btn,
    button.fabcrush-cart-address-btn {
        padding: 12px 14px !important;
        font-size: 12px !important;
        min-width: 120px !important; /* Ensure buttons are touch-friendly */
        text-align: center !important;
    }
}

@media (max-width: 480px) {
    .fabcrush-checkout-addresses-list,
    .fabcrush-cart-addresses-list {
        gap: 15px 4px; /* Even more vertical space on very small screens */
    }
    
    /* High specificity for very small screen button styles */
    .woocommerce .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn,
    .woocommerce .fabcrush-cart-addresses .button.fabcrush-cart-address-btn,
    .fabcrush-checkout-addresses .button.fabcrush-checkout-address-btn,
    .fabcrush-cart-addresses .button.fabcrush-cart-address-btn,
    button.fabcrush-checkout-address-btn,
    button.fabcrush-cart-address-btn {
        flex: 1 1 calc(50% - 2px) !important; /* Two buttons per row on very small screens */
        min-width: 0 !important;
        max-width: none !important;
    }
}
