/**
 * search-cpv-filter.css - v2.4
 * Style dla SearchCPVFilter component
 * Modern, responsive design with smooth animations
 */

/* Main container */
.search-cpv-filter {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.search-cpv-filter:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Header */
.search-cpv-header {
    margin-bottom: 16px;
}

.search-cpv-header label {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
    color: #1f2937;
    margin: 0;
}

.search-cpv-header label i {
    margin-right: 10px;
    color: #2563eb;
    font-size: 16px;
}

/* Dropdown container */
.search-cpv-dropdown-container {
    margin-bottom: 20px;
}

.search-cpv-dropdown {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    background: #ffffff;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    background-color: #ffffff !important;
}

.search-cpv-dropdown:hover {
    border-color: #2563eb;
    background-color: #f9fafb;
}

.search-cpv-dropdown:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background-color: #ffffff;
}

.search-cpv-dropdown:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f3f4f6;
}

.search-cpv-dropdown option {
    padding: 10px;
    font-weight: 500;
    background-color: #ffffff;
    color: #1f2937;
}

/* Subcategories panel */
.search-cpv-subcategories-panel {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
    animation: slideDown 0.3s ease-out;
}

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

/* Panel header */
.search-cpv-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 2px solid #d1d5db;
}

.search-cpv-panel-title {
    font-weight: 600;
    font-size: 15px;
    color: #1f2937;
}

.search-cpv-panel-actions {
    display: flex;
    gap: 10px;
}

.search-cpv-btn {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid transparent;
    background: #ffffff;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.search-cpv-btn:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-cpv-btn:active {
    transform: translateY(0);
}

.search-cpv-btn i {
    font-size: 12px;
}

.search-cpv-select-all {
    background: #dbeafe !important;
    color: #1e40af !important;
    border-color: #93c5fd !important;
}

.search-cpv-select-all:hover {
    background: #bfdbfe !important;
    border-color: #60a5fa !important;
}

.search-cpv-deselect-all {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border-color: #fca5a5 !important;
}

.search-cpv-deselect-all:hover {
    background: #fecaca !important;
    border-color: #f87171 !important;
}

/* Subcategories grid */
.search-cpv-subcategories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 20px;
    max-height: 450px;
    overflow-y: auto;
}

/* Checkbox item */
.search-cpv-checkbox-item {
    display: flex;
    align-items: flex-start;
    padding: 14px 16px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-cpv-checkbox-item:hover {
    border-color: #2563eb;
    background: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.1);
}

.search-cpv-checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #2563eb;
    flex-shrink: 0;
    margin-top: 2px;
}

.search-cpv-checkbox-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-cpv-checkbox-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    line-height: 1.4;
}

.search-cpv-checkbox-code {
    font-size: 11px;
    font-family: 'Courier New', Monaco, monospace;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

/* Checked state */
.search-cpv-checkbox-item:has(input:checked) {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-cpv-checkbox-item:has(input:checked) .search-cpv-checkbox-label {
    color: #1e40af;
    font-weight: 600;
}

.search-cpv-checkbox-item:has(input:checked) .search-cpv-checkbox-code {
    background: #2563eb;
    color: #ffffff;
    font-weight: 600;
}

/* Panel footer */
.search-cpv-panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-top: 2px solid #d1d5db;
}

.search-cpv-selected-count {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.search-cpv-apply {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    color: #ffffff !important;
    border: none !important;
    padding: 10px 20px !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.search-cpv-apply:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4) !important;
}

/* Error message */
.search-cpv-error {
    padding: 16px;
    background: #fee2e2;
    color: #991b1b;
    border: 2px solid #fca5a5;
    border-radius: 8px;
    margin-top: 16px;
    font-weight: 500;
    display: none;
}

.search-cpv-error::before {
    content: "⚠️ ";
    margin-right: 8px;
}

/* Scrollbar styling */
.search-cpv-subcategories-grid::-webkit-scrollbar {
    width: 10px;
}

.search-cpv-subcategories-grid::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 5px;
}

.search-cpv-subcategories-grid::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 5px;
    border: 2px solid #f3f4f6;
}

.search-cpv-subcategories-grid::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Loading state */
.search-cpv-filter.loading {
    opacity: 0.6;
    pointer-events: none;
}

