/**
 * Enhanced Icon Picker Styles
 * Adds visual icon picker modal for social media repeater
 *
 * @package Pawfect
 * @since 1.0.0
 */

/* Enhanced Icon Picker Button - New Design */
.pawfect-icon-picker-wrapper {
    margin-top: 8px !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 999 !important;
}

.pawfect-enhanced-icon-btn {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 8px 12px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    color: #555 !important;
    text-align: left !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1000 !important;
    height: auto !important;
    min-height: 36px !important;
}

.pawfect-enhanced-icon-btn:hover {
    border-color: #0073aa !important;
    box-shadow: 0 0 0 1px #0073aa !important;
}

.pawfect-enhanced-icon-btn:focus {
    border-color: #0073aa !important;
    box-shadow: 0 0 0 1px #0073aa !important;
    outline: none !important;
}

.pawfect-icon-preview {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    margin-right: 8px !important;
    background: #f5f5f5 !important;
    border-radius: 3px !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
}

.pawfect-icon-text {
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.pawfect-icon-arrow {
    margin-left: 8px !important;
    color: #999 !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
}

/* Hide original input when enhanced button is present */
.pawfect-icon-picker-wrapper + input[type="text"] {
    display: none !important;
}

/* Ensure icon picker elements are visible and styled properly - Generic for all repeater controls */
.icp-container {
    display: flex !important;
    align-items: stretch !important;
    margin-top: 8px !important;
}

.icp-container .icp,
.icp-container .icp-auto {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 1 !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-right: none !important;
    border-radius: 4px 0 0 4px !important;
    background: #fff !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

.icp-container .input-group-addon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    padding: 8px !important;
    border: 1px solid #ddd !important;
    border-radius: 0 4px 4px 0 !important;
    background: #f9f9f9 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.icp-container .input-group-addon:hover {
    background: #e9e9e9 !important;
    border-color: #0073aa !important;
}

.icp-container .input-group-addon i {
    font-size: 16px !important;
    color: #555 !important;
}

/* Additional generic styles for all repeater controls */
.customizer-repeater-general-control-repeater-container .icp-container,
.customizer-repeater-social-repeater-container .icp-container {
    display: flex !important;
    align-items: stretch !important;
    margin-top: 8px !important;
}

/* Ensure icon picker inputs are visible in all repeater contexts */
.customize-control .icp-container .icp,
.customize-control .icp-container .icp-auto {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide old iconpicker dropdowns for all repeater controls */
.customize-control .iconpicker-popover {
    display: none !important;
}

/* Ensure enhanced icon picker modal appears above all other elements */
.pawfect-icon-picker-modal {
    z-index: 999999 !important;
}

/* Icon Picker Modal */
.pawfect-icon-picker-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 999999 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transition: all 0.3s ease !important;
}

.pawfect-icon-picker-modal.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.pawfect-icon-picker-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.pawfect-icon-picker-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.pawfect-icon-picker-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #333;
}

.pawfect-icon-picker-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.3s ease;
    color: #666;
}

.pawfect-icon-picker-close:hover {
    background: #e9ecef;
    color: #333;
}

.pawfect-icon-picker-search {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: #fff;
}

.pawfect-icon-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.pawfect-icon-search-input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

.pawfect-icon-picker-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.pawfect-icon-picker-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    color: #666;
    border-bottom: 3px solid transparent;
}

.pawfect-icon-picker-tab.active {
    background: white;
    color: #0073aa;
    border-bottom-color: #0073aa;
}

.pawfect-icon-picker-tab:hover:not(.active) {
    background: #e9ecef;
    color: #333;
}

.pawfect-icon-picker-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    background: #fff;
}

.pawfect-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.pawfect-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 1px solid #eee;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    background: #fff;
}

.pawfect-icon-item:hover {
    border-color: #0073aa;
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pawfect-icon-item.selected {
    border-color: #0073aa;
    background: #e7f3ff;
}

.pawfect-icon-item i {
    font-size: 20px;
    margin-bottom: 5px;
    color: #666;
    transition: color 0.3s ease;
}

.pawfect-icon-item:hover i {
    color: #0073aa;
}

.pawfect-icon-item span {
    font-size: 11px;
    color: #666;
    line-height: 1.2;
    font-weight: 500;
}

.pawfect-icon-item:hover span {
    color: #333;
}

/* Custom scrollbar for modal body */
.pawfect-icon-picker-body::-webkit-scrollbar {
    width: 8px;
}

.pawfect-icon-picker-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.pawfect-icon-picker-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.pawfect-icon-picker-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Empty state */
.pawfect-icon-grid:empty::after {
    content: "No icons found. Try a different search term.";
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* Loading state */
.pawfect-icon-grid.loading {
    position: relative;
    min-height: 200px;
}

.pawfect-icon-grid.loading::after {
    content: "Loading icons...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-style: italic;
}

/* Responsive design */
@media (max-width: 782px) {
    .pawfect-icon-picker-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .pawfect-icon-picker-header {
        padding: 15px;
    }
    
    .pawfect-icon-picker-title {
        font-size: 16px;
    }
    
    .pawfect-icon-picker-search {
        padding: 12px 15px;
    }
    
    .pawfect-icon-picker-body {
        padding: 15px;
        max-height: 350px;
    }
    
    .pawfect-icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    
    .pawfect-icon-item {
        padding: 8px 4px;
    }
    
    .pawfect-icon-item i {
        font-size: 18px;
    }
    
    .pawfect-icon-item span {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .pawfect-icon-picker-content {
        width: 98%;
        max-height: 95vh;
    }
    
    .pawfect-icon-picker-tabs {
        flex-direction: column;
    }
    
    .pawfect-icon-picker-tab {
        border-bottom: 1px solid #eee;
        border-right: none;
    }
    
    .pawfect-icon-picker-tab.active {
        border-bottom-color: #eee;
        border-left: 3px solid #0073aa;
    }
    
    .pawfect-icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
    }
}

/* Animation for modal appearance */
.pawfect-icon-picker-modal {
    animation: fadeIn 0.3s ease-out;
}

.pawfect-icon-picker-content {
    animation: slideIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}
