/* Công cụ quản lý xe trên trang sell.html — nạp sau modern.css. */

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.sell-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Thống kê */
.seller-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.seller-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--tsa-line);
    border-radius: var(--tsa-radius);
    background: var(--tsa-surface);
    box-shadow: var(--tsa-shadow);
}

.seller-stat > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    height: 38px;
    border-radius: 999px;
    background: rgba(184, 134, 47, 0.12);
    color: var(--tsa-brand-dark);
}

.seller-stat strong {
    display: block;
    color: var(--tsa-ink);
    font-size: 20px;
    line-height: 1.1;
}

.seller-stat span {
    color: var(--tsa-muted);
    font-size: 13px;
    font-weight: 600;
}

.seller-stat.status-available > i { background: rgba(15, 118, 110, 0.12); color: #0f766e; }
.seller-stat.status-reserved > i { background: rgba(217, 119, 6, 0.14); color: #b45309; }
.seller-stat.status-sold > i { background: rgba(180, 35, 24, 0.1); color: #b42318; }
.seller-stat.status-hidden > i { background: rgba(102, 112, 133, 0.14); color: #475467; }

/* Form */
.form-mode-header {
    align-items: center !important;
}

.form-mode-header > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-mode-header span {
    text-align: left !important;
}

#sellForm.is-editing {
    border-color: var(--tsa-brand) !important;
    box-shadow: 0 0 0 3px rgba(184, 134, 47, 0.18), var(--tsa-shadow) !important;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 26px 0 14px;
    padding-top: 18px;
    border-top: 1px solid var(--tsa-line);
    color: var(--tsa-ink);
    font-size: 16px;
}

.form-section-title i {
    color: var(--tsa-brand);
}

.form-mode-header + .form-section-title {
    margin-top: 6px;
    padding-top: 0;
    border-top: 0;
}

.form-group label small {
    color: var(--tsa-muted);
    font-weight: 500;
}

.field-hint {
    color: var(--tsa-muted);
    font-size: 13px;
    font-weight: 600;
}

.field-hint.is-warning {
    color: #b45309;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--tsa-line);
    border-radius: var(--tsa-radius);
    background: #f8fafc;
    cursor: pointer;
}

.toggle-row input {
    flex: 0 0 auto;
    width: 20px;
    min-height: 20px !important;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--tsa-brand);
}

.toggle-row strong {
    display: block;
    color: var(--tsa-ink);
}

.toggle-row small {
    color: var(--tsa-muted);
}

/* Ảnh */
.upload-box {
    margin-top: 0 !important;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-box.is-dragging {
    border-color: var(--tsa-brand) !important;
    background: rgba(184, 134, 47, 0.08) !important;
}

.upload-drop {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 12px;
    border-radius: var(--tsa-radius);
    text-align: center;
    cursor: pointer;
}

.upload-drop i {
    color: var(--tsa-brand);
    font-size: 30px;
}

.upload-drop strong {
    color: var(--tsa-ink);
}

.upload-drop small {
    color: var(--tsa-muted);
    font-weight: 500;
}

.upload-drop:hover strong {
    color: var(--tsa-brand-dark);
}

.preview-grid figure.is-cover {
    outline: 2px solid var(--tsa-brand);
    outline-offset: 1px;
}

.preview-grid figcaption.muted {
    min-width: 22px;
    text-align: center;
    background: rgba(0, 0, 0, 0.55);
}

.preview-tools {
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: flex;
    gap: 4px;
}

.preview-tools button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}

.preview-tools button:hover:not(:disabled) {
    background: var(--tsa-brand);
}

.preview-tools button:disabled {
    opacity: 0.35;
    cursor: default;
}

.seller-details {
    margin-top: 22px;
    border: 1px solid var(--tsa-line);
    border-radius: var(--tsa-radius);
    padding: 0 16px;
}

.seller-details summary {
    padding: 14px 0;
    color: var(--tsa-ink);
    font-weight: 700;
    cursor: pointer;
}

.seller-details summary small {
    color: var(--tsa-muted);
    font-weight: 500;
}

.seller-details[open] {
    padding-bottom: 16px;
}

/* Kho xe */
.inventory-panel {
    position: sticky;
    top: 92px;
    max-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
}

.inventory-panel .seller-inventory {
    overflow-y: auto;
    padding-right: 4px;
    margin-right: -4px;
}

.inventory-toolbar {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.inventory-search {
    position: relative;
    display: block;
}

.inventory-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tsa-muted);
}

.inventory-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
}

.status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-tabs button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--tsa-line);
    border-radius: 999px;
    background: #fff;
    color: var(--tsa-text);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.status-tabs button span {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #eef1f5;
    color: var(--tsa-muted);
    font-size: 12px;
    text-align: center;
}

.status-tabs button.active {
    border-color: var(--tsa-ink);
    background: var(--tsa-ink);
    color: #fff;
}

