/* CSS Variables for Light and Dark Themes */
:root {
    /* Colors */
    --text-primary: #333;
    --text-secondary: #495057;
    --text-tertiary: #6c757d;
    --text-muted: #adb5bd;
    --text-placeholder: #6c757d;
    
    /* Backgrounds */
    --bg-primary: #f8f9fa;
    --bg-secondary: white;
    --bg-tertiary: #f8f9fa;
    --bg-modal-overlay: rgba(0, 0, 0, 0.5);
    --bg-footer: #343a40;
    
    /* Borders */
    --border-light: #e9ecef;
    --border-focus: #667eea;
    --border-error: #fed7d7;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Primary Colors */
    --primary-blue: #667eea;
    --primary-purple: #764ba2;
    
    /* Error Colors */
    --error-bg: #fff5f5;
    --error-text: #e53e3e;
    --error-text-dark: #c53030;
    --error-border: #fed7d7;
    
    /* Loading Colors */
    --loading-bg: #e9ecef;
    --loading-accent: #667eea;
    
    /* Shadows */
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.1);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-focus: 0 0 0 3px rgba(102, 126, 234, 0.1);
    --shadow-button-hover: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Dark Theme */
@media (prefers-color-scheme: dark) {
    :root {
        /* Colors */
        --text-primary: #e9ecef;
        --text-secondary: #ced4da;
        --text-tertiary: #adb5bd;
        --text-muted: #6c757d;
        --text-placeholder: #868e96;
        
        /* Backgrounds */
        --bg-primary: #1a1d23;
        --bg-secondary: #2d3748;
        --bg-tertiary: #4a5568;
        --bg-modal-overlay: rgba(0, 0, 0, 0.8);
        --bg-footer: #1a202c;
        
        /* Borders */
        --border-light: #4a5568;
        --border-focus: #667eea;
        --border-error: #e53e3e;
        
        /* Error Colors */
        --error-bg: #2d1b1b;
        --error-text: #fc8181;
        --error-text-dark: #f56565;
        --error-border: #e53e3e;
        
        /* Loading Colors */
        --loading-bg: #4a5568;
        --loading-accent: #667eea;
        
        /* Shadows */
        --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
        --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.2);
        --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.3);
        --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.5);
        --shadow-focus: 0 0 0 3px rgba(102, 126, 234, 0.3);
        --shadow-button-hover: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: var(--gradient-primary);
    color: white;
    padding: 2rem 0;
    text-align: center;
    box-shadow: var(--shadow-light);
}

.header-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Input Section */
.input-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.hardware-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1.5rem;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-input {
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.form-input::placeholder {
    color: var(--text-placeholder);
}

.submit-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: fit-content;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-button-hover);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.search-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

/* Controls Section */
.controls-section {
    margin-bottom: 2rem;
}

.controls-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.controls-container h3 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.sort-controls {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.sort-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sort-select {
    padding: 0.5rem;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.3s ease;
}

.sort-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.sort-order {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.sort-order input[type="checkbox"] {
    margin: 0;
}

.filter-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: start;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.filter-select {
    padding: 0.5rem;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 80px;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.range-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-group input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    outline: none;
}

.range-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-blue);
    border-radius: 50%;
    cursor: pointer;
}

.range-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-blue);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.range-group span {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 60px;
    text-align: right;
}

.apply-filters-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    align-self: flex-end;
}

.apply-filters-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-button-hover);
}

.apply-filters-btn:active {
    transform: translateY(0);
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 3rem 0;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--loading-bg);
    border-top: 4px solid var(--loading-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-tertiary);
    font-size: 1.1rem;
}

/* Error Section */
.error-section {
    margin-bottom: 2rem;
}

.error-container {
    background: var(--error-bg);
    border: 2px solid var(--error-border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.error-title {
    color: var(--error-text);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.error-message {
    color: var(--error-text-dark);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.retry-btn {
    background: var(--error-text);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.retry-btn:hover {
    background: var(--error-text-dark);
}

/* Results Section */
.results-section {
    margin-bottom: 2rem;
}

.results-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.results-title {
    font-size: 2rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.results-count {
    color: var(--text-tertiary);
    font-size: 1.1rem;
}

.results-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Model Card Styles */
.model-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.model-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

.model-card h3 {
    color: var(--text-secondary);
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.model-card p {
    color: var(--text-tertiary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.hardware-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.hardware-info span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.model-card button {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
    width: 100%;
}

.model-card button:hover {
    transform: translateY(-1px);
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-modal);
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 1001;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
}

/* Footer */
.footer {
    background: var(--bg-footer);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-text {
    margin: 0;
    color: var(--text-muted);
}

.footer-text a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-text a:hover {
    color: var(--primary-purple);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-title {
        font-size: 2rem;
    }
    
    .header-subtitle {
        font-size: 1rem;
    }
    
    .hardware-form {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .submit-btn {
        width: 100%;
    }
    
    .results-container {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .input-section {
        padding: 1.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    /* Controls responsive styles */
    .sort-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .filter-panel {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .controls-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0;
    }
    
    .header-title {
        font-size: 1.8rem;
    }
    
    .main {
        padding: 1rem 0;
    }
    
    .input-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .form-input, .search-input {
        padding: 0.65rem;
    }
    
    .submit-btn {
        padding: 0.65rem 1.5rem;
    }
}