/* Sidebar - левое боковое меню навигации */

.left-sidebar {
    width: 280px;
    min-width: 280px;
    background: #f8f8f8;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.left-sidebar.collapsed {
    width: 40px;
    min-width: 40px;
}

.left-sidebar.collapsed .sidebar-content,
.left-sidebar.collapsed .sidebar-header span,
.left-sidebar.collapsed .report-period-select,
.left-sidebar.collapsed .validate-all-btn {
    display: none;
}

.sidebar-header {
    padding: 4px 8px;
    background: #e0e0e0;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    font-size: 11px;
    font-weight: 600;
}

.report-period-select {
    flex: 1;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 11px;
    height: 22px;
    padding: 0 4px;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    font-weight: 600;
}

.validate-all-btn {
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 3px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.validate-all-btn:hover {
    background: #f57c00;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.sidebar-section:has(.section-content.collapsed) {
    flex: 0 0 auto;
}

.sidebar-section .section-header {
    padding: 5px 8px;
    background: #e8e8e8;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 11px;
    user-select: none;
}

.sidebar-section .section-header:hover {
    background: #e0e0e0;
}

.sidebar-section .section-header .section-counter {
    font-size: 9px;
    color: #666;
    font-weight: 600;
    margin-left: auto;
}

.sidebar-section .section-header .arrow {
    transition: transform 0.15s;
    font-size: 9px;
}

.sidebar-section .section-header.collapsed .arrow {
    transform: rotate(-90deg);
}

.sidebar-section .section-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.sidebar-section .section-content.collapsed {
    flex: 0;
    overflow: hidden;
    max-height: 0;
}

/* Скроллбары для sidebar */
.sidebar-content::-webkit-scrollbar,
.users-list-wrapper::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track,
.users-list-wrapper::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.sidebar-content::-webkit-scrollbar-thumb,
.users-list-wrapper::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.users-list-wrapper::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Правый sidebar */
.right-sidebar {
    width: 320px;
    min-width: 320px;
    background: #f8f8f8;
    border-left: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.right-sidebar.collapsed {
    width: 40px;
    min-width: 40px;
}

.right-sidebar.collapsed .sidebar-content,
.right-sidebar.collapsed .sidebar-header span {
    display: none;
}

/* Панель ошибок в правом сайдбаре */
.errors-panel {
    background: #1e1e1e;
    color: #cccccc;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 9px;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    line-height: 1.3;
}

.errors-panel::-webkit-scrollbar {
    width: 4px;
}

.errors-panel::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.errors-panel::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 2px;
}

.errors-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Панель информации о креативе */
.creative-info-panel {
    background: #fafafa;
    padding: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    font-size: 10px;
    line-height: 1.3;
}

.creative-info-panel::-webkit-scrollbar {
    width: 4px;
}

.creative-info-panel::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.creative-info-panel::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 2px;
}

.creative-info-panel::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Ссылки в панели креатива */
.creative-info-panel a {
    color: #1976d2;
    text-decoration: none;
    word-break: break-all;
}

.creative-info-panel a:hover {
    text-decoration: underline;
    color: #1565c0;
    background: rgba(25, 118, 210, 0.05);
}

/* Форматированный текст в панели креатива */
.creative-info-panel pre,
.creative-info-panel #eridTextContent {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 10px;
    line-height: 1.6;
    color: #222;
    margin: 0;
    padding: 0;
}

.creative-info-panel strong {
    font-weight: 700;
    color: #000;
}

/* Кнопка в панели креатива */
.creative-info-panel button {
    transition: all 0.15s;
}

.creative-info-panel button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.creative-info-panel button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Сворачиваемый текст креатива */
.creative-info-panel #creativeTextBlock {
    transition: max-height 0.3s ease, background 0.2s;
}

/* Кликабельный ERID */
.creative-info-panel [onclick^="copyEridValue"] {
    transition: color 0.15s;
}

.creative-info-panel [onclick^="copyEridValue"]:hover {
    color: #1565c0 !important;
    text-decoration-style: solid !important;
}

/* Кнопка закрытия */
.sidebar-close-btn {
    transition: all 0.15s;
    opacity: 0.8;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    border-radius: 2px;
    opacity: 1;
}

#creativeInfoSection .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}

/* ============================================================================
   РЕЖИМЫ ЛЕВОГО МЕНЮ: Список / Детализация
   ============================================================================ */