.search-cpv-filter.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 1024px) {
    .search-cpv-subcategories-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .search-cpv-filter {
        padding: 16px;
    }
    
    .search-cpv-panel-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .search-cpv-panel-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .search-cpv-btn {
        width: 100%;
        justify-content: center;
    }
    
    .search-cpv-subcategories-grid {
        grid-template-columns: 1fr;
        max-height: 350px;
    }
    
    .search-cpv-panel-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-cpv-apply {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .search-cpv-filter {
        padding: 12px;
        border-radius: 8px;
    }
    
    .search-cpv-header label {
        font-size: 14px;
    }
    
    .search-cpv-dropdown {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .search-cpv-checkbox-item {
        padding: 12px;
    }
    
    .search-cpv-checkbox-label {
        font-size: 13px;
    }
}

/* Print styles */
@media print {
    .search-cpv-filter {
        display: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .search-cpv-filter {
        border-width: 3px;
    }
    
    .search-cpv-checkbox-item {
        border-width: 3px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .search-cpv-filter,
    .search-cpv-checkbox-item,
    .search-cpv-btn,
    .search-cpv-subcategories-panel {
        animation: none;
        transition: none;
    }
}

/* Dark mode - see body.dark-theme rules at the end */

/* ========== DARK MODE - body.dark-theme ========== */
body.dark-theme .search-cpv-filter {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .search-cpv-header label,
body.dark-theme .search-cpv-header,
body.dark-theme .search-cpv-filter label {
    color: #e2e8f0 !important;
}

body.dark-theme .search-cpv-dropdown {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
}

body.dark-theme .search-cpv-dropdown:hover {
    border-color: #60a5fa !important;
    background-color: #3b4a5c !important;
}

body.dark-theme .search-cpv-dropdown:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}

body.dark-theme .search-cpv-dropdown option {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

body.dark-theme .search-cpv-subcategories-panel {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .search-cpv-panel-header {
    background: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .search-cpv-panel-title {
    color: #e2e8f0 !important;
}

body.dark-theme .search-cpv-subcategories-grid {
    background: #1e293b !important;
}

body.dark-theme .search-cpv-checkbox-item {
    background: #334155 !important;
    border-color: #475569 !important;
}

body.dark-theme .search-cpv-checkbox-item:hover {
    background: #3b4a5c !important;
    border-color: #60a5fa !important;
}

body.dark-theme .search-cpv-checkbox-label {
    color: #e2e8f0 !important;
}

body.dark-theme .search-cpv-checkbox-code {
    background: #1e293b !important;
    color: #94a3b8 !important;
}

body.dark-theme .search-cpv-checkbox-item:has(input:checked) {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%) !important;
    border-color: #3b82f6 !important;
}

body.dark-theme .search-cpv-checkbox-item:has(input:checked) .search-cpv-checkbox-label {
    color: #ffffff !important;
}

body.dark-theme .search-cpv-checkbox-item:has(input:checked) .search-cpv-checkbox-code {
    background: #3b82f6 !important;
    color: #ffffff !important;
}

body.dark-theme .search-cpv-panel-footer {
    background: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .search-cpv-selected-count {
    color: #94a3b8 !important;
}

body.dark-theme .search-cpv-btn {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .search-cpv-btn:hover {
    background: #3b4a5c !important;
}

body.dark-theme .search-cpv-select-all {
    background: #065f46 !important;
    color: #d1fae5 !important;
    border-color: #10b981 !important;
}

body.dark-theme .search-cpv-select-all:hover {
    background: #047857 !important;
}

body.dark-theme .search-cpv-deselect-all {
    background: #7f1d1d !important;
    color: #fecaca !important;
    border-color: #ef4444 !important;
}

body.dark-theme .search-cpv-deselect-all:hover {
    background: #991b1b !important;
}

body.dark-theme .search-cpv-apply {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    color: #ffffff !important;
}

body.dark-theme .search-cpv-error {
    background: #7f1d1d !important;
    color: #fecaca !important;
    border-color: #ef4444 !important;
}

/* Scrollbar dark mode */
body.dark-theme .search-cpv-subcategories-grid::-webkit-scrollbar-track {
    background: #1e293b !important;
}

body.dark-theme .search-cpv-subcategories-grid::-webkit-scrollbar-thumb {
    background: #475569 !important;
    border-color: #1e293b !important;
}

body.dark-theme .search-cpv-subcategories-grid::-webkit-scrollbar-thumb:hover {
    background: #64748b !important;
}