/* Стили админки каталога. Отдельный файл, потому что селекторы общие
   (body, *, h1, .container) и в общий style.css их выносить нельзя. */

body.login { background: #0f0f0f; font-family: 'Inter', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
            .login-form { background: rgba(255,255,255,0.05); padding: 2rem; border-radius: 16px; width: 300px; }
            .login-form h2 { color: white; margin-bottom: 1rem; }
            .login-error { color: #f87171; font-size: 0.9rem; margin: -0.35rem 0 0.9rem; }
.login-form input { width: 100%; padding: 12px; margin-bottom: 1rem; background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 8px; color: white; }
            .login-form button { width: 100%; padding: 12px; background: #f59e0b; border: none; border-radius: 8px; color: white; font-weight: bold; cursor: pointer; }
            .options-grid {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
                gap: 0.5rem;
                background: rgba(255,255,255,0.03);
                padding: 1rem;
                border-radius: 8px;
            }
            .option-item {
                display: flex;
                align-items: center;
                gap: 0.5rem;
                font-size: 0.85rem;
                color: #d1d5db;
                cursor: pointer;
            }
            .option-item input {
                width: auto;
                margin: 0;
            }
            .full-width {
               
                grid-column: 1 / -1;
            }

* { margin: 0; padding: 0; box-sizing: border-box; }
        body { background: #0f0f0f; font-family: 'Inter', sans-serif; color: #d1d5db; padding: 2rem; }
        .container { max-width: 1400px; margin: 0 auto; }
        h1 { color: white; margin-bottom: 1rem; }
        .admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
        .btn-add { background: #4ade80; color: black; padding: 10px 20px; border-radius: 8px; text-decoration: none; font-weight: bold; }
        .btn-add:hover { background: #22c55e; }
        .form-card { background: rgba(255,255,255,0.05); border-radius: 16px; padding: 1.5rem; margin-bottom: 2rem; }
        .form-card h2 { color: #f59e0b; margin-bottom: 1rem; font-size: 1.2rem; }
        .form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
        .form-group { display: flex; flex-direction: column; gap: 0.5rem; }
        .form-group label { font-size: 0.85rem; color: #9ca3af; }
        .form-group input, .form-group select, .form-group textarea { background: #2a2a2a; border: 1px solid #3a3a3a; padding: 8px 12px; border-radius: 8px; color: white; }
        .form-group input:focus, .form-group select:focus { outline: none; border-color: #f59e0b; }
        .form-actions { margin-top: 1rem; display: flex; gap: 1rem; }
        .btn-save { background: #f59e0b; color: black; padding: 10px 20px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; }
        .btn-cancel { background: #374151; color: white; padding: 10px 20px; border: none; border-radius: 8px; text-decoration: none; cursor: pointer; }
        
        /* Фильтр */
        .filter-bar {
            background: rgba(255,255,255,0.05);
            border-radius: 16px;
            padding: 1rem;
            margin-bottom: 1.5rem;
            display: flex;
            flex-wrap: wrap;
            align-items: flex-end;
            gap: 1rem;
        }
        .filter-group {
            display: flex;
            flex-direction: column;
            gap: 0.3rem;
        }
        .filter-group label {
            font-size: 0.7rem;
            color: #9ca3af;
        }
        .filter-group select, .filter-group input {
            background: #2a2a2a;
            border: 1px solid #3a3a3a;
            padding: 6px 10px;
            border-radius: 6px;
            color: white;
            min-width: 150px;
        }
        .filter-btn {
            background: #f59e0b;
            color: black;
            border: none;
            padding: 6px 16px;
            border-radius: 6px;
            font-weight: bold;
            cursor: pointer;
            height: 32px;
        }
        .filter-btn.reset {
            background: #374151;
            color: white;
        }
        
        .cars-table { width: 100%; overflow-x: auto; }
        .cars-table table { width: 100%; border-collapse: collapse; }
        .cars-table th, .cars-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; }
        .cars-table th { color: #f59e0b; }
        .btn-edit, .btn-delete { padding: 4px 10px; border-radius: 6px; text-decoration: none; font-size: 0.75rem; margin-right: 6px; }
        .btn-edit { background: rgba(245,158,11,0.2); color: #f59e0b; }
        .btn-delete { background: rgba(248,113,113,0.2); color: #f87171; border: none; cursor: pointer; }
        .car-image-preview { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
        .small-note { font-size: 0.7rem; color: #6b7280; margin-top: 4px; }
        .model-select {
            min-width: 150px;
        }
        .options-block > summary {
            cursor: pointer;
            font-weight: 600;
            padding: 0.75rem 1rem;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 8px;
            list-style: none;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            transition: border-color 0.2s;
        }
        .options-block > summary::-webkit-details-marker {
            display: none;
        }
        .options-block > summary::before {
            content: '\25B8';
            color: #f59e0b;
            transition: transform 0.15s;
        }
        .options-block[open] > summary::before {
            transform: rotate(90deg);
        }
        .options-block > summary:hover {
            border-color: rgba(245,158,11,0.45);
        }
        .options-hint {
            color: #6b7280;
            font-weight: 400;
            font-size: 0.85rem;
        }
        .options-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1rem;
            background: rgba(255,255,255,0.03);
            padding: 1rem;
            border-radius: 8px;
            margin-top: 0.5rem;
        }
        .options-group {
            break-inside: avoid;
        }
        .options-group-title {
            font-weight: 600;
            color: #f59e0b;
            margin-bottom: 0.5rem;
            padding-bottom: 0.25rem;
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }
        .option-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.85rem;
            color: #d1d5db;
            cursor: pointer;
            padding: 0.2rem 0;
        }
        .option-item:hover {
            color: #f59e0b;
        }
        .option-item input {
            width: auto;
            margin: 0;
        }
        .full-width {
             margin-top: 20px;
            grid-column: 1 / -1;
        }

/* Стили для select региона, страны, города */
.form-group select {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    padding: 8px 12px;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: #f59e0b;
}

/* Для лучшего отображения опций */
.form-group select option {
    background: #2a2a2a;
    color: white;
}
/* Стили для строки с тремя полями (Страна, Регион, Город) */
.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
}

/* мелкие утилиты админки вместо inline-стилей */
.adm-muted { color: #9ca3af; }
.adm-mb { margin-bottom: 1rem; }
.adm-inline { display: inline; }

/* статусы машин: цвет задаётся классом, значения совпадают с $status_labels */
.adm-status { white-space: nowrap; }
.adm-status-active { color: #22c55e; }
.adm-status-sold { color: #f59e0b; }
.adm-status-paused, .adm-status-removed, .adm-status-deleted { color: #9ca3af; }

/* панель: обычный поток, без центрирования страницы входа */
body.panel { display: block; height: auto; min-height: 100vh; }/* --- переключатель «Авто в продаже / Выкупленное авто» --- */
.add-mode{display:flex;gap:.5rem;flex-wrap:wrap;margin:0 0 1.1rem}
.add-mode-opt{display:inline-flex;align-items:center;gap:.5rem;padding:.55rem .9rem;border:1px solid rgba(255,255,255,.18);border-radius:10px;cursor:pointer;font-size:.92rem;color:#cbd5e1;background:rgba(255,255,255,.04)}
.add-mode-opt:has(input:checked){border-color:#f59e0b;color:#fff;background:rgba(245,158,11,.12)}
.add-mode-opt input{accent-color:#f59e0b}
.add-mode-hint{color:#9ca3af;font-size:.85rem;margin:.2rem 0 1rem}
.bought-ok{color:#34d399;font-size:.9rem;margin:.2rem 0 1rem}
.bought-error{color:#f87171;font-size:.9rem;margin:.2rem 0 1rem}
.bought-list-title{margin:1.6rem 0 .7rem;font-size:1rem;color:#fff}
.bought-list{width:100%;border-collapse:collapse;font-size:.9rem}
.bought-list th{text-align:left;color:#9ca3af;font-weight:500;padding:.45rem .5rem;border-bottom:1px solid rgba(255,255,255,.12);white-space:nowrap}
.bought-list td{padding:.45rem .5rem;border-bottom:1px solid rgba(255,255,255,.06);vertical-align:middle}
.bought-thumb{width:64px;height:44px;object-fit:cover;border-radius:6px;display:block}
.bought-delete{margin:0}
.btn-delete{background:transparent;border:1px solid rgba(248,113,113,.5);color:#f87171;border-radius:8px;padding:.3rem .6rem;font-size:.82rem;cursor:pointer}
.btn-delete:hover{background:rgba(248,113,113,.12)}
/* --- мобильная админка: поля в один столбец, крупные кнопки --- */
.photo-preview{margin-top:.6rem;width:100%;max-width:260px;border-radius:10px;display:block}

@media (max-width: 640px) {
    .form-card .form-grid{grid-template-columns:1fr;gap:.7rem}
    .form-group label{font-size:.82rem}
    .form-group input,.form-group select,.form-group textarea{min-height:46px;font-size:16px;padding:10px 12px}
    .form-actions{flex-direction:column}
    .form-actions .btn-save,.form-actions .btn-cancel{width:100%;min-height:48px;font-size:1rem}
    .add-mode{gap:.4rem}
    .add-mode-opt{flex:1 1 calc(50% - .2rem);justify-content:center;min-height:44px}
    .add-mode-hint{font-size:.8rem}
    .bought-list-title{font-size:.95rem}
    .bought-list{display:block;overflow-x:auto;white-space:nowrap}
    .bought-list th,.bought-list td{padding:.4rem .45rem}
    .bought-delete .btn-delete{min-height:40px;padding:.4rem .7rem}
    .photo-preview{max-width:100%}
}
@media (max-width: 640px) {
    body.panel{overflow-x:hidden}
    .form-card,.filter-bar,.panel-header{max-width:100%;overflow:hidden}
    .form-group input,.form-group select,.form-group textarea{width:100%;box-sizing:border-box}
    body.panel table:not(.bought-list){display:block;width:100%;max-width:100%;overflow-x:auto;white-space:nowrap}
    body.panel table:not(.bought-list) th,body.panel table:not(.bought-list) td{padding:.4rem .45rem}
    .bought-list{display:table;width:100%;max-width:100%;white-space:normal;font-size:.78rem}
    .bought-list th,.bought-list td{padding:.3rem .25rem}
    .bought-thumb{width:44px;height:30px}
    .bought-delete .btn-delete{min-height:34px;padding:.3rem .45rem;font-size:.75rem}
    .bought-list th:nth-child(3),.bought-list td:nth-child(3){display:none}
    .bought-list th:nth-child(4),.bought-list td:nth-child(4){display:none}
    .bought-list td:nth-child(5),.bought-list td:nth-child(6){white-space:nowrap}
    .bought-list th:nth-child(1),.bought-list td:nth-child(1){display:none}
    .bought-list td:nth-child(5){white-space:nowrap;font-weight:600}
    .bought-list td:nth-child(7){text-align:right}
    .bought-list td:nth-child(2){max-width:9rem;overflow:hidden;text-overflow:ellipsis}
    .bought-list th:nth-child(6),.bought-list td:nth-child(6){display:none}
    .bought-list td:nth-child(2){max-width:6.5rem}
    .panel-header h1{font-size:1.1rem}
    .panel-header{flex-wrap:wrap;gap:.5rem}
}
/* --- телефон: убираем внешние отступы, таблица во всю ширину --- */
@media (max-width: 640px) {
    body.panel{padding:0}
    .container{max-width:100%;padding:0}
    .admin-header{padding:.9rem .9rem .5rem;margin-bottom:.5rem}
    .form-card,.filter-bar{border-radius:0;padding:.9rem;margin-bottom:.9rem}
    .cars-table{padding:0;margin:0}
    .cars-table h2{padding:0 .9rem;margin-bottom:.6rem}
    .cars-table th,.cars-table td{padding:.45rem .5rem;font-size:.8rem}
    .filter-group{flex:1 1 45%}
}
/* на телефоне в таблице каталога — только главное: авто, год, цена, действия */
@media (max-width: 640px) {
    .cars-table th:nth-child(1),.cars-table td:nth-child(1),
    .cars-table th:nth-child(2),.cars-table td:nth-child(2),
    .cars-table th:nth-child(4),.cars-table td:nth-child(4),
    .cars-table th:nth-child(7),.cars-table td:nth-child(7),
    .cars-table th:nth-child(8),.cars-table td:nth-child(8),
    .cars-table th:nth-child(9),.cars-table td:nth-child(9),
    .cars-table th:nth-child(10),.cars-table td:nth-child(10),
    .cars-table th:nth-child(11),.cars-table td:nth-child(11){display:none}
    body.panel .cars-table table{white-space:normal}
    body.panel .cars-table td:nth-child(3){max-width:8.5rem;white-space:normal;line-height:1.25}
    .cars-table th,.cars-table td{padding:.5rem .55rem}
}
/* чекбоксы доп. опций: не растягиваются на всю ширину и не ломают сетку */
.option-item input[type="checkbox"]{
    width:20px;height:20px;min-width:20px;min-height:20px;flex:0 0 20px;
    margin:0;padding:0;accent-color:#f59e0b;border-radius:4px;cursor:pointer
}
.option-item{align-items:flex-start}
.option-item span,.option-item{line-height:1.3}

@media (max-width:640px){
    .options-grid{grid-template-columns:1fr;padding:.75rem;gap:.35rem}
    .options-group-title{font-size:.9rem;margin-bottom:.4rem}
    .option-item{font-size:.9rem;gap:.6rem;padding:.3rem 0}
    .option-item input[type="checkbox"]{width:22px;height:22px;min-width:22px;min-height:22px;flex:0 0 22px}
}
/* чекбоксы и радио внутри полей формы: обычный размер, подпись рядом */
.form-group label:has(> input[type="checkbox"]),
.form-group label:has(> input[type="radio"]){
    display:flex;align-items:center;gap:.55rem;min-height:44px;cursor:pointer;font-size:.92rem
}
.form-group input[type="checkbox"],
.form-group input[type="radio"]{
    width:20px;height:20px;min-width:20px;min-height:20px;flex:0 0 20px;
    margin:0;padding:0;accent-color:#f59e0b;cursor:pointer
}
@media (max-width:640px){
    .form-group input[type="checkbox"],
    .form-group input[type="radio"]{width:22px;height:22px;min-width:22px;min-height:22px;flex:0 0 22px}
}
/* единый вид чекбоксов и радио на тёмном фоне (не зависит от системы) */
.form-group input[type="checkbox"],
.form-group input[type="radio"],
.option-item input[type="checkbox"]{
    appearance:none;-webkit-appearance:none;
    width:22px;height:22px;min-width:22px;min-height:22px;flex:0 0 22px;
    margin:0;padding:0;border:1.5px solid #52525b;border-radius:5px;
    background:#1c1c1e;position:relative;cursor:pointer;transition:background .15s,border-color .15s
}
.form-group input[type="radio"]{border-radius:50%}
.form-group input[type="checkbox"]:checked,
.form-group input[type="radio"]:checked,
.option-item input[type="checkbox"]:checked{background:#f59e0b;border-color:#f59e0b}
.form-group input[type="checkbox"]:checked::after,
.option-item input[type="checkbox"]:checked::after{
    content:"";position:absolute;left:7px;top:3px;width:6px;height:11px;
    border:solid #111;border-width:0 2.5px 2.5px 0;transform:rotate(45deg)
}
.form-group input[type="radio"]:checked::after{
    content:"";position:absolute;left:5px;top:5px;width:8px;height:8px;border-radius:50%;background:#111
}
.form-group input[type="checkbox"]:hover,
.form-group input[type="radio"]:hover,
.option-item input[type="checkbox"]:hover{border-color:#f59e0b}
.form-group input[type="checkbox"]:focus-visible,
.form-group input[type="radio"]:focus-visible,
.option-item input[type="checkbox"]:focus-visible{outline:2px solid #f59e0b;outline-offset:2px}
/* --- город выкупа: выпадающий список с областями (свернуты по умолчанию) --- */
.city-picker{position:relative}
.city-picker-toggle{
    width:100%;display:flex;align-items:center;justify-content:space-between;gap:.5rem;
    background:#2a2a2a;border:1px solid #3a3a3a;border-radius:8px;color:#fff;
    padding:10px 12px;font-size:.95rem;cursor:pointer;text-align:left
}
.city-picker-toggle:hover{border-color:#f59e0b}
.city-picker-arrow{color:#9ca3af;font-size:.8rem;transition:transform .15s}
.city-picker-toggle[aria-expanded="true"] .city-picker-arrow{transform:rotate(180deg)}
.city-picker-panel{
    position:absolute;z-index:40;left:0;right:0;top:calc(100% + 6px);
    background:#1f1f1f;border:1px solid #3a3a3a;border-radius:10px;
    max-height:min(60vh,420px);overflow-y:auto;box-shadow:0 16px 40px rgba(0,0,0,.45)
}
.city-group + .city-group{border-top:1px solid rgba(255,255,255,.07)}
.city-group-toggle{
    width:100%;display:flex;align-items:center;justify-content:space-between;gap:.5rem;
    background:transparent;border:0;color:#e5e7eb;padding:11px 14px;font-size:.92rem;
    cursor:pointer;text-align:left
}
.city-group-toggle:hover{background:rgba(245,158,11,.08);color:#f59e0b}
.city-group-toggle[aria-expanded="true"]{color:#f59e0b}
.city-group-count{color:#6b7280;font-size:.78rem}
.city-group-list{display:block;padding:0 0 6px}
.city-option{
    display:block;width:100%;text-align:left;background:transparent;border:0;
    color:#cbd5e1;padding:9px 14px 9px 30px;font-size:.92rem;cursor:pointer
}
.city-option:hover{background:rgba(245,158,11,.12);color:#f59e0b}
.city-option.is-selected{color:#f59e0b;font-weight:600}
.city-native{display:none}
@media (max-width:640px){
    .city-picker-toggle{min-height:46px;font-size:16px}
    .city-group-toggle{min-height:46px;font-size:.95rem}
    .city-option{min-height:44px;font-size:.95rem}
    .city-picker-panel{max-height:65vh}
}
/* hidden должен побеждать display:block у списков городов */
.city-picker-panel[hidden],
.city-group-list[hidden]{display:none}
.city-picker-search{position:sticky;top:0;z-index:1;padding:8px;background:#1f1f1f;border-bottom:1px solid rgba(255,255,255,.08)}
.city-picker-search input{
    width:100%;box-sizing:border-box;background:#2a2a2a;border:1px solid #3a3a3a;border-radius:8px;
    color:#fff;padding:9px 12px;font-size:.92rem
}
.city-picker-search input:focus{outline:none;border-color:#f59e0b}
@media (max-width:640px){.city-picker-search input{min-height:44px;font-size:16px}}
/* скрытые опции поиска не должны показываться из-за display:block */
.city-option[hidden]{display:none}