/* Навигация по клиентам */
.client-nav-bar {
    display: none;
    gap: 4px;
    padding: 4px;
    background: #e8e8e8;
    border-bottom: 1px solid #ddd;
}

.client-nav-bar .nav-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 3px;
}

.client-nav-bar .back-btn {
    background: #757575;
    color: white;
}

.client-nav-bar .back-btn:hover {
    background: #616161;
}

.client-nav-bar .next-btn {
    background: #1976d2;
    color: white;
}

.client-nav-bar .next-btn:hover {
    background: #1565c0;
}

/* Виджет информации о клиенте */
.client-info-widget {
    display: none;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    transition: background 0.2s;
}

.client-info-widget:hover {
    background: #f5f5f5;
}

.client-info-widget .refresh-hint {
    font-size: 9px;
    color: #999;
    margin-top: 6px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.client-info-widget:hover .refresh-hint {
    opacity: 1;
}

/* --- Шапка: имя + бейджи --- */
.client-info-widget .client-header {
    margin-bottom: 6px;
}

.client-info-widget .client-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 3px;
}

.client-info-widget .client-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.client-info-widget .badge-tariff,
.client-info-widget .badge-ord {
    display: inline-block;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.client-info-widget .badge-tariff.free {
    background: #e0e0e0;
    color: #757575;
}

.client-info-widget .badge-tariff.paid {
    background: #4caf50;
    color: white;
}

.client-info-widget .badge-ord.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.client-info-widget .badge-ord.inactive {
    background: #fbe9e7;
    color: #c62828;
}

/* --- Строка ИНН / тип --- */
.client-info-widget .client-info-row {
    font-size: 11px;
    color: #555;
    margin-bottom: 6px;
    display: flex;
    gap: 8px;
}

/* --- Контакты --- */
.client-info-widget .client-contacts-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.client-info-widget .contact-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 3px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
    font-weight: 500;
}

.client-info-widget .contact-badge:hover {
    opacity: 0.8;
}

.client-info-widget .contact-badge.tg {
    background: #e3f2fd;
    color: #1565c0;
}

.client-info-widget .contact-badge.email {
    background: #f3e5f5;
    color: #7b1fa2;
}

.client-info-widget .contact-badge.phone {
    background: #e8f5e9;
    color: #2e7d32;
}

.client-info-widget .contact-badge.vk {
    background: #e3f2fd;
    color: #1565c0;
}

.client-info-widget .contact-badge.tg-lookup {
    background: #fff3e0;
    color: #e65100;
}

/* --- Статистика --- */
.client-info-widget .client-stats {
    display: flex;
    gap: 0;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #eee;
}

.client-info-widget .stat-item {
    flex: 1;
    text-align: center;
}

.client-info-widget .stat-value {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.client-info-widget .stat-label {
    font-size: 8px;
    color: #999;
    text-transform: uppercase;
}

/* --- ID (мелким шрифтом внизу) --- */
.client-info-widget .client-ids {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #f5f5f5;
}

.client-info-widget .client-id {
    font-size: 9px;
    color: #bbb;
    cursor: pointer;
    transition: color 0.2s;
    font-family: monospace;
}

.client-info-widget .client-id:hover {
    color: #1976d2;
}

.client-info-widget .client-id.copied {
    color: #4caf50;
}

/* Режим списка: показываем только список пользователей */
.left-sidebar.sidebar-list-mode .client-nav-bar,
.left-sidebar.sidebar-list-mode .client-info-widget {
    display: none;
}

.left-sidebar.sidebar-list-mode #usersSectionWrapper {
    display: flex;
}

.left-sidebar.sidebar-list-mode #padsSectionWrapper,
.left-sidebar.sidebar-list-mode #contractorsSectionWrapper {
    display: none;
}

/* Режим детализации: показываем детали клиента */
.left-sidebar.sidebar-detail-mode .client-nav-bar {
    display: flex;
}

.left-sidebar.sidebar-detail-mode .client-info-widget {
    display: block;
}

.left-sidebar.sidebar-detail-mode #usersSectionWrapper {
    display: none;
}

.left-sidebar.sidebar-detail-mode #padsSectionWrapper,
.left-sidebar.sidebar-detail-mode #contractorsSectionWrapper {
    display: flex;
}
