@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

:root {
    --primary-color: #5E81AC; /* Скандинавский синий */
    --primary-hover: #4C566A;
    --bg-color: #F4F6F9; /* Светлый серо-голубой фон */
    --card-bg: #ffffff;
    --text-color: #2E3440; /* Темно-серый, почти черный */
    --text-muted: #4C566A;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header */
.main-header {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03); /* Очень мягкая тень */
    padding: 1rem 0;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-header nav a:not(.btn-add) {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 10px 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.main-header nav a:not(.btn-add):hover,
.main-header nav a.active {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.btn-add {
    background: var(--primary-color);
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 50px; /* Pill shape */
    text-decoration: none;
    transition: background 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(94, 129, 172, 0.2);
}
.btn-add:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Grid для каналов */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.channel-card {
    background: var(--card-bg);
    border-radius: 20px; /* Более сильное скругление */
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.03); /* Мягкая, рассеянная тень */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.02);
}

.channel-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.channel-logo {
    width: 50px;
    height: 50px;
    border-radius: 14px; /* Soft square */
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.channel-logo-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    flex-shrink: 0;
    background-color: #ECEFF4;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
}

.channel-card-info {
    min-width: 0; /* Prevents overflow with flexbox */
}

.channel-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.06);
}

.channel-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    margin-bottom: 2px;
}

.channel-title {
    margin: 0;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-desc {
    flex-grow: 1;
    margin-bottom: 15px;
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Breadcrumbs */
.breadcrumbs {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.breadcrumbs a {
    color: var(--primary-color);
    text-decoration: none;
}
.breadcrumbs a:hover {
    text-decoration: underline;
}
.breadcrumbs span {
    margin: 0 5px;
    color: #ccc;
}

.btn-visit {
    display: block;
    text-align: center;
    background: #ECEFF4;
    color: var(--text-color);
    padding: 10px 15px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-visit:hover {
    background: #E5E9F0;
}

/* Формы */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
}
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ECEFF4;
    border-radius: 12px;
    background: #fff;
    box-sizing: border-box; /* Важно для input */
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Пагинация */
.pagination {
    margin-top: 2rem;
    display: flex;
    gap: 10px;
    justify-content: center;
}
.pagination a {
    padding: 8px 16px;
    background: #fff;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.pagination a.active {
    background: var(--primary-color);
    color: #fff;
}

/* Страница просмотра канала */
.channel-detail {
    background: #fff;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    overflow: hidden; /* To contain the floated logo */
}
.channel-detail-logo {
    float: left;
    margin: 0 20px 10px 0;
    width: 100px;
    height: 100px;
    border-radius: 20px;
    object-fit: cover;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}
.meta-info {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* Footer */
.main-footer {
    margin-top: auto;
    padding: 20px 0;
    text-align: center;
    color: #777;
}

/* Admin Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th, .admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ECEFF4;
}
.admin-table th {
    background-color: #ECEFF4;
    font-weight: 600;
    color: var(--text-color);
    border-radius: 8px 8px 0 0;
}

/* Burger Menu */
.burger-menu {
    display: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    z-index: 100;
}

.burger-menu span {
    width: 25px;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .main-header {
        position: relative;
    }

    .burger-menu {
        display: flex;
    }

    .main-header nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #fff;
        flex-direction: column;
        align-items: center;
        padding: 20px 0;
        box-shadow: 0 10px 20px rgba(0,0,0,0.05);
        display: none;
        z-index: 99;
        border-top: 1px solid #ECEFF4;
    }

    .main-header nav.active {
        display: flex;
    }

    .main-header nav a {
        margin: 10px 0;
        font-size: 1.1rem;
        width: 100%;
        text-align: center;
    }

    /* Анимация бургера */
    .burger-menu.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
    .burger-menu.active span:nth-child(2) { opacity: 0; }
    .burger-menu.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }
}

/* --- Новые стили для унификации дизайна --- */

/* Контейнеры форм (Вход, Добавление, Редактирование) */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
}
.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 40px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
}

