/**
 * Стили раздела рассылок в админ-панели
 * Оформление под основную админ-панель (белые карточки, градиент)
 */

.admin-nav {
    display: flex;
    gap: 8px;
}

.admin-nav-link {
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none !important;
    color: #666;
    font-weight: 500;
    transition: all 0.2s;
    background: #f5f5f5;
    border: none;
}

.admin-nav-link:hover {
    background: #eee;
    color: #333;
}

.admin-nav-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.admin-tab-content {
    display: none !important;
}

.admin-tab-content.active {
    display: block !important;
}

/* Вкладки рассылок */
.mail-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mail-tab {
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    background: white;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.2s;
}

.mail-tab:hover {
    background: #f8f8f8;
    color: #333;
}

.mail-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.mail-tab-content {
    display: none;
}

.mail-tab-content.active {
    display: block;
}

/* Статистика */
.mail-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.mail-stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.mail-stat-card h3 {
    color: #999;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.mail-stat-card .value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

/* Карточки рассылок */
.mail-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.mail-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    min-width: 0;
    overflow: hidden;
}

.mail-card h2 {
    color: #333;
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.mail-card .form-control {
    max-width: 100%;
    box-sizing: border-box;
}

/* Редактор — светлая тема под админ */
.telegram-editor {
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    max-width: 100%;
}

.editor-toolbar {
    background: #f0f0f0;
    padding: 10px;
    display: flex;
    gap: 5px;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.toolbar-btn {
    background: white;
    border: 1px solid #ddd;
    color: #666;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.toolbar-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

#editor-container {
    min-height: 180px;
    padding: 14px 16px;
    color: #333;
    background: white;
    font-size: 15px;
    line-height: 1.5;
    outline: none;
    overflow-y: auto;
}

#editor-container:empty:before {
    content: attr(data-placeholder);
    color: #999;
}

/* Предпросмотр Telegram — тёмный блок для контраста */
.preview-card {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border: 1px solid #2d2d44;
    overflow: hidden;
}

.preview-card h2 {
    color: white;
    border: none;
    margin-bottom: 20px;
    font-size: 16px;
}

.telegram-message {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 360px;
    margin: 0 auto;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.message-info {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.sender-name {
    font-weight: 600;
    color: white;
    font-size: 15px;
}

.bot-tag {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.message-time {
    color: #8e9fb1;
    font-size: 13px;
    margin-left: 4px;
}

.message-bubble {
    background: #16213e;
    border-radius: 12px 12px 12px 4px;
    padding: 12px 14px;
    margin-left: 48px;
    max-width: calc(100% - 48px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.preview-photos {
    margin: -4px -8px 8px -8px;
    display: grid;
    gap: 2px;
    border-radius: 8px;
    overflow: hidden;
}

.preview-photos.has-1 { grid-template-columns: 1fr; }
.preview-photos.has-2 { grid-template-columns: 1fr 1fr; }
.preview-photos.has-3 { grid-template-columns: 1fr 1fr; }
.preview-photos.has-3 .preview-photo:nth-child(3) { grid-column: 1 / -1; }
.preview-photos.has-4 { grid-template-columns: 1fr 1fr; }
.preview-photos.has-5,
.preview-photos.has-6 { grid-template-columns: 1fr 1fr; }

.preview-photo {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

.preview-photos.has-1 .preview-photo {
    aspect-ratio: auto;
    max-height: 280px;
    object-fit: contain;
}

.preview-text {
    color: #e0e0e0;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.preview-text a {
    color: #6ab3f3;
    text-decoration: none;
}

.preview-text a:hover { text-decoration: underline; }

.preview-text b, .preview-text strong { font-weight: 600; }
.preview-text i, .preview-text em { font-style: italic; }
.preview-text u { text-decoration: underline; }
.preview-text s { text-decoration: line-through; }
.preview-text code {
    background: #0f0f1a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.preview-text.empty {
    color: #6b7f94;
    font-style: italic;
}

.preview-documents {
    margin-top: 10px;
    border-top: 1px solid #2d2d44;
    padding-top: 10px;
}

.preview-document {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #0f0f1a;
    border-radius: 8px;
    margin-bottom: 6px;
    color: #e0e0e0;
}

.preview-document:last-child { margin-bottom: 0; }

.preview-document-icon { font-size: 18px; }

.preview-document-name { font-size: 14px; font-weight: 500; }

.preview-document-size {
    color: #8e9fb1;
    font-size: 11px;
    margin-top: 2px;
}

/* Загрузка файлов */
.file-upload-area {
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
    max-width: 100%;
}

.file-upload-area:hover {
    border-color: #667eea;
    background: #f5f3ff;
}

.file-upload-area.dragover {
    border-color: #22c55e;
    background: #f0fdf4;
}

.file-list { margin-top: 12px; }

.file-item {
    background: #f9f9f9;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #eee;
}

.file-item span:last-child {
    color: #ef4444;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
}

.file-item span:last-child:hover {
    background: #fef2f2;
}

/* Фильтры */
.filter-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.filter-option {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-option:hover {
    background: #f0f0f0;
    border-color: #667eea;
}

.filter-option.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.filter-option .title {
    font-size: 12px;
    margin-bottom: 6px;
    color: #999;
}

.filter-option.active .title {
    color: rgba(255,255,255,0.9);
}

.filter-option .count {
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

.filter-option.active .count {
    color: white;
}

/* Таблица рассылок */
.tasks-table {
    width: 100%;
    border-collapse: collapse;
}

.tasks-table th {
    text-align: left;
    padding: 14px;
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    color: #666;
    font-weight: 600;
    font-size: 13px;
}

.tasks-table td {
    padding: 14px;
    border-bottom: 1px solid #eee;
    color: #333;
}

.tasks-table tr:hover {
    background: #fafafa;
}

.mail-progress {
    width: 120px;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.mail-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 4px;
}

.btn-warning {
    background: #f97316;
    color: white;
}

.btn-success {
    background: #22c55e;
    color: white;
}

/* Бейджи */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-paused { background: #e5e7eb; color: #4b5563; }
.badge-stopped { background: #fee2e2; color: #991b1b; }

/* Список пользователей */
.users-list {
    max-height: 280px;
    overflow-y: auto;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 8px;
    border: 1px solid #eee;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 6px;
}

.user-item:last-child { border-bottom: none; }

.user-item:hover {
    background: #f0f0f0;
}

.user-item.selected {
    background: linear-gradient(135deg, rgba(102,126,234,0.2) 0%, rgba(118,75,162,0.2) 100%);
}

.selected-users {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    min-height: 50px;
    border: 1px solid #eee;
}

.selected-tag {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    margin: 4px 4px 4px 0;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.selected-tag:hover {
    opacity: 0.9;
}

/* Модальное окно рассылок */
.mail-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.mail-modal.active {
    display: flex;
}

.mail-modal .modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.mail-modal .modal-content h2 {
    color: #333;
    margin-bottom: 15px;
}

.mail-modal .modal-content hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 15px 0;
}

@media (max-width: 900px) {
    .mail-main-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .admin-nav {
        flex-direction: column;
    }

    .mail-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-options {
        grid-template-columns: 1fr 1fr;
    }
}
