* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* iOS Colors - точно как в приложении */
    --color-primary: #000000;
    --color-secondary: #8E8E93;
    --color-accent: #FF9500;
    --color-background: #FFFFFF;
    --color-surface: #F2F2F7;
    --color-gray6: #F2F2F7;
    --color-gray: #8E8E93;
    --color-error: #FF3B30;
    
    /* iOS Spacing */
    --spacing-small: 8px;
    --spacing-medium: 16px;
    --spacing-large: 24px;
    --spacing-extra-large: 32px;
    
    /* iOS Corner Radius */
    --radius-small: 8px;
    --radius-medium: 12px;
    --radius-large: 16px;
    
    /* iOS Shadows */
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    padding-bottom: 80px; /* Место для нижней навигации */
}

#app {
    min-height: 100vh;
}

/* Верхняя навигация */
.top-nav {
    background: var(--color-background);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.top-nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-medium);
    max-width: 1200px;
    margin: 0 auto;
}

.page-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.filter-btn {
    background: none;
    border: none;
    padding: var(--spacing-small);
    cursor: pointer;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-active-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-small) var(--spacing-medium);
    background: var(--color-surface);
    font-size: 13px;
    color: var(--color-secondary);
    max-width: 1200px;
    margin: 0 auto;
}

.reset-filter-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}

/* Контентная область */
.content-area {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-medium);
}

/* Состояния загрузки */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-extra-large);
    min-height: 400px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-surface);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-state p {
    margin-top: var(--spacing-medium);
    color: var(--color-secondary);
    font-size: 15px;
}

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-extra-large);
    min-height: 400px;
    text-align: center;
}

.error-state svg {
    color: var(--color-accent);
    margin-bottom: var(--spacing-medium);
}

.error-state h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: var(--spacing-small);
}

.error-state p {
    color: var(--color-secondary);
    font-size: 15px;
    margin-bottom: var(--spacing-medium);
}

.empty-state {
    text-align: center;
    padding: var(--spacing-extra-large);
    color: var(--color-secondary);
    font-size: 17px;
    font-weight: 500;
}

.empty-subtitle {
    font-size: 15px;
    color: var(--color-secondary);
    margin-top: var(--spacing-small);
}

/* Список автомобилей */
.cars-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-medium);
}

/* Карточка автомобиля - ТОЧНАЯ КОПИЯ iOS */
.car-card {
    display: flex;
    gap: 12px;
    padding: var(--spacing-small) var(--spacing-medium);
    background: var(--color-background);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 0.5px solid rgba(0, 0, 0, 0.05);
}

.car-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.car-image-container {
    flex-shrink: 0;
    width: 100px;
    height: 80px;
    border-radius: var(--radius-small);
    overflow: hidden;
    background: var(--color-gray6);
}

.car-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.car-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.car-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.3;
    margin: 0;
}

.car-price {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.car-details {
    font-size: 13px;
    color: var(--color-secondary);
    line-height: 1.4;
    margin: 0;
}

.car-region {
    font-size: 13px;
    color: var(--color-secondary);
    margin-top: 2px;
}

/* Кнопки */
.btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0 var(--spacing-large);
    height: 50px;
    border-radius: var(--radius-medium);
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background: #1a1a1a;
    transform: scale(0.98);
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    padding: 0 var(--spacing-large);
    height: 50px;
    border-radius: var(--radius-medium);
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: var(--color-surface);
}

.create-ad-btn {
    width: 100%;
    margin-bottom: var(--spacing-medium);
}

/* Нижняя навигация - iOS стиль */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-background);
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: var(--spacing-small) 0;
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: var(--spacing-small);
    cursor: pointer;
    color: var(--color-secondary);
    font-size: 10px;
    font-weight: 500;
    font-family: inherit;
    transition: color 0.2s ease;
    flex: 1;
}

.nav-tab svg {
    width: 24px;
    height: 24px;
}

.nav-tab.active {
    color: var(--color-primary);
}

.nav-tab.active svg {
    fill: var(--color-primary);
}

.nav-tab span {
    font-size: 10px;
    line-height: 1;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background-color: var(--color-background);
    margin: 5% auto;
    padding: var(--spacing-large);
    border-radius: var(--radius-large);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-large);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.close {
    color: var(--color-secondary);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
    background: none;
    border: none;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: var(--color-primary);
}

/* Формы */
.filter-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-medium);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-small);
}

.filter-group label {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-primary);
}

.filter-group input,
.filter-group select,
.filter-group textarea {
    padding: 12px var(--spacing-medium);
    border: none;
    border-radius: var(--radius-medium);
    font-size: 17px;
    font-family: inherit;
    background-color: var(--color-gray6);
    color: var(--color-primary);
    transition: background-color 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus,
.filter-group textarea:focus {
    outline: none;
    background-color: #E5E5EA;
}

.filter-group select[multiple] {
    min-height: 100px;
}

.modal-footer {
    display: flex;
    gap: var(--spacing-medium);
    margin-top: var(--spacing-large);
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
    flex: 1;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-medium);
}

.auth-form input {
    width: 100%;
    padding: 12px var(--spacing-medium);
    border: none;
    border-radius: var(--radius-medium);
    font-size: 17px;
    font-family: inherit;
    background-color: var(--color-gray6);
    color: var(--color-primary);
    transition: background-color 0.2s ease;
}

.auth-form input:focus {
    outline: none;
    background-color: #E5E5EA;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: var(--spacing-extra-large);
}

.app-title {
    font-size: 48px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--spacing-small);
}

.app-subtitle {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-secondary);
    margin-bottom: var(--spacing-extra-large);
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-medium);
    width: 100%;
    max-width: 400px;
}

.auth-buttons .btn-primary,
.auth-buttons .btn-secondary {
    width: 100%;
}

/* User Info */
.user-info-card {
    background: var(--color-background);
    padding: var(--spacing-large);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-card);
}

.user-info-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--spacing-small);
}

.user-phone {
    color: var(--color-secondary);
    font-size: 15px;
    margin-bottom: var(--spacing-large);
}

.logout-btn {
    width: 100%;
}

/* Детали автомобиля */
.car-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-medium);
    margin-top: var(--spacing-medium);
}

.detail-label {
    color: var(--color-secondary);
    font-size: 13px;
    font-weight: 500;
}

.detail-value {
    font-weight: 600;
    font-size: 15px;
    margin-top: 4px;
    color: var(--color-primary);
}

.car-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-medium);
    margin-top: var(--spacing-medium);
}

.car-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-medium);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.car-photo:hover {
    transform: scale(1.05);
}

#photoPreview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--spacing-small);
    margin: var(--spacing-medium) 0;
}

.preview-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-small);
}

/* Секции */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* Адаптивность */
@media (max-width: 768px) {
    .cars-list {
        gap: var(--spacing-small);
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: var(--spacing-medium);
    }
    
    .car-detail-grid {
        grid-template-columns: 1fr;
    }
}