/* Уведомления (Alerts) */
.alert {
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}
.alert-success {
    background: #E6F4EA;
    color: #2E7D32;
}
.alert-danger {
    background: #FCE8E6;
    color: #C62828;
}
.alert-content {
    flex: 1;
}
.alert a {
    text-decoration: underline;
    font-weight: bold;
}
.alert-success a { color: #2E7D32; }
.alert-danger ul { margin: 5px 0 0 20px; padding: 0; }

/* Поиск и Табы */
.search-form {
    display: flex;
    gap: 10px;
    max-width: 760px;
    margin: 0 auto;
    flex-wrap: wrap;
    align-items: center;
}
.search-bar {
    display: flex;
    justify-content: center;
    margin: 0 auto 14px;
    padding: 8px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.04);
    border: 1px solid rgba(94, 129, 172, 0.08);
}
.search-form input[type="text"] {
    flex: 1 1 360px;
}
.search-form select {
    flex: 0 0 auto;
    min-width: 190px;
}
.search-form .btn-add {
    flex: 0 0 auto;
    padding: 0.7rem 1.4rem;
    line-height: 1;
}
.search-form .form-control {
    height: 50px;
    border-radius: 14px;
    background: #F7F9FC;
    border: 1px solid #E6EBF2;
}
.search-form .btn-add {
    height: 50px;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(94, 129, 172, 0.2);
}
.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 34px;
    flex-wrap: wrap;
}
.tab-item {
    background: #F0F3F8;
    color: var(--text-color);
    padding: 10px 22px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: none;
    border: 1px solid #E6EBF2;
}
.tab-item:hover {
    background: #E9EEF6;
}
.tab-item.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 8px 18px rgba(94, 129, 172, 0.35);
    border-color: transparent;
}

/* Админ-панель */
.admin-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
.admin-table-wrapper {
    overflow-x: auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    padding: 5px;
}

/* Детальная страница */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.2s;
}
.back-link:hover {
    color: var(--primary-color);
}
.channel-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ECEFF4;
}
.like-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 50px;
    transition: all 0.2s;
}
.like-button.liked {
    background: #FCE8E6;
    color: #BF616A;
    border: 1px solid #FCE8E6;
    cursor: default;
}
.like-button.not-liked {
    background: #fff;
    color: #BF616A;
    border: 2px solid #BF616A;
}
.like-button.not-liked:hover {
    background: #FCE8E6;
}
.btn-control {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    border-radius: 8px;
    transition: background 0.2s;
}
.btn-control.edit {
    color: var(--text-muted);
    background: #ECEFF4;
}
.btn-control.edit:hover { background: #E5E9F0; }
.btn-control.delete {
    color: #BF616A;
    background: #FCE8E6;
}
.btn-control.delete:hover { background: #F9D6D3; }

/* Топ-10 */
.page-header {
    text-align: center;
    margin-bottom: 40px;
}
.rank-badge {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 40px;
    height: 40px;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    z-index: 1;
    border: 3px solid #fff;
}

/* --- Landing Page Styles --- */

.hero-section {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #fff 0%, #F4F6F9 100%);
    border-radius: 24px;
    margin-bottom: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.02);
}
.hero-title {
    font-size: 2.5rem;
    color: var(--text-color);
    margin-bottom: 15px;
    font-weight: 800;
}
.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.categories-section {
    margin-bottom: 60px;
    position: relative;
}
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 18px;
}
.category-card {
    background: linear-gradient(180deg, #FFFFFF 0%, #F7F9FC 100%);
    padding: 22px 16px;
    border-radius: 18px;
    text-align: center;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: 0 6px 18px rgba(0,0,0,0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(94, 129, 172, 0.08);
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(0,0,0,0.08);
    border-color: rgba(94, 129, 172, 0.25);
}
.category-card:focus-visible {
    outline: 3px solid rgba(94, 129, 172, 0.35);
    outline-offset: 2px;
}
.category-icon {
    font-size: 2.2rem;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: #EEF2F7;
    color: var(--primary-color);
    box-shadow: inset 0 0 0 1px rgba(94, 129, 172, 0.08);
}
.category-name {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text-color);
    line-height: 1.3;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    margin-top: 60px;
}
.section-title {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 700;
}

.faq-section, .about-section {
    background: #fff;
    padding: 40px;
    border-radius: 24px;
    margin-top: 60px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
}
details.faq-item {
    margin-bottom: 15px;
    padding: 15px;
    background: #FAFAFC;
    border-radius: 12px;
    cursor: pointer;
}
details.faq-item summary {
    font-weight: 600;
    list-style: none;
}
details.faq-item p {
    margin-top: 10px;
    color: var(--text-muted);
    line-height: 1.6;
}
