/* Variables */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --error-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --gray-border: #e5e7eb;
    --gray-text: #6b7280;
    --loading-overlay: rgba(0, 0, 0, 0.5);
}

/* Base styles */
body {
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Loading Spinner */
.loading-spinner {
    border: 4px solid var(--gray-border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spinner 1s linear infinite;
}

@keyframes spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Search Input Loading State */
.search-loading {
    position: relative;
}

.search-loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

/* Search Results Container */
#searchResults {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-border) transparent;
}

#searchResults::-webkit-scrollbar {
    width: 6px;
}

#searchResults::-webkit-scrollbar-track {
    background: transparent;
}

#searchResults::-webkit-scrollbar-thumb {
    background-color: var(--gray-border);
    border-radius: 3px;
}

/* Product Categories */
.product-category {
    margin-bottom: 2rem;
}

.product-category-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.legacy-category .product-category-title {
    color: #6b7280;
}

/* Product Cards */
.product-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color), var(--primary-hover));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card:hover::before {
    opacity: 1;
}

/* Legacy Product Styles */
.product-card.legacy {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f9fafb;
}

.product-card.legacy:hover {
    transform: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.product-card.legacy::before {
    display: none;
}

.product-card.legacy button {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.product-card.legacy button:hover {
    background-color: #9ca3af;
}

/* Badge Styles */
.product-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

.badge-legacy {
    background-color: #f3f4f6;
    color: #374151;
}

.badge-vc {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-vr {
    background-color: #f3e8ff;
    color: #6b21a8;
}

/* Form Input Validation States */
input.border-red-500 {
    border-color: var(--error-color);
    padding-right: 2.5rem;
    background-position: right 0.5rem center;
}

input.border-green-500 {
    border-color: var(--success-color);
    padding-right: 2.5rem;
    background-position: right 0.5rem center;
}

/* Validation Message Animation */
.validation-message {
    animation: slideDown 0.2s ease-out;
}

.validation-details {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    0% { 
        opacity: 0;
        transform: translateY(-10px);
    }
    100% { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Icon Animation */
.validation-icon {
    animation: fadeIn 0.2s ease-out;
}

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

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 1rem;
    border-radius: 0.375rem;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 50;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Success Message */
.success-message {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease-out;
}

/* Error Alert */
#errorAlert {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Search Result Items */
#resultsContainer > div {
    transition: all 0.2s ease-in-out;
}

#resultsContainer > div:hover,
#resultsContainer > div.selected {
    background-color: #f8fafc;
    transform: translateX(4px);
}

/* Highlight Text in Search Results */
mark {
    background-color: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
    animation: highlight 1s ease-out;
}

@keyframes highlight {
    0% { background-color: #fef9c3; }
    100% { background-color: #fef08a; }
}

/* Form Field Focus States */
input:focus, 
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Disabled States */
input:disabled,
select:disabled,
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Required Field Indicator */
label.required::after {
    content: ' *';
    color: var(--error-color);
}

/* Loading Overlay */
#loadingSpinner {
    backdrop-filter: blur(2px);
}

/* Progress Steps */
.step-indicator {
    transition: all 0.3s ease-in-out;
}

/* Mobile Responsive Adjustments */
@media (max-width: 640px) {
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    #searchResults {
        max-height: 300px;
    }

    .product-card {
        margin-bottom: 1rem;
    }
    
    .product-grid {
        grid-template-columns: 1fr;
    }
    
    .product-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dark-mode {
        background-color: #1f2937;
        color: #f3f4f6;
    }

    .dark-mode .product-card {
        background-color: #374151;
    }

    .dark-mode .product-card.legacy {
        background-color: #1f2937;
        opacity: 0.5;
    }

    .dark-mode .product-badge {
        background-color: #4b5563;
        color: #e5e7eb;
    }

    .dark-mode .badge-legacy {
        background-color: #374151;
        color: #9ca3af;
    }

    .dark-mode .badge-vc {
        background-color: #1e3a8a;
        color: #93c5fd;
    }

    .dark-mode .badge-vr {
        background-color: #5b21b6;
        color: #e9d5ff;
    }

    .dark-mode input,
    .dark-mode select {
        background-color: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }

    .dark-mode .validation-message {
        color: #f3f4f6;
    }
    
    .dark-mode .product-category-title {
        color: #e5e7eb;
    }

    .dark-mode .legacy-category .product-category-title {
        color: #9ca3af;
    }
}

/* Print Styles */
@media print {
    .product-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .product-card::before {
        display: none;
    }

    .product-badge {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    button {
        display: none;
    }

    .legacy-category {
        opacity: 1;
    }
}