/* Enhanced File Picker Styles - Mobile Touch Optimized */

/* FIX: Override the default strict modal sizing when the picker is active */
#dialog-content.picker-modal {
    max-width: 95vw !important;
    width: auto !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    display: flex;
    justify-content: center;
}

#dialog-overlay.active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: env(safe-area-inset-top, 40px) 20px 20px 20px !important;
}

.enhanced-picker {
    position: relative;
    width: 90%;
    max-width: 480px; 
    max-height: calc(100vh - env(safe-area-inset-top, 80px) - 40px);
    display: flex;
    flex-direction: column;
    background: var(--secondary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9);
    overflow: hidden;
    margin: 0 auto;
}

.picker-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.picker-header h3 {
    margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 8px; color: var(--accent);
}

.picker-close-btn {
    background: none; border: none; color: var(--text); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 4px; border-radius: 50%; transition: background 0.2s; width: 30px; height: 30px;
    touch-action: manipulation; /* FIX */
}

.picker-controls {
    padding: 12px 18px; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; background: var(--primary);
}

.search-box { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: #666; font-size: 18px; pointer-events: none; }

#picker-search {
    width: 100%; padding: 10px 12px 10px 40px; background: #111;
    border: 1px solid #444; border-radius: 8px; color: var(--text);
    font-size: 0.85rem; outline: none; transition: all 0.2s;
}

.picker-filters { display: flex; gap: 8px; }
.picker-select {
    flex: 1; padding: 9px 12px; background: #111; border: 1px solid #444;
    border-radius: 8px; color: var(--text); font-size: 0.8rem; outline: none;
}

.picker-stats {
    padding: 8px 18px; color: #666; font-size: 0.72rem;
    border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--primary);
}

.picker-file-list {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 18px; min-height: 120px;
}

.picker-file-item {
    display: flex; align-items: center; gap: 12px; padding: 11px;
    margin-bottom: 8px; background: #111; border: 1px solid #444;
    border-radius: 10px; transition: all 0.2s; cursor: pointer;
    touch-action: manipulation; /* FIX: Removes 300ms delay safely */
}

.picker-file-item:hover { background: #1a1a1a; border-color: var(--accent); transform: translateX(2px); }

.picker-file-thumbnail {
    position: relative; width: 48px; height: 48px; background: #0a0a0a;
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; border: 1px solid #333;
}

.picker-image-count {
    position: absolute; bottom: 2px; right: 2px; background: var(--accent);
    color: #000; font-size: 0.6rem; font-weight: 700; padding: 2px 5px;
    border-radius: 5px;
}

.picker-file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.picker-file-name { font-weight: 600; font-size: 0.88rem; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-file-meta { font-size: 0.7rem; color: #888; display: flex; gap: 5px; }

.picker-file-actions { display: flex; gap: 5px; flex-shrink: 0; }
.picker-action-btn {
    width: 32px; height: 32px; border-radius: 50%; background: #0a0a0a;
    border: 1px solid #444; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text); transition: all 0.15s;
    touch-action: manipulation; /* FIX */
}

.picker-footer {
    padding: 12px 18px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; background: var(--primary);
}

.picker-empty { text-align: center; padding: 40px 20px; color: #666; font-style: italic; }

@media (max-width: 600px) {
    .enhanced-picker { width: 100%; max-width: 100%; max-height: 100%; height: 100vh; border-radius: 0; }
    .picker-header { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
    .picker-footer { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}
