/* === SALES.CSS ===
   Стили для страницы продаж (sales.html)
*/

/* Контейнер таблицы */
.sales-table-container {
    overflow-x: auto;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid #e5e7eb;
}

.sales-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.sales-table thead {
    background: #f9fafb;
}

.sales-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sales-table td {
    padding: 10px 10px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    color: #4b5563;
}

/* Фиксированные ширины узких колонок:
   1=№, 2=Авто, 3=OEM, 4=Название, 5=Бренд, 6=Состояние,
   7=Цена, 8=Кол-во, 9=Дата, 10=Источник, 11=Продал,
   12=Покупатель, 13=Оплата, 14=Статус, 15=Фото, 16=Комментарий, 17=Действия */
.sales-table th:nth-child(1),
.sales-table td:nth-child(1) { width: 48px; }

.sales-table th:nth-child(8),
.sales-table td:nth-child(8) { width: 52px; text-align: center; }

.sales-table th:nth-child(9),
.sales-table td:nth-child(9) { width: 140px; white-space: nowrap; }

.sales-table th:nth-child(10),
.sales-table td:nth-child(10) { width: 88px; }

.sales-table th:nth-child(12),
.sales-table td:nth-child(12) { width: 100px; }

.sales-table th:nth-child(13),
.sales-table td:nth-child(13) { width: 110px; }

.sales-table th:nth-child(14),
.sales-table td:nth-child(14) { width: 120px; }

.sales-table th:nth-child(15),
.sales-table td:nth-child(15) { width: 64px; }

.sales-table th:nth-child(17),
.sales-table td:nth-child(17) { width: 94px; }

.comment-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #6b7280;
    font-size: 12px;
}

.sales-table tbody tr {
    transition: background 0.15s;
}

.sales-table tbody tr:hover {
    background: #f9fafb;
}

.sales-table tbody tr:last-child td {
    border-bottom: none;
}

/* Табличное фото */
.sales-table .table-photo {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    transition: border-color 0.2s;
}

.sales-table .table-photo:hover {
    border-color: #3b82f6;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.pagination span {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Бейджи источников продажи */
.source-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.source-avito {
    background: #fff3e0;
    color: #e65100;
}

.source-drom {
    background: #e3f2fd;
    color: #1565c0;
}

.source-site {
    background: #f3e5f5;
    color: #6a1b9a;
}

.source-unknown {
    background: #f3f4f6;
    color: #9ca3af;
}

/* === Строка фильтров === */
.sales-filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.sales-search {
    flex: 1;
    min-width: 180px;
    max-width: 380px;
}

.sales-date-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 5px 12px;
    flex-shrink: 0;
}

.date-filter-sep {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
    white-space: nowrap;
}

.date-filter-input {
    border: none;
    outline: none;
    font-size: 13px;
    color: #374151;
    width: 130px;
    background: transparent;
    padding: 2px 0;
    cursor: pointer;
}

/* === Блок статистики продаж === */
.sales-stats {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
    background: #fff;
}

/* Горизонтальная полоса KPI */
.sales-kpis {
    display: flex;
    align-items: stretch;
}

.stats-kpi-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 14px 18px;
    gap: 3px;
    min-width: 0;
}

.stats-kpi-total {
    background: #f8fafc;
    flex: 0 0 auto;
    min-width: 160px;
}

.stats-kpi-sep {
    width: 1px;
    background: #e2e8f0;
    flex-shrink: 0;
    align-self: stretch;
}

.stats-kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    margin-bottom: 2px;
}

.stats-kpi-total .stats-kpi-label {
    font-size: 10px;
    color: #6b7280;
}

.stats-kpi-count {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-kpi-total .stats-kpi-count {
    font-size: 18px;
}

.stats-kpi-revenue {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-kpi-revenue--total {
    font-size: 14px;
    font-weight: 600;
    color: #15803d;
}

/* Разбивка по месяцам */
.stats-months-details {
    border-top: 1px solid #e2e8f0;
    padding: 0;
}

.stats-months-details summary {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: color 0.15s;
}

.stats-months-details summary:hover { color: #374151; }

.stats-months-details summary::before {
    content: '▶';
    font-size: 8px;
    color: #9ca3af;
    transition: transform 0.15s;
    display: inline-block;
}

.stats-months-details[open] summary::before { transform: rotate(90deg); }

.stats-months-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-months-table th {
    text-align: left;
    padding: 6px 18px;
    color: #9ca3af;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.stats-months-table td {
    padding: 8px 18px;
    color: #374151;
    border-bottom: 1px solid #f1f5f9;
}

.stats-month-revenue {
    font-weight: 600;
    color: #15803d !important;
}

.stats-months-table tbody tr:last-child td { border-bottom: none; }
.stats-months-table tbody tr:hover { background: #f8fafc; }

.stats-months-empty {
    padding: 10px 18px 14px;
    color: #9ca3af;
    font-size: 13px;
    margin: 0;
}

/* Кнопка возврата запчасти */
.btn-return {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-return:hover {
    background: #ffedd5;
    border-color: #fdba74;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
}

/* Бейджи статуса сделки */
.deal-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.deal-reserved {
    background: #eff6ff;
    color: #1d4ed8;
}

.deal-partial {
    background: #fff7ed;
    color: #c2410c;
}

.deal-paid {
    background: #f0fdf4;
    color: #15803d;
}

.deal-ready {
    background: #fdf4ff;
    color: #7e22ce;
}

.deal-delivered {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}
