/* Responsive styles for all pages */

/* Base responsive utilities */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
}

/* Typography responsive */
@media (max-width: 768px) {
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.3rem; }
    h4 { font-size: 1.1rem; }
    
    body {
        font-size: 14px;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.2rem; }
    
    body {
        font-size: 13px;
    }
}

/* Grid responsive */
.manga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

@media (max-width: 1024px) {
    .manga-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 18px;
    }
}

@media (max-width: 768px) {
    .manga-grid {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding: 0 0 8px 0;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(var(--accent-rgb), 0.5) transparent;
    }
    
    .manga-grid::-webkit-scrollbar {
        height: 6px;
    }
    
    .manga-grid::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 3px;
    }
    
    .manga-grid::-webkit-scrollbar-thumb {
        background: rgba(var(--accent-rgb), 0.6);
        border-radius: 3px;
    }
    
    .manga-grid::-webkit-scrollbar-thumb:hover {
        background: rgba(var(--accent-rgb), 0.8);
    }
    
    .manga-grid .manga-card {
        flex: 0 0 130px;
        scroll-snap-align: start;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        overflow: hidden;
        transition: transform 0.2s, box-shadow 0.2s;
    }
    
    .manga-grid .manga-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

@media (max-width: 480px) {
    .manga-grid .manga-card {
        flex: 0 0 110px;
    }
    
    .manga-grid {
        gap: 10px;
    }
}

/* Buttons responsive */
.btn-primary,
.btn-outline {
    padding: 12px 24px;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

@media (max-width: 768px) {
    .btn-primary,
    .btn-outline {
        padding: 10px 20px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .btn-primary,
    .btn-outline {
        padding: 8px 16px;
        font-size: 12px;
        width: 100%;
        text-align: center;
    }
}

/* Forms responsive */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #f5f7f6;
    font-size: 14px;
}

@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        padding: 10px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Tables responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

@media (max-width: 768px) {
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 8px 4px;
    }
}

/* Modal responsive */
.modal__content {
    max-width: 90vw;
    max-height: 90vh;
    margin: 20px;
}

@media (max-width: 768px) {
    .modal__content {
        max-width: 95vw;
        margin: 10px;
    }
}

/* Sidebar responsive */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr 250px;
        gap: 30px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .sidebar {
        order: 2; /* Сайдбар после основного контента на мобильных */
    }
}

/* Cards responsive */
.manga-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.manga-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .manga-card:hover {
        transform: none;
    }
}

.manga-card-cover {
    aspect-ratio: 3/4;
    overflow: hidden;
    position: relative;
}

.manga-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.manga-card:hover .manga-card-cover img {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .manga-card:hover .manga-card-cover img {
        transform: none;
    }
}

.manga-card-body {
    padding: 12px;
}

@media (max-width: 768px) {
    .manga-card-body {
        padding: 8px;
    }
    
    .manga-card-cover {
        aspect-ratio: 3/4;
        overflow: hidden;
        position: relative;
    }
    
    .manga-card-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .manga-card-title {
        font-size: 12px;
        line-height: 1.3;
        margin-bottom: 4px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .manga-card-meta {
        font-size: 10px;
        opacity: 0.7;
        margin-bottom: 6px;
    }
    
    .manga-card .btn-outline {
        font-size: 11px;
        padding: 4px 8px;
        border-radius: 4px;
    }
}

.manga-card-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .manga-card-title {
        font-size: 12px;
        margin-bottom: 6px;
    }
}

/* Comments responsive */
.manga-comment-item {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .manga-comment-item {
        gap: 8px;
        padding: 12px 0;
    }
}

.manga-comment-item__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .manga-comment-item__avatar {
        width: 36px;
        height: 36px;
    }
}

/* Chapters list responsive */
.chapter-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .chapter-item {
        gap: 8px;
        padding: 8px 0;
    }
}

.chapter-cover {
    width: 60px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .chapter-cover {
        width: 48px;
        height: 64px;
    }
}

/* Hero section responsive */
.hero-slider {
    position: relative;
    height: 500px;
    overflow: hidden;
    border-radius: 16px;
}

@media (max-width: 1024px) {
    .hero-slider {
        height: 400px;
    }
}

