/* Variables */
:root {
    --openserve-primary: #004b96;
    --openserve-secondary: #00a0df;
    --openserve-accent: #ff6b00;
    --openserve-light: #e6f3ff;
    --primary-hover: #003d7a;
    --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(--openserve-primary);
    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(--openserve-primary);
    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 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(--openserve-primary), var(--openserve-secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Product Speed Badge */
.speed-badge {
    background: linear-gradient(135deg, var(--openserve-primary), var(--openserve-secondary));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Network Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-ready {
    background-color: #dcfce7;
    color: #166534;
}

.status-coming-soon {
    background-color: #fef9c3;
    color: #854d0e;
}

.status-unavailable {
    background-color: #fee2e2;
    color: #991b1b;
}

/* 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; }
}

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

.step-active {
    color: var(--openserve-primary);
}

.step-active .step-number {
    border-color: var(--openserve-primary);
    background-color: var(--openserve-light);
}

/* Custom Button Styles */
.btn-openserve {
    background-color: var(--openserve-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-openserve:hover {
    background-color: var(--primary-hover);
}

.btn-openserve:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 75, 150, 0.2);
}

/* AMID Reference Badge */
.amid-badge {
    background-color: var(--openserve-light);
    color: var(--openserve-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Selected Location Card */
.location-card {
    border: 1px solid var(--gray-border);
    border-radius: 0.5rem;
    padding: 1rem;
    background-color: white;
    margin-bottom: 1rem;
}

.location-card.selected {
    border-color: var(--openserve-secondary);
    background-color: var(--openserve-light);
}

/* 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;
    }
}

/* Error Alert */
#errorAlert {
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--error-color);
}

@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;
    border-left: 3px solid transparent;
}

#resultsContainer > div:hover {
    background-color: var(--openserve-light);
    border-left-color: var(--openserve-primary);
}

/* Highlight Text in Search Results */
mark {
    background-color: var(--openserve-light);
    color: var(--openserve-primary);
    padding: 0 2px;
    border-radius: 2px;
    animation: highlight 1s ease-out;
}

@keyframes highlight {
    0% { background-color: var(--openserve-secondary); }
    100% { background-color: var(--openserve-light); }
}

/* Form Field Focus States */
input:focus, 
select:focus {
    outline: none;
    border-color: var(--openserve-primary);
    box-shadow: 0 0 0 3px rgba(0, 75, 150, 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);
}

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

    #searchResults {
        max-height: 300px;
    }

    .product-card {
        margin-bottom: 1rem;
    }

    .step-indicator {
        font-size: 0.875rem;
    }

    .amid-badge {
        font-size: 0.75rem;
        padding: 0.125rem 0.5rem;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none;
    }

    .product-card {
        break-inside: avoid;
    }

    .location-card {
        break-inside: avoid;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --openserve-primary: #003366;
        --openserve-secondary: #0066cc;
        --openserve-accent: #cc5500;
    }

    .product-card::before {
        background: var(--openserve-primary);
    }

    mark {
        background-color: yellow;
        color: black;
    }
}