/* FamilyHub — стили (адаптивные, с боковым меню) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Страница логина --- */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8ecf1;
    padding: 16px;
}

.login-container {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-container h1 {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 4px;
}

.login-container .subtitle {
    color: #888;
    margin-bottom: 32px;
}

.login-container .form-group {
    text-align: left;
    margin-bottom: 16px;
}

/* --- Шапка --- */
header {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 12px 20px;
    flex-shrink: 0;
}

.header-row {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 {
    font-size: 22px;
    white-space: nowrap;
}

.menu-toggle {
    font-size: 18px;
    padding: 4px 8px;
    line-height: 1;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ecf0f1;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

/* --- Основная раскладка: sidebar + content --- */
.app-layout {
    display: flex;
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* --- Боковое меню --- */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    padding: 16px 0;
}

.sidebar.collapsed {
    display: none;
}

.nav-list {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #555;
    text-decoration: none;
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: #f5f7fa;
    color: #2c3e50;
}

.nav-link.active {
    background: #eef4fb;
    color: #2980b9;
    border-left-color: #2980b9;
    font-weight: 500;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-badge {
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
}

.sidebar.locked {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Контент --- */
.content {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

.page {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.panel h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #2c3e50;
}

.panel h3 {
    font-size: 15px;
    margin: 24px 0 12px;
    color: #555;
}

/* --- Главная страница --- */
#page-home {
    text-align: center;
    padding: 48px 32px;
}

.events-widget {
    margin-top: 40px;
    text-align: left;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.events-widget h3 {
    font-size: 15px;
    color: #666;
    margin-bottom: 12px;
    text-align: center;
}

.events-list {
    max-height: 400px;
    overflow-y: auto;
}

.events-empty {
    color: #999;
    text-align: center;
    font-size: 13px;
}

.event-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f3f3;
    font-size: 13px;
    line-height: 1.4;
}

.event-item:last-child {
    border-bottom: none;
}

.event-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.event-text {
    flex: 1;
    color: #555;
}

.event-text strong {
    color: #2c3e50;
}

.event-time {
    flex-shrink: 0;
    color: #bbb;
    font-size: 11px;
    white-space: nowrap;
}

.event-link {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.15s;
}

.event-link:hover {
    color: #3498db;
    text-decoration: underline;
}

#home-greeting {
    font-size: 26px;
    margin-bottom: 8px;
}

.home-subtext {
    color: #888;
    margin-bottom: 32px;
    font-size: 15px;
}

.home-name {
    font-size: 18px;
    color: #2c3e50;
    margin-top: 16px;
}

.profile-photo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.profile-photo-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e0e0e0;
}

.profile-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 13px;
    border: 3px dashed #ccc;
}

/* --- Панель индикаторов (главная) --- */
.dashboard {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.dash-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fb;
    border: 1px solid #e5e8ec;
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 220px;
    flex: 1;
}

.dash-card-full {
    flex-basis: 100%;
    min-width: 0;
}

.dash-card-sm {
    min-width: 100px;
    flex: 1 1 0;
}

.dash-icon {
    font-size: 28px;
    line-height: 1;
}

.dash-body {
    flex: 1;
    min-width: 0;
}

.dash-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.dash-value {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 6px;
}

.dash-detail {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.dash-bar-bg {
    width: 100%;
    height: 6px;
    background: #e5e8ec;
    border-radius: 3px;
    overflow: hidden;
}

.dash-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.dash-bar-fill.warn {
    background: linear-gradient(90deg, #FF9800, #FFC107);
}

.dash-bar-fill.crit {
    background: linear-gradient(90deg, #f44336, #FF5722);
}

.gallery-loading {
    text-align: center;
    color: #999;
    padding: 32px 16px;
    font-size: 14px;
}

/* --- Галерея --- */
.gallery-toolbar,
.files-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 8px;
}

.gallery-breadcrumbs {
    font-size: 14px;
    color: #666;
}

.gallery-breadcrumbs a {
    color: #3498db;
    text-decoration: none;
}

.gallery-breadcrumbs a:hover {
    text-decoration: underline;
}

.gallery-breadcrumbs span {
    margin: 0 6px;
    color: #999;
}

.gallery-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

/* --- Фильтр типов медиа --- */
.filter-bar {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.filter-btn {
    padding: 5px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #555;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filter-btn:hover {
    background: #f0f4f8;
    border-color: #3498db;
    color: #2980b9;
}

.filter-active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    font-weight: 500;
}

.filter-active:hover {
    background: #2980b9 !important;
    color: #fff !important;
}

/* Карточки разделов */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.gallery-card {
    background: #fafbfc;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    position: relative;
}

.gallery-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #3498db;
}

.gallery-card h3 {
    margin: 0 0 6px;
    font-size: 16px;
    color: #2c3e50;
}

.gallery-card .card-date {
    font-size: 12px;
    color: #999;
}

.gallery-card .card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

.gallery-card:hover .card-actions {
    display: flex;
}

/* --- Дерево разделов и галерей --- */
.tree-section {
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.tree-section-header {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    background: #f9fafb;
    transition: background 0.15s;
    user-select: none;
}
.tree-section-header:hover {
    background: #f0f4ff;
}
.tree-galleries {
    padding: 4px 0;
}
.tree-gallery {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px 8px 32px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: background 0.1s;
}
.tree-gallery:hover {
    background: #f0f7ff;
    color: #2980b9;
}

/* Сетка медиа */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.media-card {
    background: #fafbfc;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.media-card:hover {
    border-color: #b0b8c1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.media-thumb-wrap {
    position: relative;
    line-height: 0;
    background: #1a1a2e;
    min-height: 100px;
    overflow: hidden;
}
.media-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    pointer-events: none;
    z-index: 1;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
/* Тёмная полупрозрачная полоска внизу превью */
.media-thumb-wrap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    pointer-events: none;
    z-index: 1;
}

.media-thumb-placeholder {
    width: 100%;
    height: 140px;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.media-thumb-icon {
    font-size: 32px;
    color: rgba(255,255,255,0.4);
}

.media-thumb-ext {
    font-size: 12px;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    font-family: monospace;
}

.media-thumb-wrap img,
.media-thumb-wrap video {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.media-reactions-overlay {
    position: absolute;
    bottom: 6px;
    left: 6px;
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    pointer-events: none;
    z-index: 2;
}

.media-reaction-emoji {
    font-size: clamp(10px, 2.5vw, 16px);
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

@media (min-width: 768px) {
    .media-reaction-emoji {
        font-size: 14px;
    }
}

@media (min-width: 1024px) {
    .media-reaction-emoji {
        font-size: 16px;
    }
}

.media-card .media-placeholder {
    width: 100%;
    height: 140px;
    background: #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #999;
}

.media-card .media-info {
    padding: 8px 10px;
    font-size: 12px;
}

.media-card .media-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-card .media-meta {
    color: #999;
    font-size: 11px;
    margin-top: 2px;
}

.media-card .media-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
    display: none;
}

.media-card:hover .media-del {
    display: block;
}

/* Форма создания (раздел/галерея) */
.inline-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form input {
    padding: 7px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.inline-form input:focus {
    outline: none;
    border-color: #3498db;
}

/* Зона загрузки */
.upload-zone {
    border: 2px dashed #d0d5dd;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: #888;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}

.upload-zone:hover {
    border-color: #3498db;
    background: #f5f9fd;
}

.upload-zone-active {
    border-color: #27ae60 !important;
    background: #e8f8ef !important;
}

/* --- Прогресс загрузки --- */
.upload-progress {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.upload-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: #555;
}

.upload-progress-bar {
    height: 6px;
    background: #e8ecf1;
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.upload-zone input {
    display: none;
}

/* --- Формы --- */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.form-hint {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* Кнопка показать/скрыть пароль */
.pwd-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.pwd-wrap input {
    padding-right: 38px;
}

.pwd-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    color: #888;
    user-select: none;
}

.pwd-toggle:hover {
    color: #333;
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* --- Кнопки --- */
.btn {
    padding: 8px 16px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    transition: background 0.15s;
}

.btn:hover {
    background: #f5f5f5;
}

.btn-primary {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-danger {
    color: #e74c3c;
    border-color: #e74c3c;
}

.btn-danger:hover {
    background: #fde8e8;
}

/* --- Сообщения --- */
.error-message {
    color: #e74c3c;
    font-size: 13px;
    margin-bottom: 8px;
    padding: 8px;
    background: #fde8e8;
    border-radius: 4px;
}

.ok-message {
    color: #27ae60;
    font-size: 13px;
    margin-bottom: 8px;
    padding: 8px;
    background: #e8f8ef;
    border-radius: 4px;
}

.settings-photo-preview {
    margin-bottom: 12px;
}

.photo-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.photo-upload-label {
    cursor: pointer;
    display: inline-block;
}

/* --- Таблицы (пользователи, бэкапы) --- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#users-table, #backup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#users-table th,
#users-table td,
#backup-table th,
#backup-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

#users-table th, #backup-table th {
    font-weight: 600;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #fafafa;
}

#users-table td .btn {
    margin-right: 4px;
}

.user-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

.user-thumb-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8ecf1;
    display: inline-block;
    vertical-align: middle;
}

/* --- Кнопка «Наверх» --- */
.btn-scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2980b9;
    color: #fff;
    border: none;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 900;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-scroll-top:hover {
    background: #1c6ea0;
}

.btn-scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

/* --- Подвал --- */
footer {
    text-align: center;
    padding: 12px;
    color: #999;
    font-size: 12px;
    flex-shrink: 0;
}

/* --- Чат --- */
.chat-messages {
    height: 55vh;
    overflow-y: auto;
    padding: 8px 0;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    animation: fadeIn 0.15s ease;
}

.chat-msg-mine {
    align-self: flex-end;
    background: #3498db;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-other {
    align-self: flex-start;
    background: #f0f2f5;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-msg-user {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.chat-msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.chat-msg-mine .chat-msg-time {
    color: rgba(255,255,255,0.7);
}

.chat-form {
    display: flex;
    gap: 8px;
}

.chat-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.chat-form input:focus {
    outline: none;
    border-color: #3498db;
}

.chat-typing {
    font-size: 12px;
    color: #999;
    padding: 4px 0;
}

/* --- Панель комментариев --- */
.comments-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100%;
    background: #fff;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    animation: slideIn 0.25s ease;
}
@keyframes slideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.comments-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.comments-header .lightbox-close {
    position: static;
    color: #333;
    font-size: 24px;
    z-index: auto;
}
.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.comment-item {
    padding: 10px 14px;
    border-radius: 10px;
    background: #f3f4f6;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    max-width: 90%;
    align-self: flex-start;
}
.comment-item.my {
    align-self: flex-end;
    background: #e8f4fd;
}
.comment-user {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    display: block;
    margin-bottom: 2px;
}
.comment-text {
    color: #1f2937;
    white-space: pre-wrap;
    word-break: break-word;
}
.comment-time {
    font-size: 10px;
    color: #9ca3af;
    display: block;
    margin-top: 6px;
    text-align: right;
}
.comment-delete {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}
.comment-delete:hover {
    color: #ef4444;
}
.comments-form {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}
.comments-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.comments-form input:focus {
    outline: none;
    border-color: #3498db;
}

/* --- Бейдж счётчика комментариев на превью --- */
.media-comment-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    pointer-events: none;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* --- Лайтбокс --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 90vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 2001;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-viewer {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 48px;
    width: 56px;
    height: 80px;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover { opacity: 1; background: rgba(255,255,255,0.25); }

.lightbox-prev { left: -64px; }
.lightbox-next { right: -64px; }

/* --- Панель реакций в лайтбоксе --- */
.lightbox-reactions {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 12px 0 4px;
    flex-wrap: wrap;
}

.reaction-btn {
    font-size: 22px;
    padding: 4px 8px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 3px;
    color: #ddd;
}

.reaction-btn:hover {
    background: rgba(255,255,255,0.18);
}

.reaction-btn.my {
    border-color: #3498db;
    background: rgba(52,152,219,0.2);
}

.reaction-btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.reaction-count {
    font-size: 12px;
    color: #aaa;
    min-width: 12px;
}

.lightbox-info {
    color: #ccc;
    font-size: 13px;
    margin-top: 12px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.lightbox-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.lightbox-actions .btn {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ddd;
}

.lightbox-actions .btn:hover {
    background: rgba(255,255,255,0.2);
}

.lightbox-actions .btn-danger {
    color: #ff6b6b;
    border-color: rgba(255,107,107,0.4);
}

.lightbox-actions .btn-danger:hover {
    background: rgba(255,107,107,0.2);
}

/* --- Пагинация --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #555;
    transition: background 0.15s, border-color 0.15s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f0f4f8;
    border-color: #3498db;
    color: #2980b9;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination-active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    font-weight: 600;
}

.pagination-active:hover {
    background: #2980b9 !important;
    color: #fff !important;
}

.pagination-info {
    font-size: 12px;
    color: #999;
    margin: 0 12px;
}

.pagination-ellipsis {
    padding: 6px 4px;
    font-size: 13px;
    color: #999;
    user-select: none;
}

/* --- Модальное окно --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
    padding: 16px;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 20px 24px 8px;
}

.modal-header h3 {
    font-size: 17px;
    color: #2c3e50;
    margin: 0;
}

.modal-body {
    padding: 8px 24px 16px;
}

.modal-body p {
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.modal-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    margin-top: 12px;
    transition: border-color 0.2s;
}

.modal-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.modal-footer {
    padding: 0 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* =====================================================================
   Адаптивность — планшеты (≤ 768px)
   ===================================================================== */
@media (max-width: 768px) {
    .sidebar {
        width: 56px;
    }

    .nav-link {
        padding: 12px;
        justify-content: center;
    }

    .nav-link span:not(.nav-icon) {
        display: none;
    }

    .nav-icon {
        font-size: 20px;
        margin: 0;
    }

    .content {
        padding: 16px;
    }

    .panel {
        padding: 20px;
    }

    #page-home {
        padding: 40px 20px;
    }

    #home-greeting {
        font-size: 22px;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        min-width: 0;
    }

    header h1 {
        font-size: 18px;
    }

    .dashboard {
        gap: 10px;
    }

    .dash-card {
        padding: 12px 14px;
        min-width: 140px;
    }

    .dash-icon {
        font-size: 24px;
    }

    .dash-value {
        font-size: 18px;
    }
}

/* =====================================================================
   Адаптивность — телефоны (≤ 480px)
   ===================================================================== */
@media (max-width: 480px) {
    .login-container {
        padding: 24px 16px;
    }

    .login-container h1 {
        font-size: 22px;
    }

    .sidebar {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        border-right: none;
        border-top: 1px solid #e0e0e0;
        padding: 0;
        display: flex;
    }

    .sidebar.collapsed {
        display: flex; /* нижнее меню всегда видно */
    }

    .nav-list {
        display: flex;
        width: 100%;
    }

    .nav-list li {
        flex: 1;
    }

    .nav-link {
        flex-direction: column;
        gap: 2px;
        padding: 8px 4px;
        font-size: 10px;
        text-align: center;
        border-left: none;
        border-top: 3px solid transparent;
    }

    .nav-link.active {
        border-left: none;
        border-top-color: #2980b9;
    }

    .nav-icon {
        font-size: 20px;
    }

    .app-layout {
        flex-direction: column;
        padding-bottom: 70px; /* место для нижнего меню */
    }

    .content {
        padding: 12px;
    }

    .panel {
        padding: 16px;
    }

    #page-home {
        padding: 32px 16px;
    }

    #home-greeting {
        font-size: 20px;
    }

    .profile-photo-img,
    .profile-photo-placeholder {
        width: 80px;
        height: 80px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 15px;
        width: 100%;
    }

    .btn-sm {
        width: auto;
    }

    .btn-row {
        flex-direction: column;
    }

    #users-table {
        font-size: 12px;
    }

    #users-table th,
    #users-table td {
        padding: 6px 4px;
    }

    .menu-toggle {
        display: none;
    }

    /* Индикаторы — компактнее */
    .dashboard {
        gap: 8px;
    }

    .dash-card {
        padding: 10px 12px;
        gap: 8px;
        min-width: 0;
    }

    .dash-card-full {
        min-width: 0;
    }

    .dash-card-sm {
        min-width: 0;
        flex: 1 1 0;
    }

    .dash-icon {
        font-size: 22px;
    }

    .dash-value {
        font-size: 16px;
    }

    .dash-label {
        font-size: 11px;
    }

    .dash-detail {
        font-size: 10px;
    }

    .dash-bar-bg {
        height: 4px;
    }

    /* --- Лайтбокс: мобильная версия --- */
    .lightbox-content img,
    .lightbox-content video {
        max-height: 50vh;
    }

    .lightbox-info {
        font-size: 11px;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .lightbox-actions {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .lightbox-actions .btn {
        font-size: 11px;
        padding: 6px 10px;
        white-space: nowrap;
    }

    .lightbox-reactions {
        gap: 2px;
        padding: 8px 0 2px;
    }

    .reaction-btn {
        font-size: 16px;
        padding: 2px 4px;
        gap: 1px;
    }
    .reaction-count {
        font-size: 10px;
    }

    .lightbox-nav {
        font-size: 36px;
    }
}

/* Индикатор скрытой от гостей галереи */
.guest-hidden-badge {
    display: inline-block;
    font-size: 14px;
    opacity: 0.7;
    vertical-align: middle;
    cursor: help;
}

/* Чекбокс в строке формы галереи */
.inline-form .checkbox-label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.inline-form .checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

/* --- Лучшее --- */
.best-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.best-toolbar h2 {
    margin-bottom: 0;
    font-size: 20px;
    color: #2c3e50;
}

.best-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.best-info {
    padding: 10px 12px 12px;
}

.best-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-size: 13px;
}

.best-path {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.best-path a {
    color: #3498db;
    text-decoration: none;
}

.best-path a:hover {
    text-decoration: underline;
}

.best-path span {
    color: #ccc;
    margin: 0 2px;
}

/* --- Таблица файлов --- */
.files-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.files-table th {
    background: #f5f7fa;
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.files-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.files-table tbody tr:hover {
    background: #f9fafb;
}

.files-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}

.file-type-badge {
    display: inline-block;
    background: #eef2f7;
    color: #666;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    text-transform: lowercase;
}

/* Адаптив: файлы */
@media (max-width: 640px) {
    .files-table th:nth-child(2),
    .files-table td:nth-child(2) {
        display: none;
    }
    .files-table th:nth-child(3),
    .files-table td:nth-child(3) {
        display: none;
    }
}