@media (max-width: 768px) {
    .hero-slider {
        height: 280px;
        border-radius: 12px;
        margin-top: 0; /* Отступ уже в site-main */
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .hero-slider {
        height: 240px;
        border-radius: 8px;
    }
}

.hero-inner {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 40px;
    align-items: center;
    height: 100%;
    padding: 20px;
}

@media (max-width: 1024px) {
    .hero-inner {
        grid-template-columns: 160px 1fr;
        gap: 30px;
    }
}

@media (max-width: 768px) {
    .hero-inner {
        display: flex;
        gap: 12px;
        padding: 16px;
        text-align: left;
        height: 100%;
        align-items: flex-start;
    }
    
    .hero-cover {
        flex-shrink: 0;
        width: 80px;
    }
    
    .hero-cover img {
        width: 80px;
        height: 110px;
        object-fit: cover;
        border-radius: 6px;
    }
    
    .hero-content {
        flex: 1;
        min-width: 0;
    }
    
    .hero-title {
        font-size: 1.2rem !important;
        margin-bottom: 8px !important;
        line-height: 1.3;
    }
    
    .hero-description {
        font-size: 13px !important;
        margin-bottom: 12px !important;
        display: -webkit-box;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .hero-tags {
        margin-bottom: 8px !important;
    }
    
    .hero-tags .chip {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
}

@media (max-width: 480px) {
    .hero-inner {
        padding: 12px;
        gap: 12px;
    }
    
    .hero-cover {
        width: 80px;
    }
    
    .hero-cover img {
        width: 80px;
        height: 112px;
    }
}

/* Hero content responsive */
.hero-title {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 1.8rem;
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
}

.hero-description {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 24px;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .hero-description {
        font-size: 14px;
        margin-bottom: 16px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    .hero-description {
        font-size: 13px;
        margin-bottom: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

.btn-primary.btn-long {
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .btn-primary.btn-long {
        padding: 10px 20px;
        font-size: 14px;
        margin-bottom: 12px;
        display: inline-block;
        width: auto;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .btn-primary.btn-long {
        padding: 10px 20px;
        font-size: 14px;
        margin-bottom: 12px;
    }
}

.hero-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

@media (max-width: 768px) {
    .hero-stats-row {
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .hero-stat {
        font-size: 11px;
    }
    
    .hero-stat .label {
        font-size: 10px;
        opacity: 0.7;
    }
    
    .hero-stat .value {
        font-size: 11px;
        font-weight: 600;
    }
}

@media (max-width: 480px) {
    .hero-stats-row {
        gap: 8px;
        font-size: 12px;
    }
}

.hero-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

@media (max-width: 480px) {
    .hero-stat {
        gap: 2px;
    }
}

.hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .hero-tags {
        justify-content: center;
        margin-bottom: 12px;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .hero-tags {
        margin-bottom: 8px;
        gap: 4px;
    }
}

.chip.chip-genre {
    font-size: 12px;
    padding: 4px 8px;
}

@media (max-width: 480px) {
    .chip.chip-genre {
        font-size: 11px;
        padding: 3px 6px;
    }
}

/* Hero navigation responsive */
.hero-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .hero-nav {
        margin-top: 12px;
        margin-bottom: 20px;
        gap: 12px;
        position: relative;
        background: rgba(0, 0, 0, 0.3);
        padding: 8px 12px;
        border-radius: 20px;
        backdrop-filter: blur(10px);
        justify-content: center;
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 480px) {
    .hero-nav {
        margin-top: 8px;
        margin-bottom: 16px;
        gap: 8px;
    }
}

.hero-arrow {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f5f7f6;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.hero-arrow:hover {
    background: rgba(var(--accent-rgb), 0.2);
    border-color: rgba(var(--accent-rgb), 0.4);
    color: #79ff6b;
}

@media (max-width: 768px) {
    .hero-arrow {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .hero-arrow {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

.hero-dots {
    display: flex;
    gap: 8px;
}

.hero-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.hero-dot.is-active {
    background: #79ff6b;
    transform: scale(1.2);
}

@media (max-width: 768px) {
    .hero-dots {
        gap: 6px;
    }
    
    .hero-dot {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 480px) {
    .hero-dot {
        width: 8px;
        height: 8px;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .manga-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    .manga-card:hover .manga-card-cover img {
        transform: none;
    }
    
    button,
    .btn-primary,
    .btn-outline,
    a {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Жанры на планшетах и мобильных */
@media (max-width: 1024px) {
    .genres-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
    
    .genre-card {
        padding: 12px 10px;
        min-height: 130px;
    }
    
    .genre-card__icon {
        width: 40px;
        height: 40px;
        margin-bottom: 8px;
    }
    
    .genre-card__name {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .genres-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .genre-card {
        padding: 10px 8px;
        min-height: 120px;
    }
    
    .genre-card__icon {
        width: 36px;
        height: 36px;
        margin-bottom: 6px;
    }
    
    .genre-card__name {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .genre-card__count {
        font-size: 10px;
        padding: 1px 6px;
    }
}

@media (max-width: 480px) {
    .genres-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 6px;
    }
    
    .genre-card {
        padding: 8px 6px;
        min-height: 110px;
    }
    
    .genre-card__icon {
        width: 32px;
        height: 32px;
        margin-bottom: 4px;
    }
    
    .genre-card__name {
        font-size: 10px;
    }
    
    .genre-card__count {
        font-size: 9px;
    }
}

/* Обновления на мобильных */
@media (max-width: 768px) {
    .recent-updates-list {
        gap: 6px;
    }
    
    .update-item {
        padding: 8px 10px;
        gap: 3px;
    }
    
    .update-manga-title {
        font-size: 12px;
    }
    
    .update-date {
        font-size: 10px;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile slider indicators and improvements */
@media (max-width: 768px) {
    .block-grid {
        position: relative;
        margin-bottom: 24px;
    }
    
    .block-grid .manga-grid {
        padding-left: 16px;
        padding-right: 16px;
        margin-left: -16px;
        margin-right: -16px;
    }
    
    .block-grid::after {
        content: '';
        position: absolute;
        bottom: 8px;
        right: 20px;
        width: 40px;
        height: 3px;
        background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.4));
        border-radius: 2px;
        pointer-events: none;
    }
    
    .block-header {
        margin-bottom: 16px;
        padding: 0 16px;
    }
    
    .block-header h2 {
        font-size: 1.4rem;
        font-weight: 600;
        color: #f5f7f6;
    }
}

/* Social buttons fix */
.social-btn {
    color: #f5f7f6 !important;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-size: 12px;
}

.social-btn:hover {
    background: rgba(var(--accent-rgb), 0.2);
    border-color: rgba(var(--accent-rgb), 0.4);
    color: #79ff6b !important;
}

.social-btn svg {
    fill: currentColor;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .manga-card {
        border: 2px solid currentColor;
    }
    
    button,
    .btn-primary,
    .btn-outline {
        border: 2px solid currentColor;
    }
}

/* Mobile search bar fix */
@media (max-width: 768px) {
    .mobile-search-bar {
        width: 100%;
        overflow: hidden;
    }
    
    .mobile-search-form {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .mobile-search-input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Mobile content spacing */
@media (max-width: 768px) {
    .hmanhwa-page {
        padding-bottom: 80px; /* Space for mobile bottom nav */
        padding-top: 70px; /* Space for mobile search bar */
        width: 100%;
        overflow-x: hidden;
    }
    
    .hmanhwa-main {
        padding-top: 0;
    }
    
    .site-main {
        padding-top: 70px;
        padding-bottom: 80px;
    }
    
    .block {
        margin-bottom: 32px;
    }
    
    .block-header h2 {
        font-size: 1.5rem;
        margin-bottom: 16px;
    }
    
    /* Make sidebar sections stack on mobile */
    .sidebar .block {
        margin-bottom: 24px;
    }
    
    /* Improve chapter list on mobile */
    .chapter-item {
        padding: 12px 0;
        gap: 12px;
    }
    
    .chapter-cover {
        width: 50px;
        height: 70px;
    }
    
    .chapter-title {
        font-size: 14px;
        line-height: 1.4;
    }
    
    .chapter-meta {
        font-size: 12px;
        opacity: 0.7;
    }
}

@media (max-width: 768px) {
    /* Sidebar slides from right on mobile */
    .sidebar-menu {
        width: 85% !important;
        max-width: 320px !important;
        right: -85% !important;
        left: auto !important;
    }
    
    .sidebar-menu.active {
        right: 0 !important;
    }
}

@media (max-width: 480px) {
    .hmanhwa-page {
        padding-bottom: 70px;
    }
    
    .container {
        padding: 0 12px;
    }
    
    .block {
        margin-bottom: 24px;
    }
    
    .block-header h2 {
        font-size: 1.3rem;
    }
    
    .chapter-item {
        padding: 8px 0;
        gap: 8px;
    }
    
    .chapter-cover {
        width: 40px;
        height: 56px;
    }
}