/* ========== Админ-панель ========== */
.admin-container {
    display: flex;
    min-height: calc(100vh - var(--header-height) - 80px);
    margin-top: 20px;
}

.admin-sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px;
}

.admin-sidebar h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.admin-nav {
    list-style: none;
    padding: 0;
}

.admin-nav li {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: background 0.2s;
}

.admin-nav li:hover,
.admin-nav li.active {
    background: var(--primary);
    color: white;
}

.admin-content {
    flex: 1;
    padding: 20px 30px;
    overflow-x: auto;
}

/* ========== Таблицы (единый стиль) ========== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    table-layout: fixed;                /* фиксированные колонки */
}

.admin-table th,
.admin-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.9rem;
    vertical-align: middle;
    line-height: 1.4;
    height: 42px;                       /* одинаковая высота строки */
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-table th {
    background: var(--bg);
    font-weight: 600;
    white-space: nowrap;
}

/* Ширины колонок – подобраны для большинства таблиц (8 колонок) */
.admin-table th:nth-child(1) { width: 5%; }   /* ID */
.admin-table th:nth-child(2) { width: 10%; }  /* Аватар / Название */
.admin-table th:nth-child(3) { width: 14%; }  /* Имя / Slug */
.admin-table th:nth-child(4) { width: 14%; }  /* Email / Категория */
.admin-table th:nth-child(5) { width: 14%; }  /* Описание / Статус */
.admin-table th:nth-child(6) { width: 14%; }  /* Роль / Лайки */
.admin-table th:nth-child(7) { width: 14%; }  /* Рецептов */
.admin-table th:nth-child(8) { width: 15%; }  /* Действия */

/* Для таблиц с меньшим числом колонок браузер проигнорирует лишние nth-child */
/* Если нужно точно подогнать под конкретную таблицу, можно добавить отдельные классы,
   но такой гибкости достаточно для плавного отображения. */

/* ========== Режимы просмотра и редактирования ========== */
.view-mode {
    display: inline-block;
    vertical-align: middle;
    line-height: 1.4;
}

.edit-mode {
    display: inline-block;
    width: 100%;
    height: 26px;                    /* фиксированная высота */
    box-sizing: border-box;
    margin: 0;
    padding: 0 6px;                 /* только горизонтальные отступы */
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 24px;              /* чтобы текст не прилипал к краям */
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    vertical-align: middle;
    resize: none;                   /* запрещаем растягивание (для textarea) */
    overflow: hidden;               /* скрываем лишний текст (для textarea) */
}

.edit-mode:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

textarea.edit-mode {
    height: 26px;
    resize: none;
    overflow: hidden;
    white-space: nowrap;            /* текст в одну строку */
}

/* ========== Аватар в таблице ========== */
.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* ========== Кнопки действий ========== */
.admin-table .btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    margin-right: 4px;
    white-space: nowrap;
}

/* ========== Плашки статуса ========== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
.status-published {
    background: #d4edda;
    color: #155724;
}
.status-draft {
    background: rgba(255, 193, 7, 0.9);
    color: #856404;
}

/* ========== Ссылка на рецепт ========== */
.recipe-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.recipe-link:hover {
    text-decoration: underline;
}

/* ========== Аватар среднего размера (в карточке пользователя) ========== */
.avatar-medium {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    cursor: pointer;
    transition: opacity 0.2s;
}
.avatar-medium:hover {
    opacity: 0.8;
}

/* ========== Модальное окно просмотра аватара ========== */
.avatar-modal {
    position: absolute;
    z-index: 9999;
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
    padding: 15px;
    width: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}
.avatar-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.avatar-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text);
    font-weight: 600;
}
.avatar-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.avatar-modal-close:hover {
    color: var(--text);
}
.avatar-modal-body img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 125px;
    display: block;
}

/* ========== Поля ввода и селекты (формы) ========== */
.admin-content .form-control,
.admin-content .form-select {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.25s, box-shadow 0.25s;
    background: var(--bg);
    outline: none;
    color: var(--text);
}
.admin-content .form-control:focus,
.admin-content .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.15);
}

