/**
 * Nowoczesne komponenty UI - 2025 Style
 * Custom selecty, animacje, efekty
 * Używa zwykłego CSS (bez @apply) dla kompatybilności z Tailwind CDN
 */

/* Custom Select Component */
.custom-select {
    position: relative;
    width: 100%;
    display: block;
}

.custom-select-button {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    text-align: left;
    color: #111827;
    font-weight: 500;
    transition: all 0.2s;
    box-sizing: border-box;
}

/* Style dla inputów number w custom-select-button */
input.custom-select-button[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
    display: block;
    cursor: text;
    font-family: inherit;
}

input.custom-select-button[type="number"]::-webkit-inner-spin-button,
input.custom-select-button[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

/* Style tylko dla buttonów (nie inputów) */
button.custom-select-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    cursor: pointer;
}

.custom-select-button:hover:not(input) {
    border-color: #d1d5db;
}

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

.custom-select-button:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.custom-select-dropdown {
    position: absolute;
    z-index: 9999;
    width: 100%;
    margin-top: 0.5rem;
    background-color: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    top: 100%;
    left: 0;
    right: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Większe dropdowny na desktopie dla selectów z wyszukiwarką */
.select-options-container {
    max-height: 12rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Większe dropdowny na desktopie - bezpośrednio dla dropdownów z klasą custom-select-dropdown-with-search */
@media (min-width: 1024px) {
    .custom-select-dropdown-with-search .select-options-container {
        max-height: 40rem !important;
    }
}

/* Większe dropdowny na desktopie dla selectów z wyszukiwarką */
@media (min-width: 1024px) {
    .custom-select:has(.select-search) .custom-select-dropdown {
        max-height: 24rem;
    }
}

/* Alternatywnie - dla selectów które mają search */
.custom-select-dropdown:has(.select-search) {
    max-height: 12rem;
}

@media (min-width: 1024px) {
    .custom-select-dropdown:has(.select-search) {
        max-height: 24rem;
    }
}

.custom-select-option {
    padding: 0.75rem 1rem;
    color: #111827;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.custom-select-option:hover {
    background-color: #eff6ff;
    color: #1e40af;
}

.custom-select-option:first-child {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

.custom-select-option:last-child {
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
}

.custom-select-option.selected {
    background-color: #dbeafe;
    color: #1e3a8a;
    font-weight: 600;
}

.custom-select-option.disabled {
    color: #9ca3af;
    cursor: not-allowed;
}

.custom-select-option.disabled:hover {
    background-color: white;
}

/* Search Input w selectach */
.select-search {
    padding: 0.75rem;
    border-bottom: 2px solid #f3f4f6;
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
}

.select-search .relative {
    position: relative;
}

.select-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

.select-search input::placeholder {
    color: #9ca3af;
}

/* Source Badge Component */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.source-badge.autoplac {
    background-color: #dbeafe;
    color: #1e40af;
    border: 2px solid #93c5fd;
}

.source-badge.otomoto {
    background-color: #fed7aa;
    color: #9a3412;
    border: 2px solid #fdba74;
}

.source-badge.olx {
    background-color: #dcfce7;
    color: #166534;
    border: 2px solid #86efac;
}

/* Source Stats Card */
.source-stats-card {
    background: linear-gradient(to bottom right, white, #f9fafb);
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 2px solid #f3f4f6;
    padding: 1.5rem;
    transition: all 0.3s;
}

.source-stats-card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(1.05);
}

/* Filter Counter Badge */
.filter-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: #2563eb;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Clear Filters Button */
.clear-filters-btn {
    transition: all 0.2s ease;
}

.clear-filters-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clear-filters-btn:active {
    transform: translateY(0);
}

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

/* Sort Button */
.sort-button {
    padding: 0.5rem 1rem;
    background-color: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    color: #374151;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.sort-button:hover {
    border-color: #3b82f6;
    color: #1e40af;
}

.sort-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.sort-button.active {
    background-color: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* Validation Message */
.validation-message {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    animation: fadeIn 0.2s ease-out;
}

.validation-message.error {
    color: #dc2626;
}

.validation-message.info {
    color: #2563eb;
}

/* Loading Skeleton */
.skeleton {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    background-color: #e5e7eb;
    border-radius: 0.25rem;
}

/* Custom scrollbar */
.custom-select-dropdown::-webkit-scrollbar {
    width: 8px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background-color: #f3f4f6;
    border-radius: 0.25rem;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 0.25rem;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-10px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-in {
    animation: fadeIn 0.2s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* Lepsze pozycjonowanie dla grid layout */
.grid .custom-select {
    position: relative;
}

/* Range inputs grid - wymuszenie działania gridu */
.range-inputs-grid {
    display: grid !important;
    grid-template-columns: repeat(1, 1fr) !important;
    gap: 1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.range-inputs-grid > div {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

@media (min-width: 640px) {
    .range-inputs-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .range-inputs-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (min-width: 1280px) {
    .range-inputs-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }
}

/* Source Chips - Piękne chipy z faviconkami */
.source-chip {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.source-chip img {
    flex-shrink: 0;
    object-fit: contain;
}

/* View Toggle Buttons - Przyciski przełączania widoku */
.view-toggle-btn {
    min-width: 2rem;
    min-height: 2rem;
}

.view-toggle-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}