/**
 * ICON PICKER STYLES
 * Visual language for icon selection
 */

/* Icon Picker Container */
.icon-picker-container {
    position: fixed;
    z-index: 10060;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 500px;  /* Increased from 400px */
    max-width: 95vw;
    max-height: 80vh;  /* Changed from fixed 500px to 80% of viewport height */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.icon-picker {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: inherit;
    border-radius: inherit;
    overflow: hidden;
    box-shadow: none;
}

/* Portfolio page specific - even larger picker when in modal context */
.modal-open .icon-picker-container {
    width: 600px;  /* Even wider in modal context */
    max-height: 85vh;  /* Use more vertical space when in modal */
}

/* Icon Picker Trigger */
.icon-picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
}

.icon-picker-trigger:hover {
    border-color: #9ca3af;
}

.icon-picker-trigger:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.icon-picker-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
}

.icon-picker-preview .placeholder {
    font-size: 0.875rem;
    color: #9ca3af;
}

.icon-picker-arrow {
    color: #6b7280;
    transition: transform 0.2s;
}

/* Icon Picker Tabs */
.icon-picker-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.icon-picker-tabs .tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.icon-picker-tabs .tab:hover {
    background: #f9fafb;
}

.icon-picker-tabs .tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

/* Search Bar */
.icon-picker-search {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.icon-picker-search .search-input {
    width: 100%;
    padding: 8px 36px 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.icon-picker-search .search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.icon-picker-search .search-icon {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

/* Content Area */
.icon-picker-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;  /* Increased padding for better spacing */
    min-height: 0;
    scrollbar-gutter: stable both-edges;
}

/* Icon Sections */
.icon-section {
    margin-bottom: 20px;
}

.icon-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    margin: 0 0 8px 0;
    padding: 0 4px;
}

/* Icon Grid */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));  /* Increased from 36px */
    gap: 8px;  /* Increased gap from 4px for better visual spacing */
}

.emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));  /* Increased from 40px */
    gap: 8px;  /* Increased gap for better visual spacing */
}

/* Icon Items */
.icon-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;  /* Increased from 36px */
    height: 42px;  /* Increased from 36px */
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.4rem;  /* Slightly larger icons */
    color: #374151;
}

.emoji-item {
    width: 48px;  /* Increased from 40px */
    height: 48px;  /* Increased from 40px */
    font-size: 1.75rem;  /* Larger emojis */
}

.icon-item:hover {
    background: #f3f4f6;
    transform: scale(1.1);
}

/* Fix for spinner/loading issue */
.icon-item {
    cursor: pointer !important;
}

.icon-item i,
.icon-item span {
    pointer-events: none;
    cursor: inherit;
}

/* Remove any loading animations */
.icon-item:not(.loading) i::before,
.icon-item:not(.loading) i::after {
    animation: none !important;
}

/* Category selector */
.icon-picker-category-selector {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.category-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

.category-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading state */
.icon-picker-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.icon-picker-loading i {
    font-size: 2rem;
    margin-bottom: 12px;
    color: #3b82f6;
}

/* No results */
.no-icons,
.no-emojis {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-size: 0.875rem;
}

.icon-item:active {
    transform: scale(0.95);
}

/* Favorite Icons */
.icon-item.favorite {
    position: relative;
}

.favorite-star {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 0.625rem;
}

/* Scrollbar Styling */
.icon-picker-content::-webkit-scrollbar {
    width: 8px;
}

.icon-picker-content::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.icon-picker-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.icon-picker-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive Design */
@media (max-width: 640px) {
    .icon-picker-container {
        width: calc(100vw - 32px);
        max-height: 70vh;  /* Increased from 60vh for mobile */
    }

    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }

    .icon-item {
        width: 40px;
        height: 40px;
    }

    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    }

    .emoji-item {
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   VIEWPORT-SAFE POSITIONING
   ============================================ */

/* Smooth transitions when positioning changes */
.icon-picker-container {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Visual indicators for positioning */
.icon-picker-container.picker-top {
    transform-origin: bottom;
}

.icon-picker-container.picker-bottom {
    transform-origin: top;
}

/* Constrained picker indicator - when viewport forces size reduction */
.icon-picker-container.picker-constrained {
    border-color: #f59e0b;
    border-width: 2px;
}

.icon-picker-container.picker-constrained::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    z-index: 1;
    border-radius: 12px 12px 0 0;
}

/* Ensure scrollbar is always visible when constrained */
.icon-picker-container.picker-constrained .icon-picker-content {
    scrollbar-width: thin;
    scrollbar-color: #f59e0b #f3f4f6;
}

.icon-picker-container.picker-constrained .icon-picker-content::-webkit-scrollbar {
    width: 10px;
}

.icon-picker-container.picker-constrained .icon-picker-content::-webkit-scrollbar-track {
    background: #fef3c7;
    border-radius: 5px;
}

.icon-picker-container.picker-constrained .icon-picker-content::-webkit-scrollbar-thumb {
    background: #f59e0b;
    border-radius: 5px;
}

.icon-picker-container.picker-constrained .icon-picker-content::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

/* Add subtle animation when constrained to draw attention */
.icon-picker-container.picker-constrained::after {
    content: 'Scroll for more';
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(245, 158, 11, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}