/* ========== Пагинация ========== */
.pagination {
    display: flex;
    gap: 5px;
    margin-top: 15px;
}
.page-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    border-radius: 6px;
}
.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========== Дашборд ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin-top: 20px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
}
.stat-card span {
    display: block;
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 5px;
}
.period-selector {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.period-selector select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 10px;
}
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.chart-card h3 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    color: var(--text);
}
.chart-container {
    height: 300px;
}
.stats-summary {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-bottom: 25px;
    width: 100%;
    flex-wrap: nowrap;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
}
.summary-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 10px;
}
.summary-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

/* ========== Анимации ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ========== Адаптив для админки ========== */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Зелёная кнопка подтверждения */
.btn-success {
    background: #28a745;
    color: white;
    border-color: #28a745;
}
.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

/* Красная кнопка отмены */
.btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}
.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.admin-table tr.row-highlight-yellow {
    background-color: #fff3cd;
}

.row-highlight-yellow {
    background-color: #fff3cd;
}

/* Подборки на модерации */
.collections-moderation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.moderation-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.moderation-cover {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.moderation-info {
    padding: 15px;
}

.moderation-info h3 {
    margin: 0 0 5px;
    font-size: 1.1rem;
}

.moderation-info p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.moderation-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.moderation-recipes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0;
}
.moderation-recipe-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 8px;
    border-radius: 8px;
}
.moderation-recipe-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
}
.moderation-recipe-time {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.log-type {
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}
.log-type-user_action { background: #d4edda; color: #155724; }
.log-type-system { background: #d6eaf8; color: #0c5460; }
.log-type-error { background: #f8d7da; color: #721c24; }

.status-new { background: #d6eaf8; color: #0c5460; }
.status-in_progress { background: #ffe082; color: #856404; }
.status-answered { background: #c8e6c9; color: #1e5a1e; }
.status-closed { background: #e0e0e0; color: #333; }

/* Модальное окно обращения */
.report-admin-modal-content {
    width: 560px;
    max-width: 95%;
    max-height: 80vh;          /* ограничиваем высоту */
    overflow-y: auto;          /* включаем внутреннюю прокрутку */
    padding: 20px;
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    box-sizing: border-box;
}

.report-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.report-admin-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text);
}

.report-admin-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0 5px;
    transition: color 0.2s;
}

.report-admin-close:hover {
    color: var(--text);
}

.report-admin-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.report-admin-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-admin-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 80px;
}

.report-admin-message p {
    margin: 5px 0;
    background: var(--bg);
    padding: 10px;
    border-radius: 8px;
}

.report-admin-attachments,
.report-admin-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-admin-attachment-item,
.report-admin-message-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 10px;
}

.report-admin-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.report-admin-message-header small {
    color: var(--text-secondary);
}

.report-admin-empty {
    color: var(--text-secondary);
    font-style: italic;
}

.report-admin-reply textarea {
    width: 100%;
    min-height: 80px;
}

.report-admin-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Мобильная адаптация админ-модалки обращения */
@media (max-width: 480px) {
    .report-admin-modal-content {
        width: 95%;
        padding: 15px;
        border-radius: 16px;
        max-height: 85vh;
    }
    .report-admin-header h3 {
        font-size: 1.2rem;
    }
    .report-admin-close {
        font-size: 1.5rem;
    }
    .report-admin-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .report-admin-label {
        min-width: auto;
        font-weight: 600;
    }
    .report-admin-message p {
        font-size: 0.9rem;
        padding: 8px;
    }
    .report-admin-attachments {
        gap: 6px;
    }
    .report-admin-message-item {
        padding: 8px;
    }
    .report-admin-reply textarea {
        min-height: 60px;
    }
    .report-admin-actions {
        flex-direction: column;
        gap: 8px;
    }
    .report-admin-actions .btn {
        width: 100%;
    }
}