/* Windows 11 Design System */
:root {
    --bg-primary: #f3f3f3;
    --bg-secondary: #ffffff;
    --bg-hover: #f5f5f5;
    --text-primary: #1f1f1f;
    --text-secondary: #606060;
    --accent: #0078d4;
    --accent-hover: #106ebe;
    --border: #e5e5e5;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --status-green: #34c759;
    --status-yellow: #ff9500;
    --status-red: #ff3b30;
    --radius: 4px;
    --radius-lg: 8px;
}

[data-theme="dark"] {
    --bg-primary: #202020;
    --bg-secondary: #2d2d2d;
    --bg-hover: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #0078d4;
    --accent-hover: #1a86e0;
    --border: #404040;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Buttons */
.btn-primary {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease-in-out;
    font-family: inherit;
    height: 32px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

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

.btn-secondary {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    transition: all 150ms ease-in-out;
    font-family: inherit;
    height: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* Main */
.app-main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
}

/* Toolbar */
.toolbar {
    margin-bottom: 24px;
    overflow: visible;
}

.search-box {
    margin-bottom: 16px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    height: 32px;
    transition: all 150ms ease-in-out;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

.toolbar-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    overflow: visible;
}

.filter-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    overflow: visible;
}

.filter-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.filter-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 150ms ease-in-out;
    font-family: inherit;
    height: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.filter-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Выпадающий список "Все/Мои" */
.user-filter-dropdown {
    position: relative;
    overflow: visible;
    z-index: 1001;
}

.dropdown-btn {
    position: relative;
    padding-right: 32px;
}

.dropdown-btn::after {
    content: '▼';
    position: absolute;
    right: 12px;
    font-size: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1002;
    min-width: 120px;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 150ms ease-in-out;
    font-size: 13px;
    color: var(--text-primary);
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item.active {
    background: var(--accent);
    color: white;
}

/* Cars List */
.cars-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px;
}

.car-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    position: relative;
    transition: all 150ms ease-in-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.reminder-countdown {
    position: absolute;
    right: 12px;
    bottom: 12px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    pointer-events: none; /* чтобы клики проходили в карточку */
}

.reminder-countdown.expired {
    display: none;
}

.car-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.85);
}

.car-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.car-lot {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.car-date {
    font-weight: 400;
    font-size: 13px;
    color: var(--text-secondary);
}

.check-engine-icon {
    display: inline-block;
    margin-left: 8px;
    width: 25px;
    height: 27px;
    cursor: help;
    vertical-align: middle;
    object-fit: contain;
}

.car-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    flex-wrap: wrap;
}

.buyout-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 4px;
}

.buyout-yes {
    background: #10b981;
    color: white;
}

.buyout-no {
    background: #ef4444;
    color: white;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.green {
    background: var(--status-green);
}

.status-dot.yellow {
    background: var(--status-yellow);
}

.status-dot.red {
    background: var(--status-red);
}

.car-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.car-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.car-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.car-url {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--accent);
    word-break: break-all;
}

.car-responsible {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.car-card-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.btn-send-telegram {
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    grid-column: 1 / -1;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.modal-header {
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-body {
    margin-bottom: 16px;
}

.modal-body input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    height: 32px;
    margin-bottom: 12px;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.error-message {
    background: rgba(232, 17, 35, 0.1);
    border: 1px solid rgba(232, 17, 35, 0.3);
    color: #e81123;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

/* Индикатор загрузки */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    margin-top: 16px;
}

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

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

.loading-text {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Theme Toggle */
.theme-toggle-wrapper {
    display: flex !important;
    align-items: center;
    gap: 12px;
    margin-right: 16px;
    visibility: visible !important;
    opacity: 1 !important;
}

.theme-toggle-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.theme-toggle {
    position: relative;
    width: 51px;
    height: 31px;
    border-radius: 31px;
    background: #c7c7cc;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle.active {
    background: #34c759;
}

.theme-toggle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

.theme-toggle.active::before {
    transform: translateX(20px);
}

.theme-toggle:active::before {
    width: 33px;
}

.theme-toggle.active:active::before {
    transform: translateX(14px);
}

/* Dark theme card adjustments */
[data-theme="dark"] .car-card {
    background: rgba(45, 45, 45, 0.7);
    border-color: var(--border);
}

[data-theme="dark"] .car-card:hover {
    background: rgba(58, 58, 58, 0.85);
}

/* Responsive */
@media (max-width: 768px) {
    .cars-list {
        grid-template-columns: 1fr;
    }

    .toolbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .user-filter-dropdown {
        position: relative;
    }

    .dropdown-menu {
        display: none;
        position: absolute;
        z-index: 1000;
        min-width: 120px;
    }

    .dropdown-menu.show {
        display: block;
    }

    .btn-primary {
        width: 100%;
    }

    .app-header {
        padding: 12px 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .app-main {
        padding: 16px;
    }
}

