/**
 * Стабильный layout кабинета — без «дёрганья» при смене вкладок.
 */

body.dashboard-page .dashboard-content {
    min-height: calc(100vh - 11rem);
    flex: 1;
}

body.dashboard-page .sidebar {
    align-self: flex-start;
    width: 280px;
    flex: 0 0 280px;
    min-height: 12rem;
}

body.dashboard-page .sidebar-nav .nav-item {
    min-height: 2.75rem;
    box-sizing: border-box;
}

body.dashboard-page .nav-item .badge,
body.dashboard-page .nav-notifications-badge {
    min-width: 1.35rem;
    text-align: center;
    flex-shrink: 0;
}

body.modal-open {
    overflow: hidden;
}

body.modal-open .header,
body.modal-open .sidebar {
    padding-right: 0 !important;
}

body.dashboard-page .v2-reveal,
body.dashboard-page .v2-reveal-delay-1,
body.dashboard-page .v2-reveal-delay-2,
body.dashboard-page .v2-reveal-delay-3,
body.dashboard-page .v2-reveal-delay-4 {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
}

/* Фиксируем высоту строк имени и email в сайдбаре — не «прыгают» при подмене значений. */
body.dashboard-page .sidebar .user-name {
    min-height: 1.2em;
    line-height: 1.2;
}

body.dashboard-page .sidebar .user-email {
    min-height: 1em;
    line-height: 1;
}

/* Заголовок страницы: фиксируем высоту области, чтобы исключить вертикальный «скачок»
   при поздней подгрузке счётчика/перевода. */
body.dashboard-page .dashboard-page-header > div:first-child {
    min-height: 3.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.dashboard-page .dashboard-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.25rem;
    min-height: 3.25rem;
}

body.dashboard-page .dashboard-page-header h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.2;
    /* Flex-контейнер: и текст заголовка, и счётчик становятся flex-айтемами
       и идеально центрируются по высоте через align-items: center. */
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

/* Счётчик-таблетка рядом с заголовком (гараж/дневник/уведомления и т.п.). */
body.dashboard-page .page-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Высота = высота строки заголовка → align-items: center даст идеальное
       визуальное совпадение центра счётчика и оптического центра текста. */
    height: 1.2em;
    min-width: 1.6em;
    padding: 0 0.55em;
    box-sizing: border-box;
    font-size: 0.7em;
    font-weight: 700;
    line-height: 1;
    /* Лёгкое смещение вниз: визуально опускаем «капсулу», т.к. оптическая ось
       цифр в заголовке выше центра счётчика. */
    transform: translateY(0.18em);
    color: var(--primary-700);
    background: var(--primary-50);
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 999px;
    letter-spacing: 0.02em;
    animation: pageCounterPop 220ms ease both;
}

body.dashboard-page .page-counter[hidden] {
    display: none !important;
}