.status-tabs button.active span {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.inventory-panel .inventory-card {
    border-left: 4px solid #0f766e !important;
}

.inventory-panel .inventory-card.status-reserved { border-left-color: #d97706 !important; }
.inventory-panel .inventory-card.status-sold { border-left-color: #b42318 !important; }
.inventory-panel .inventory-card.status-hidden { border-left-color: #98a2b3 !important; }

.inventory-panel .inventory-card.status-sold img,
.inventory-panel .inventory-card.status-hidden img {
    filter: grayscale(0.8);
    opacity: 0.75;
}

.inventory-panel .inventory-card.is-editing {
    box-shadow: 0 0 0 2px var(--tsa-brand) !important;
}

.inventory-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.inventory-panel .inventory-card h4 {
    color: var(--tsa-ink) !important;
}

.inventory-panel .inventory-card p {
    color: var(--tsa-price) !important;
}

.inventory-panel .inventory-card .meta {
    color: var(--tsa-muted) !important;
}

.featured-toggle {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 1px solid var(--tsa-line);
    border-radius: 999px;
    background: #fff;
    color: #98a2b3;
    cursor: pointer;
}

.featured-toggle.active {
    border-color: #f5c451;
    background: #fff8e6;
    color: #d39a07;
}

.status-select {
    display: block;
    margin-top: 8px;
}

.status-select select {
    width: 100%;
    min-height: 34px !important;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 700;
}

.inventory-panel .inventory-actions {
    justify-content: flex-start;
    gap: 6px;
}

.inventory-panel .inventory-actions a,
.inventory-panel .inventory-actions button {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.inventory-panel .inventory-actions a {
    border: 1px solid var(--tsa-line);
    background: #fff;
    color: var(--tsa-text);
}

.inventory-panel .inventory-actions .action-edit {
    border: 1px solid var(--tsa-ink);
    background: var(--tsa-ink);
    color: #fff;
}

.inventory-panel .inventory-actions .action-delete {
    border: 1px solid rgba(180, 35, 24, 0.4);
    background: #fff;
    color: #b42318;
}

@media (max-width: 1100px) {
    .seller-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .inventory-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 560px) {
    .seller-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .seller-stat {
        padding: 12px;
    }

    .seller-stat strong {
        font-size: 17px;
    }
}

/* Tự điền từ giấy tờ xe */
.doc-autofill {
    display: grid;
    gap: 12px;
    margin: 4px 0 8px;
    padding: 16px;
    border: 1px dashed var(--tsa-brand);
    border-radius: var(--tsa-radius);
    background: linear-gradient(135deg, rgba(184, 134, 47, 0.08), rgba(184, 134, 47, 0.02));
    transition: background 0.15s ease;
}

.doc-autofill.is-dragging {
    background: rgba(184, 134, 47, 0.16);
}

.doc-autofill.is-busy .doc-autofill-btn {
    pointer-events: none;
    opacity: 0.6;
}

.doc-autofill-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.doc-autofill-head > i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--tsa-brand);
    font-size: 22px;
}

.doc-autofill-head strong {
    display: block;
    color: var(--tsa-ink);
}

.doc-autofill-head small {
    color: var(--tsa-muted);
    font-weight: 500;
    line-height: 1.5;
}

.doc-autofill-btn {
    justify-self: start;
    cursor: pointer;
}

.doc-status {
    padding: 10px 12px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--tsa-line);
    color: var(--tsa-text);
    font-weight: 600;
    line-height: 1.5;
}

.doc-status.success {
    border-color: rgba(15, 118, 110, 0.35);
    background: rgba(15, 118, 110, 0.07);
    color: #0f5f59;
}

.doc-status.error {
    border-color: rgba(180, 35, 24, 0.35);
    background: rgba(180, 35, 24, 0.06);
    color: #b42318;
}

.doc-status small {
    font-weight: 500;
}

.form-group.is-autofilled input,
.form-group.is-autofilled select,
.form-group.is-autofilled textarea {
    border-color: rgba(15, 118, 110, 0.55) !important;
    background: rgba(15, 118, 110, 0.05) !important;
}

.form-group.is-autofill-guess input,
.form-group.is-autofill-guess select {
    border-color: rgba(217, 119, 6, 0.7) !important;
    background: rgba(217, 119, 6, 0.07) !important;
}

.form-group.is-autofill-guess label::after {
    content: " · kiểm tra lại";
    color: #b45309;
    font-size: 12px;
    font-weight: 700;
}

/* Hộp chọn ảnh giữ lại khi xe đã bán */
.sold-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(17, 19, 23, 0.6);
}

.sold-picker {
    width: min(640px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 22px;
    border-radius: var(--tsa-radius);
    background: var(--tsa-surface);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.sold-picker h3 {
    margin: 0 0 8px;
    color: var(--tsa-ink);
    font-size: 19px;
}

.sold-picker p {
    margin: 0 0 16px;
    color: var(--tsa-text);
    line-height: 1.55;
}

.sold-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.sold-picker-grid button {
    position: relative;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #eef1f5;
    aspect-ratio: 4 / 3;
    cursor: pointer;
}

.sold-picker-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.55;
}

.sold-picker-grid button span {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--tsa-brand);
    color: #fff;
}

.sold-picker-grid button.selected {
    border-color: var(--tsa-brand);
}

.sold-picker-grid button.selected img {
    opacity: 1;
}

.sold-picker-grid button.selected span {
    display: inline-flex;
}

.sold-picker-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
/* Kéo thả đổi thứ tự ảnh */
.preview-grid figure[data-index] {
    cursor: grab;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.preview-grid figure[data-index]:focus-visible {
    outline: 3px solid var(--tsa-brand);
    outline-offset: 2px;
}

.preview-grid.is-sorting figure[data-index] {
    cursor: grabbing;
}

.preview-grid figure.is-drag-source {
    opacity: 0.25;
    outline: 2px dashed var(--tsa-brand);
    outline-offset: -2px;
}

.preview-drag-handle {
    position: absolute;
    top: 6px;
    left: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 16px;
    cursor: grab;
    touch-action: none;
}

.preview-grid.is-sorting .preview-drag-handle {
    cursor: grabbing;
}

.preview-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 3000;
    margin: 0;
    overflow: hidden;
    border-radius: 8px;
    border: 2px solid var(--tsa-brand);
    background: #111;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    opacity: 0.92;
}

.preview-ghost img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-ghost button,
.preview-ghost .preview-tools {
    display: none;
}

body.is-image-sorting {
    cursor: grabbing;
    user-select: none;
    -webkit-user-select: none;
}