/**
 * Theme22 Main Stylesheet
 * Primary CSS for the dealer website theme
 * Optimized for performance and responsive design
 */

/* CSS Custom Properties for theme consistency */
:root {
    /* Primary theme colors - will be overridden by server variables */
    --theme-primary-color: #007bff;
    --theme-secondary-color: #6c757d;
    --theme-primary-hover: #0056b3;
    --theme-white-text-color: #ffffff;
    
    /* Additional theme variables */
    --theme-text-color: #333333;
    --theme-background-color: #ffffff;
    --theme-border-color: #e0e0e0;
    --theme-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --theme-border-radius: 4px;
    
    /* Typography */
    --theme-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --theme-font-size-base: 16px;
    --theme-line-height-base: 1.5;
    
    /* Spacing */
    --theme-spacing-xs: 0.25rem;
    --theme-spacing-sm: 0.5rem;
    --theme-spacing-md: 1rem;
    --theme-spacing-lg: 1.5rem;
    --theme-spacing-xl: 3rem;
}

/* Base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--theme-font-family);
    font-size: var(--theme-font-size-base);
    line-height: var(--theme-line-height-base);
    color: var(--theme-text-color);
    background-color: var(--theme-background-color);
    margin: 0;
    padding: 0;
}

/* Header styles */
.header {
    background-color: var(--theme-primary-color);
    color: var(--theme-white-text-color);
    padding: var(--theme-spacing-md);
}

.header .logo {
    font-size: 1.5rem;
    font-weight: bold;
}

/* Navigation styles */
.navigation {
    background-color: var(--theme-background-color);
    border-bottom: 1px solid var(--theme-border-color);
    padding: var(--theme-spacing-sm) 0;
}

.navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.navigation li {
    margin-right: var(--theme-spacing-md);
}

.navigation a {
    color: var(--theme-text-color);
    text-decoration: none;
    padding: var(--theme-spacing-sm) var(--theme-spacing-md);
    border-radius: var(--theme-border-radius);
    transition: background-color 0.3s ease;
}

.navigation a:hover,
.navigation a:focus {
    background-color: var(--theme-primary-color);
    color: var(--theme-white-text-color);
}

/* Main content area */
.main-content {
    min-height: calc(100vh - 200px);
    padding: var(--theme-spacing-lg);
}

/* Card component */
.card {
    background-color: var(--theme-background-color);
    border: 1px solid var(--theme-border-color);
    border-radius: var(--theme-border-radius);
    box-shadow: var(--theme-shadow);
    padding: var(--theme-spacing-lg);
    margin-bottom: var(--theme-spacing-lg);
}

.card-header {
    border-bottom: 1px solid var(--theme-border-color);
    padding-bottom: var(--theme-spacing-md);
    margin-bottom: var(--theme-spacing-md);
}

.card-title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--theme-primary-color);
}

/* Button styles */
.btn {
    display: inline-block;
    padding: var(--theme-spacing-sm) var(--theme-spacing-md);
    background-color: var(--theme-primary-color);
    color: var(--theme-white-text-color);
    border: none;
    border-radius: var(--theme-border-radius);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-family: inherit;
    font-size: inherit;
}

.btn:hover,
.btn:focus {
    background-color: var(--theme-primary-hover);
}

.btn-secondary {
    background-color: var(--theme-secondary-color);
}

.btn-outline {
    background-color: transparent;
    color: var(--theme-primary-color);
    border: 1px solid var(--theme-primary-color);
}

.btn-outline:hover,
.btn-outline:focus {
    background-color: var(--theme-primary-color);
    color: var(--theme-white-text-color);
}

/* Form styles */
.form-group {
    margin-bottom: var(--theme-spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--theme-spacing-xs);
    font-weight: 600;
    color: var(--theme-text-color);
}

.form-control {
    width: 100%;
    padding: var(--theme-spacing-sm);
    border: 1px solid var(--theme-border-color);
    border-radius: var(--theme-border-radius);
    font-family: inherit;
    font-size: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--theme-primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Floating label enhancement */
.floating-label {
    position: relative;
}

.floating-label .form-label {
    position: absolute;
    top: var(--theme-spacing-sm);
    left: var(--theme-spacing-sm);
    transition: all 0.3s ease;
    pointer-events: none;
    background-color: var(--theme-background-color);
    padding: 0 var(--theme-spacing-xs);
}

.floating-label.focused .form-label {
    top: -8px;
    font-size: 0.875rem;
    color: var(--theme-primary-color);
}

/* Stock listing styles */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--theme-spacing-lg);
    margin-bottom: var(--theme-spacing-xl);
}

.stock-card {
    border: 1px solid var(--theme-border-color);
    border-radius: var(--theme-border-radius);
    overflow: hidden;
    box-shadow: var(--theme-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stock-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.stock-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.stock-card-content {
    padding: var(--theme-spacing-md);
}

.stock-card-title {
    margin: 0 0 var(--theme-spacing-sm) 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.stock-card-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--theme-primary-color);
    margin: var(--theme-spacing-sm) 0;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--theme-background-color);
    padding: var(--theme-spacing-lg);
    border-radius: var(--theme-border-radius);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--theme-spacing-md);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--theme-text-color);
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--theme-primary-color);
    color: var(--theme-white-text-color);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

/* Footer styles */
.footer {
    background-color: var(--theme-text-color);
    color: var(--theme-white-text-color);
    padding: var(--theme-spacing-xl) var(--theme-spacing-lg);
    margin-top: var(--theme-spacing-xl);
}

/* Responsive design */
@media (max-width: 768px) {
    .navigation ul {
        flex-direction: column;
    }
    
    .navigation li {
        margin-right: 0;
        margin-bottom: var(--theme-spacing-xs);
    }
    
    .stock-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: var(--theme-spacing-md);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .navigation,
    .back-to-top,
    .modal {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        break-inside: avoid;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 2px solid var(--theme-border-color);
    border-top: 2px solid var(--theme-primary-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: var(--theme-spacing-xs);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}