/* ===== ПЕРЕМЕННЫЕ ТЕМ ===== */
:root {
    /* Светлая тема (по умолчанию) */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f2f2f7;
    --bg-active: #e5e5ea;
    --bg-modal-overlay: rgba(0, 0, 0, 0.5);
    --bg-tag: #f2f2f7;
    --bg-tag-hover: #e5e5ea;
    --bg-vote-btn: #f2f2f7;
    --bg-vote-btn-hover: #e5e5ea;
    --bg-comment: #f8f8fa;
    --bg-comment-hover: #f2f2f7;
    --bg-navbar: rgba(255, 255, 255, 0.95);
    --bg-header: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    --bg-admin-header: linear-gradient(135deg, #ff3b30 0%, #d63031 100%);
    
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #8e8e93;
    --text-white: #ffffff;
    --text-link: #007aff;
    --text-link-hover: #0066d9;
    --text-tag: #555555;
    
    --border-color: #e5e5ea;
    --border-light: #f2f2f7;
    --border-card: rgba(0, 0, 0, 0.03);
    
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-header: 0 4px 12px rgba(0, 122, 255, 0.3);
    --shadow-btn: 0 2px 8px rgba(0, 122, 255, 0.25);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.2);
    --shadow-navbar: 0 -4px 20px rgba(0, 0, 0, 0.05);
    --shadow-tag: 0 2px 8px rgba(0, 122, 255, 0.25);
    
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --scrollbar-thumb-hover: #a8a8a8;
    
    --fav-color: #ff9500;
    --fav-inactive: #c7c7cc;
    --dislike-hover: #ffebee;
}

/* ===== ТЕМНАЯ ТЕМА ===== */
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2333;
    --bg-input: #0d1117;
    --bg-hover: #2d3748;
    --bg-active: #374151;
    --bg-modal-overlay: rgba(0, 0, 0, 0.85);
    --bg-tag: #2d3748;
    --bg-tag-hover: #374151;
    --bg-vote-btn: #2d3748;
    --bg-vote-btn-hover: #374151;
    --bg-comment: #1c2333;
    --bg-comment-hover: #2d3748;
    --bg-navbar: rgba(22, 27, 34, 0.95);
    --bg-header: linear-gradient(135deg, #0d1b3e 0%, #2d1b69 100%);
    --bg-admin-header: linear-gradient(135deg, #3d1a1a 0%, #692b2b 100%);
    
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-white: #ffffff;
    --text-link: #58a6ff;
    --text-link-hover: #79c0ff;
    --text-tag: #8b949e;
    
    --border-color: #30363d;
    --border-light: #21262d;
    --border-card: rgba(255, 255, 255, 0.06);
    
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.6);
    --shadow-header: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-btn: 0 2px 8px rgba(88, 166, 255, 0.3);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.9);
    --shadow-navbar: 0 -4px 20px rgba(0, 0, 0, 0.4);
    --shadow-tag: 0 2px 8px rgba(88, 166, 255, 0.25);
    
    --scrollbar-track: #0d1117;
    --scrollbar-thumb: #2d3748;
    --scrollbar-thumb-hover: #374151;
    
    --fav-color: #ff9500;
    --fav-inactive: #6e7681;
    --dislike-hover: #3d1a1a;
}

