/* =====================================================
   KiniJani.com - Complete Responsive CSS
   Mobile & Tablet Optimized
   ===================================================== */

/* ===== MOBILE FIRST - Base Styles ===== */

/* Reset viewport issues */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    min-width: 320px;
}

/* Container responsive */
.container {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin: 0 auto;
}

/* Images responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== MOBILE STYLES (< 576px) ===== */
@media (max-width: 575.98px) {
    /* Typography */
    body {
        font-size: 14px;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.15rem; }
    h4 { font-size: 1rem; }
    
    /* Top Bar - Hide on mobile */
    .top-bar {
        display: none;
    }
    
    /* Header */
    .header-main {
        padding: 10px 0;
    }
    
    .logo-text {
        font-size: 22px;
    }
    
    .logo img {
        max-height: 35px;
    }
    
    /* Hide desktop search */
    .header-main .col-lg-6 {
        display: none;
    }
    
    /* Mobile menu button */
    .header-main .btn-outline-dark {
        padding: 8px 12px;
    }
    
    /* Hide LIVE button on mobile header */
    .header-main .btn-danger.d-none.d-lg-inline-flex {
        display: none !important;
    }
    
    /* Breaking News */
    .breaking-news {
        padding: 8px 0;
    }
    
    .breaking-label {
        font-size: 10px;
        padding: 4px 10px;
    }
    
    .ticker-item {
        padding: 0 20px;
        font-size: 13px;
    }
    
    /* Main Content */
    .main-content {
        padding: 15px 0;
    }
    
    /* Featured News - Stack vertically */
    .headline-section .row {
        flex-direction: column;
    }
    
    .headline-section .col-lg-8,
    .headline-section .col-lg-4 {
        width: 100%;
        max-width: 100%;
    }
    
    .featured-news {
        min-height: 200px !important;
        margin-bottom: 15px;
    }
    
    .featured-news .overlay {
        padding: 15px;
    }
    
    .featured-news h2 {
        font-size: 16px !important;
        margin-bottom: 8px;
    }
    
    .featured-news .meta {
        font-size: 11px;
    }
    
    /* News Cards */
    .news-card {
        margin-bottom: 15px;
    }
    
    .news-card .card-body {
        padding: 12px;
    }
    
    .news-card .card-title {
        font-size: 14px !important;
        line-height: 1.3;
        margin-bottom: 8px;
    }
    
    .news-card .card-text {
        font-size: 12px;
        margin-bottom: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .news-card .card-meta {
        font-size: 11px;
    }
    
    .news-card .card-meta span {
        margin-right: 10px;
    }
    
    .news-card .category-badge {
        top: 10px;
        left: 10px;
        padding: 3px 8px;
        font-size: 9px;
    }
    
    /* Section Titles */
    .section-title {
        margin-bottom: 15px;
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .section-title h2 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .section-title .view-all {
        font-size: 12px;
    }
    
    /* Grid - Single column on mobile */
    .row.g-4 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
    
    .col-md-6, .col-lg-3, .col-lg-4, .col-lg-6, .col-lg-8 {
        width: 100%;
        padding: 0;
    }
    
    /* Sidebar */
    .sidebar {
        position: relative;
        top: 0;
        margin-top: 20px;
    }
    
    .sidebar-widget {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .widget-title {
        font-size: 1rem;
        margin-bottom: 15px;
    }
    
    /* Popular News in Sidebar */
    .popular-news-item {
        padding: 10px 0;
    }
    
    .popular-news-item .number {
        width: 25px;
        height: 25px;
        font-size: 12px;
    }
    
    .popular-news-item h4 {
        font-size: 13px;
    }
    
    /* Tags Cloud */
    .tags-cloud .tag {
        font-size: 11px;
        padding: 4px 10px;
        margin: 3px;
    }
    
    /* Article Page */
    .article-detail {
        padding: 0;
    }
    
    .article-header h1 {
        font-size: 1.3rem !important;
        line-height: 1.3;
    }
    
    .article-meta {
        font-size: 11px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .article-meta span {
        margin-right: 0 !important;
    }
    
    .article-featured-image {
        margin: 0 -15px 20px;
        border-radius: 0;
    }
    
    .article-content {
        font-size: 15px;
        line-height: 1.7;
    }
    
    .article-content p {
        margin-bottom: 1rem;
    }
    
    .article-content img {
        margin: 15px -15px;
        max-width: calc(100% + 30px);
        width: calc(100% + 30px);
    }
    
    /* Share Buttons */
    .share-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .share-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    /* Author Box */
    .author-box {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    .author-box .avatar {
        width: 60px;
        height: 60px;
        margin-bottom: 15px;
    }
    
    /* Comments */
    .comment-form .row {
        flex-direction: column;
    }
    
    .comment-form .col-md-6 {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .comment-item {
        flex-direction: column;
    }
    
    .comment-item .avatar {
        margin-bottom: 10px;
    }
    
    /* Category Page */
    .category-header {
        padding: 20px !important;
    }
    
    .category-header h1 {
        font-size: 1.3rem;
    }
    
    /* Live Streaming */
    .player-container {
        border-radius: 0;
        margin: 0 -15px;
    }
    
    .channel-list h4 {
        font-size: 1rem;
    }
    
    .list-group-item {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* Search Page */
    .search-result-item .row {
        flex-direction: column;
    }
    
    .search-result-item .col-md-3 {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .search-result-item .col-md-3 img {
        width: 100%;
        height: 150px;
        object-fit: cover;
    }
    
    /* Footer */
    .footer {
        padding-top: 30px;
    }
    
    .footer .row > div {
        margin-bottom: 25px;
    }
    
    .footer h4 {
        font-size: 1rem;
        margin-bottom: 15px;
    }
    
    .footer-news-item {
        gap: 10px;
    }
    
    .footer-news-item img {
        width: 60px;
        height: 45px;
    }
    
    .footer-news-item h5 {
        font-size: 13px;
    }
    
    .newsletter-box {
        padding: 20px;
    }
    
    .newsletter-box h3 {
        font-size: 1.1rem;
    }
    
    .footer-bottom {
        text-align: center;
    }
    
    .footer-bottom .row > div {
        width: 100%;
        text-align: center !important;
        margin-bottom: 10px;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination .page-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    /* Breadcrumb */
    .breadcrumb-wrap {
        padding: 10px 0;
        margin-bottom: 15px;
    }
    
    .breadcrumb {
        font-size: 12px;
    }
    
    .breadcrumb-item + .breadcrumb-item::before {
        padding: 0 5px;
    }
    
    /* Back to Top */
    .back-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Offcanvas Mobile Menu */
    .offcanvas {
        max-width: 280px;
    }
    
    .offcanvas-body .nav-link {
        padding: 12px 0;
        border-bottom: 1px solid #eee;
    }
}

/* ===== TABLET STYLES (576px - 991px) ===== */
@media (min-width: 576px) and (max-width: 991.98px) {
    .container {
        max-width: 720px;
    }
    
    /* Top Bar */
    .top-bar {
        font-size: 12px;
    }
    
    /* Header */
    .header-main {
        padding: 12px 0;
    }
    
    .logo-text {
        font-size: 26px;
    }
    
    /* Navigation - Scroll horizontal on tablet */
    .main-nav .navbar-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .main-nav .nav-link {
        white-space: nowrap;
        padding: 12px 14px !important;
        font-size: 13px !important;
    }
    
    /* Featured News */
    .featured-news {
        min-height: 280px !important;
    }
    
    .featured-news h2 {
        font-size: 20px !important;
    }
    
    /* News Cards - 2 columns */
    .col-md-6 {
        width: 50%;
        flex: 0 0 50%;
    }
    
    .col-lg-3 {
        width: 50%;
        flex: 0 0 50%;
    }
    
    .news-card .card-title {
        font-size: 15px;
    }
    
    /* Sidebar - Full width on tablet */
    .col-lg-4.sidebar-col {
        width: 100%;
        flex: 0 0 100%;
    }
    
    .sidebar {
        position: relative;
        top: 0;
    }
    
    .sidebar-widget {
        padding: 20px;
    }
    
    /* Article */
    .article-header h1 {
        font-size: 1.6rem;
    }
    
    .article-content {
        font-size: 16px;
    }
    
    /* Footer */
    .footer .col-lg-4,
    .footer .col-lg-2 {
        width: 50%;
        flex: 0 0 50%;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-width: 767.98px) and (orientation: landscape) {
    .featured-news {
        min-height: 250px !important;
    }
    
    .headline-section .col-lg-8 {
        width: 60%;
    }
    
    .headline-section .col-lg-4 {
        width: 40%;
    }
    
    .headline-section .row {
        flex-direction: row;
    }
}

/* ===== DESKTOP STYLES (992px+) ===== */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    /* Ensure sidebar sticky works */
    .sidebar {
        position: sticky;
        top: 100px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .nav-link,
    .btn,
    .page-link,
    .list-group-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Remove hover effects */
    .news-card:hover {
        transform: none;
    }
    
    .news-card:hover .card-img-wrap img {
        transform: none;
    }
    
    /* Better tap feedback */
    .news-card:active {
        transform: scale(0.98);
    }
}

/* ===== HIGH DPI / RETINA DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ===== SAFE AREA (iPhone X and newer) ===== */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .footer {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .back-to-top {
        bottom: max(15px, env(safe-area-inset-bottom));
        right: max(15px, env(safe-area-inset-right));
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .top-bar,
    .header,
    .main-nav,
    .breaking-news,
    .sidebar,
    .footer,
    .share-buttons,
    .comment-form,
    .related-news,
    .back-to-top,
    .breadcrumb-wrap {
        display: none !important;
    }
    
    .col-lg-8 {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .article-content {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 10pt;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .ticker {
        animation: none;
    }
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== UTILITY CLASSES FOR RESPONSIVE ===== */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 767.98px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}

/* Text truncation */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