@keyframes pageCounterPop {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

/* Стили выпадающего меню профиля переехали в css/main.css (.account-menu) */

/* Гараж */
.garage-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.garage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.vehicle-card {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.vehicle-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.vehicle-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.vehicle-card-title {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--gray-900);
}

.vehicle-card-plate {
    font-size: 0.875rem;
    color: var(--primary-600);
    font-weight: 600;
    background: var(--primary-50);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.vehicle-card-meta {
    font-size: 0.8125rem;
    color: var(--gray-500);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.vehicle-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.garage-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-xl);
    border: 1px dashed var(--gray-300);
}

.garage-empty i {
    font-size: 3rem;
    color: var(--primary-400);
    margin-bottom: 1rem;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

.page-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    color: var(--gray-500);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.garage-header {
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.garage-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn.btn-icon {
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.btn.btn-icon i { font-size: 1rem; }

.garage-empty[hidden] {
    display: none !important;
}

.garage-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.garage-empty-icon {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.garage-empty h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.garage-empty-text {
    margin: 0 0 1.25rem;
    color: var(--gray-500);
    max-width: 22rem;
    line-height: 1.5;
}

.vehicle-card-top {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.vehicle-card-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.vehicle-card-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vehicle-card-head {
    flex: 1;
    min-width: 0;
}

.vehicle-card-title {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vehicle-card-plate {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    background: var(--primary-50);
    color: var(--primary-700);
}

.vehicle-card-stats {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.vehicle-card-stats li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.vehicle-card-stats li span {
    color: var(--gray-500);
    flex-shrink: 0;
}

.vehicle-card-stats li strong {
    color: var(--gray-800);
    text-align: right;
    word-break: break-all;
}

.vehicle-card-stats .mono {
    font-family: ui-monospace, monospace;
    font-size: 0.78rem;
}

.vehicle-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.vehicle-card-actions .btn-primary {
    flex: 1;
    min-width: 7rem;
}

.btn-danger-outline:hover {
    border-color: var(--error);
    color: var(--error);
}

.nav-notifications-badge[hidden] {
    display: none !important;
}

.nav-item .badge {
    min-width: 1.25rem;
    text-align: center;
}

#vehicle-modal.modal.active {
    z-index: 2100;
}

/* ============ Карточка авто (новая) ============ */
.vehicle-modal .modal-content.vehicle-modal-content {
    max-width: 720px;
    width: min(720px, 96vw);
    padding: 1.5rem 1.5rem 1.75rem;
    border-radius: 1.25rem;
    background:
        radial-gradient(120% 60% at 0% 0%, rgba(59, 130, 246, 0.07), transparent 60%),
        radial-gradient(120% 60% at 100% 0%, rgba(168, 85, 247, 0.06), transparent 60%),
        #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18), 0 8px 18px rgba(15, 23, 42, 0.08);
    animation: vehicleModalIn 220ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Скролл внутри формы — чтобы поп-ап цвета не обрезался overflow модалки. */
.vehicle-modal .vehicle-form {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-right: 0.15rem;
}

@keyframes vehicleModalIn {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.vehicle-modal-header {
    margin-bottom: 1rem;
}

.vehicle-modal-content .modal-title {
    margin: 0 0 0.25rem;
    font-family: var(--font-heading);
    font-size: 1.4rem;
}

.vehicle-modal-content .modal-subtitle {
    margin: 0;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.vehicle-form-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.85);
    padding: 1rem 1.1rem 0.75rem;
    margin-bottom: 0.85rem;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
    animation: sectionIn 280ms ease both;
}

.vehicle-form-section:hover {
    border-color: var(--primary-200, #c7d2fe);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.vehicle-form-section:nth-child(2) { animation-delay: 30ms; }
.vehicle-form-section:nth-child(3) { animation-delay: 60ms; }
.vehicle-form-section:nth-child(4) { animation-delay: 90ms; }
.vehicle-form-section:nth-child(5) { animation-delay: 120ms; }
.vehicle-form-section:nth-child(6) { animation-delay: 150ms; }
.vehicle-form-section:nth-child(7) { animation-delay: 180ms; }

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

.vehicle-section-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.85rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
}

.vehicle-section-title i {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 0.5rem;
    background: var(--primary-50);
    color: var(--primary-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.vehicle-modal-content .form-row-2 {
    gap: 0.75rem;
}

.vehicle-modal-content .form-group {
    margin-bottom: 0.75rem;
}

.vehicle-modal-content label .req {
    color: var(--error, #ef4444);
    margin-left: 0.15rem;
}

.vehicle-modal-content textarea {
    width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    font: inherit;
    color: var(--gray-800);
    background: #fff;
    resize: vertical;
    min-height: 5rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.vehicle-modal-content textarea:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* ============ Чипы (трансмиссия / топливо) ============ */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    appearance: none;
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--gray-700);
    border-radius: 999px;
    padding: 0.5rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: transform 140ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.chip i {
    color: var(--gray-400);
    transition: color 160ms ease;
}

.chip:hover {
    border-color: var(--primary-300, #93c5fd);
    color: var(--primary-700);
    transform: translateY(-1px);
}

.chip:hover i {
    color: var(--primary-500);
}

.chip-active {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 14px rgba(59, 130, 246, 0.25);
}

.chip-active i {
    color: #fff;
}

.chip-group-compact .chip {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

#vehicle-fuel-grade-group {
    animation: gradeIn 220ms ease both;
}

@keyframes gradeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ Цвет авто ============ */
.color-picker {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
    gap: 0.5rem;
}

.color-swatch {
    appearance: none;
    border: 2px solid rgba(15, 23, 42, 0.08);
    background: var(--swatch);
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.color-swatch:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}

.color-swatch-tick {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 140ms ease, transform 160ms ease;
}

.color-swatch-active {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.color-swatch-active .color-swatch-tick {
    opacity: 1;
    transform: scale(1);
}

.color-custom {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.color-custom-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-700);
    cursor: pointer;
}

.color-custom-preview {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--swatch);
    border: 2px solid rgba(15, 23, 42, 0.1);
    box-shadow: inset 0 0 0 2px #fff;
}

#vehicle-color-custom {
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: auto;
    position: absolute;
}

.color-hex-input {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.8rem;
    font: inherit;
    width: 8rem;
    background: #fff;
    color: var(--gray-800);
    text-transform: uppercase;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.color-hex-input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

/* ============ Сабмит ============ */
.vehicle-submit-btn {
    margin-top: 0.5rem;
    height: 3rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.18);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.vehicle-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(59, 130, 246, 0.25);
}

.vehicle-submit-btn.btn-loading {
    pointer-events: none;
    opacity: 0.75;
}

/* ============ Цветовая точка в карточке гаража ============ */
.vehicle-card-color {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--swatch);
    display: inline-block;
    margin-right: 0.4rem;
    border: 2px solid rgba(15, 23, 42, 0.1);
    vertical-align: middle;
}

.vehicle-card-plate-empty {
    background: var(--gray-100);
    color: var(--gray-500);
}

.diary-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

.diary-panel {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
}

.panel-title {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.diary-entries {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.diary-entry {
    position: relative;
    padding: 1rem 2.5rem 1rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
}

.diary-entry-head {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.diary-entry-type {
    font-weight: 600;
    color: var(--primary-600);
}

.diary-entry-title {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.diary-entry-body {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--gray-700);
    white-space: pre-wrap;
}

.diary-entry-mileage {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.diary-entry .btn-ghost {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: none;
    background: transparent;
    color: var(--gray-400);
}

.diary-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--gray-500);
}

body.dashboard-page .sidebar-nav .nav-item {
    min-height: 2.75rem;
}

@media (max-width: 900px) {
    .diary-layout {
        grid-template-columns: 1fr;
    }
}