/* ===== ОБЩИЕ СТИЛИ ===== */
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background: var(--bg-primary); 
    margin: 0; 
    padding: 0; 
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ===== ШАПКА ===== */
.app-header {
    background: var(--bg-header);
    padding: 20px 16px 16px 16px;
    margin: 0;
    border-radius: 0 0 24px 24px;
    box-shadow: var(--shadow-header);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.app-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.app-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-badge {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
}

/* ===== КНОПКА ТЕМЫ ===== */
.theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    padding: 6px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(4px);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Кнопка новостей в шапке */
.news-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    padding: 6px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(4px);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.news-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.news-btn:active {
    transform: scale(0.95);
}

/* ===== БЛОК КНОПОК ===== */
.action-bar {
    padding: 12px 16px 8px 16px;
    background: var(--bg-secondary);
    margin: -8px 0 0 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    background: var(--bg-navbar);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Кнопки режимов */
.mode-btn {
    background: var(--bg-tag);
    color: var(--text-primary);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.mode-btn:hover {
    background: var(--bg-tag-hover);
    transform: translateY(-1px);
}

.mode-btn.active {
    background: #007aff;
    color: white;
    box-shadow: var(--shadow-btn);
}

.mode-btn.active:hover {
    background: #0066d9;
}

/* Основные кнопки */
.btn-primary {
    background: #007aff;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
    background: #0066d9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
}

.btn-secondary {
    background: var(--bg-tag);
    color: var(--text-primary);
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-secondary:hover {
    background: var(--bg-tag-hover);
}

.btn-danger {
    background: #ff3b30;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-danger:hover {
    background: #d63031;
}

/* ===== ТЕГИ ===== */
.hashtags { 
    display: flex; 
    gap: 8px; 
    overflow-x: auto; 
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: none;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.hashtags::-webkit-scrollbar {
    display: none;
}

.tag { 
    background: var(--bg-tag); 
    padding: 6px 14px; 
    border-radius: 16px; 
    font-size: 13px; 
    cursor: pointer; 
    white-space: nowrap; 
    color: var(--text-primary); 
    transition: all 0.2s ease;
    font-weight: 500;
}

.tag:hover {
    background: var(--bg-tag-hover);
    transform: scale(1.02);
}

.tag.active { 
    background: #007aff; 
    color: white; 
    box-shadow: var(--shadow-tag);
}

/* ===== КАРТОЧКИ РАССКАЗОВ ===== */
#stories-container {
    padding: 12px 16px;
}

.story-card { 
    background: var(--bg-card); 
    padding: 16px 18px; 
    border-radius: 16px; 
    margin-bottom: 12px; 
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
    border: 1px solid var(--border-card);
}

.story-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

.story-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.story-title { 
    font-size: 18px; 
    font-weight: 600; 
    color: var(--text-link); 
    text-decoration: none; 
    display: block; 
    margin-bottom: 6px;
    transition: color 0.2s ease;
}

.story-title:hover {
    color: var(--text-link-hover);
}

/* ===== ТЕГИ ВНУТРИ РАССКАЗА ===== */
.story-tags { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px; 
    margin-bottom: 10px; 
}

.story-tags .tag { 
    font-size: 11px; 
    padding: 3px 10px; 
    background: var(--bg-tag); 
    color: var(--text-tag); 
}

.story-tags .tag:hover { 
    background: var(--bg-tag-hover); 
}

.story-tags .tag.active { 
    background: #007aff; 
    color: white; 
}

.story-preview { 
    font-size: 14px; 
    color: var(--text-secondary); 
    line-height: 1.5; 
    margin-bottom: 12px; 
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== ПОДВАЛ КАРТОЧКИ ===== */
.story-footer { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 14px; 
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.vote-box { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.vote-box button {
    background: var(--bg-vote-btn);
    color: var(--text-primary);
    border: none;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.vote-box button:hover {
    background: var(--bg-vote-btn-hover);
    transform: scale(1.05);
}

.vote-box button.dislike:hover {
    background: var(--dislike-hover);
}

.rating-val { 
    font-weight: 600; 
    min-width: 24px; 
    text-align: center;
    font-size: 15px;
}

.story-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.views-count {
    display: flex;
    align-items: center;
    gap: 3px;
}

.comments-link { 
    color: var(--text-muted); 
    text-decoration: none; 
    font-weight: 500;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 3px;
}

.comments-link:hover { 
    color: var(--text-link); 
}

/* ===== КНОПКА ИЗБРАННОГО ===== */
.fav-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    transition: all 0.3s ease;
    color: var(--fav-inactive);
}

.fav-btn.active {
    color: var(--fav-color);
}

.fav-btn:hover {
    transform: scale(1.3);
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: var(--bg-modal-overlay); 
    justify-content: center; 
    align-items: center; 
    z-index: 1000; 
    backdrop-filter: blur(4px);
}

.modal-content { 
    background: var(--bg-secondary); 
    padding: 24px; 
    border-radius: 20px; 
    width: 90%; 
    max-width: 420px; 
    box-sizing: border-box; 
    box-shadow: var(--shadow-modal);
    animation: modalSlideUp 0.3s ease;
    color: var(--text-primary);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h3 { 
    margin-top: 0; 
    color: var(--text-link); 
    font-size: 20px;
}

.form-group { 
    margin-bottom: 16px; 
}

.form-group label { 
    display: block; 
    font-size: 13px; 
    color: var(--text-muted); 
    margin-bottom: 4px; 
    font-weight: 500;
}

.form-group input, 
.form-group textarea { 
    width: 100%; 
    padding: 10px 12px; 
    border: 2px solid var(--border-color); 
    border-radius: 12px; 
    box-sizing: border-box; 
    font-family: inherit;
    font-size: 15px;
    transition: border-color 0.2s ease;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007aff;
}

.form-group textarea { 
    height: 120px; 
    resize: none; 
}

.modal-actions { 
    display: flex; 
    justify-content: flex-end; 
    gap: 10px; 
    margin-top: 20px;
}

/* ===== ПАГИНАЦИЯ ===== */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px;
    flex-wrap: wrap;
}

.page-btn {
    background: var(--bg-tag);
    color: var(--text-primary);
    border: none;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 36px;
}

.page-btn:hover {
    background: var(--bg-tag-hover);
    transform: translateY(-1px);
}

.page-btn.active {
    background: #007aff;
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-btn);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 480px) {
    .app-title {
        font-size: 24px;
    }
    
    .btn-group {
        gap: 6px;
    }
    
    .mode-btn,
    .btn-primary {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .story-card {
        padding: 14px;
    }
    
    .story-title {
        font-size: 16px;
    }
    
    .theme-toggle,
    .news-btn {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }
}

@media (max-width: 360px) {
    .app-title {
        font-size: 20px;
    }
    
    .version-badge {
        font-size: 10px;
        padding: 1px 6px;
    }
    
    .btn-group {
        flex-wrap: wrap;
    }
    
    .theme-toggle,
    .news-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }
}

/* ===== ОБЩИЕ УТИЛИТЫ ===== */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mt-8 {
    margin-top: 8px;
}

.mt-12 {
    margin-top: 12px;
}

.mt-16 {
    margin-top: 16px;
}

.mb-8 {
    margin-bottom: 8px;
}

.mb-12 {
    margin-bottom: 12px;
}

.mb-16 {
    margin-bottom: 16px;
}

/* ===== АНИМАЦИИ ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ===== ДАТА ПУБЛИКАЦИИ ===== */
.story-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* В темной теме */
[data-theme="dark"] .story-date {
    color: var(--text-muted);
}

/* ===== КАРТОЧКИ КОММЕНТАРИЕВ ===== */
.comment-card-item {
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-card);
    transition: all 0.2s ease;
    cursor: pointer;
}

.comment-card-item:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

.comment-card-item:active {
    transform: scale(0.99);
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .comment-card-item {
        padding: 12px 14px;
    }
    
    .comment-card-item .comment-author {
        font-size: 13px;
    }
    
    .comment-card-item .comment-text {
        font-size: 13px;
    }
}