/* ============================================
   MOBILE OPTIMIZATION CSS
   Designed for WebUI News Site
   ============================================ */

/* ========== BASE MOBILE STYLES ========== */
@media (max-width: 991px) {
    /* Improved Touch Targets - Minimum 44x44px */
    .btn,
    .nav-link,
    .badge,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 12px 16px;
    }

    /* Mobile Typography */
    body {
        font-size: 16px;
        line-height: 1.6;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    h4 {
        font-size: 1.125rem !important;
    }

    /* Remove hover effects on mobile */
    * {
        -webkit-tap-highlight-color: rgba(129, 76, 158, 0.2);
    }

    /* Prevent horizontal scroll */
    html,
    body {
        overflow-x: hidden;
        width: 100%;
    }
}

/* ========== HEADER & NAVIGATION ========== */
@media (max-width: 991px) {
    /* Mobile Header */
    .container-fluid.d-none.d-lg-block {
        display: block !important;
    }

    /* Top Bar - Mobile Optimized */
    .container-fluid .row.align-items-center.bg-dark {
        flex-direction: column;
        padding: 10px 15px;
    }

    .col-lg-9,
    .col-lg-3 {
        width: 100%;
        text-align: center !important;
    }

    /* Social Icons - Larger on Mobile */
    .navbar-nav.ml-auto .nav-link {
        font-size: 20px;
        padding: 10px 15px;
    }

    /* Logo - Centered on Mobile */
    .navbar-brand h1 {
        font-size: 2rem !important;
        margin: 10px 0;
    }

    /* Hamburger Menu */
    .navbar-toggler {
        border: 2px solid #814C9E;
        padding: 10px 15px;
        border-radius: 8px;
    }

    .navbar-toggler-icon {
        width: 28px;
        height: 28px;
    }

    /* Mobile Menu */
    .navbar-collapse {
        background: #1E2024;
        margin-top: 15px;
        border-radius: 8px;
        padding: 15px;
    }

    .navbar-nav .nav-item {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin: 0;
    }

    .navbar-nav .nav-link {
        padding: 15px 10px;
        font-size: 16px;
        width: 100%;
        justify-content: flex-start;
    }

    /* Search Box - Full Width Mobile */
    .input-group.ml-auto {
        width: 100% !important;
        max-width: 100% !important;
        margin: 15px 0 0 0 !important;
    }

    .input-group .form-control {
        border-radius: 8px 0 0 8px;
        height: 48px;
        font-size: 16px;
    }

    .input-group-text {
        border-radius: 0 8px 8px 0;
        padding: 0 20px;
    }
}

/* ========== SLIDER / CAROUSEL ========== */
@media (max-width: 991px) {
    /* Main News Slider - Reduced Height */
    .position-relative.overflow-hidden {
        height: 300px !important;
    }

    .owl-carousel .img-fluid {
        object-fit: cover !important;
        height: 300px !important;
    }

    /* Slider Overlay Text */
    .overlay {
        padding: 15px !important;
    }

    .overlay .h2 {
        font-size: 1.25rem !important;
        line-height: 1.4;
    }

    .overlay .badge {
        font-size: 0.75rem;
        padding: 6px 10px !important;
    }

    /* Owl Carousel Dots */
    .owl-carousel .owl-dots {
        margin-top: 10px;
    }

    .owl-carousel .owl-dot span {
        width: 12px;
        height: 12px;
    }
}

/* ========== BREAKING NEWS ========== */
@media (max-width: 991px) {
    .container-fluid.bg-dark.py-3 {
        padding: 15px 0 !important;
    }

    .bg-primary.text-dark {
        width: 100% !important;
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .tranding-carousel {
        width: 100% !important;
        margin-left: 0 !important;
        padding-right: 0 !important;
    }

    .d-flex.justify-content-between {
        flex-direction: column !important;
    }
}

/* ========== NEWS CARDS ========== */
@media (max-width: 991px) {
    /* News Grid - Single Column */
    .col-lg-8,
    .col-lg-4 {
        padding-left: 15px;
        padding-right: 15px;
    }

    .col-lg-6 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    /* News Card Improvements */
    .position-relative.mb-3 {
        margin-bottom: 25px !important;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .position-relative.mb-3 img {
        width: 100%;
        height: 220px;
        object-fit: cover;
    }

    /* Card Content */
    .bg-white.border.p-4 {
        padding: 15px !important;
    }

    .h4.d-block {
        font-size: 1.1rem !important;
        line-height: 1.4;
        margin-bottom: 10px !important;
    }

    /* Badge & Date */
    .badge {
        font-size: 0.75rem;
        padding: 5px 10px !important;
    }

    /* Author & Views Section */
    .d-flex.justify-content-between.bg-white {
        padding: 12px 15px !important;
    }

    .rounded-circle {
        width: 35px !important;
        height: 35px !important;
    }

    small {
        font-size: 0.875rem;
    }
}

/* ========== SIDEBAR ========== */
@media (max-width: 991px) {
    .col-lg-4 {
        margin-top: 30px;
    }

    /* Category List */
    .list-group-item {
        padding: 15px;
        font-size: 16px;
    }

    /* Popular News Section */
    .d-flex.align-items-center.bg-white.mb-3 {
        height: auto !important;
        min-height: 90px;
    }

    .d-flex.align-items-center.bg-white.mb-3 img {
        width: 90px !important;
        height: 90px !important;
        object-fit: cover;
    }

    .h6.m-0 {
        font-size: 0.9rem !important;
    }
}

/* ========== NEWS DETAIL PAGE ========== */
@media (max-width: 991px) {
    /* News Detail Image */
    .position-relative.mb-3 .img-fluid {
        height: 250px;
        object-fit: cover;
    }

    /* News Title */
    .mb-3.text-secondary.text-uppercase {
        font-size: 1.5rem !important;
        line-height: 1.3;
    }

    /* News Content */
    .bg-white.border.p-4 p {
        font-size: 1rem;
        line-height: 1.7;
        text-align: justify;
    }

    /* Video Player */
    video {
        width: 100% !important;
        height: auto;
        border-radius: 8px;
    }

    /* Comments Section */
    .media {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .media img {
        margin-bottom: 10px;
        margin-right: 0 !important;
    }

    .media-body h6 {
        font-size: 0.95rem;
    }

    /* Comment Form */
    .form-row .col-sm-6 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-control {
        height: 48px;
        font-size: 16px;
        border-radius: 8px;
    }

    textarea.form-control {
        height: 120px !important;
        min-height: 120px;
    }

    .btn-primary {
        width: 100%;
        height: 50px;
        font-size: 16px;
        font-weight: 600;
        border-radius: 8px;
    }
}

/* ========== FOOTER ========== */
@media (max-width: 991px) {
    .container-fluid.py-4 {
        padding: 20px 15px !important;
        text-align: center;
    }

    .container-fluid.py-4 p {
        font-size: 14px;
    }
}

/* ========== BACK TO TOP BUTTON ========== */
@media (max-width: 991px) {
    .back-to-top {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
        font-size: 20px;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(129, 76, 158, 0.4);
    }
}

/* ========== TABLET (768px - 991px) ========== */
@media (min-width: 768px) and (max-width: 991px) {
    .col-lg-6 {
        width: 50%;
        max-width: 50%;
        flex: 0 0 50%;
    }

    .position-relative.mb-3 img {
        height: 200px;
    }
}

/* ========== SMALL MOBILE (320px - 576px) ========== */
@media (max-width: 576px) {
    /* Extra small screens */
    body {
        font-size: 14px;
    }

    .navbar-brand h1 {
        font-size: 1.75rem !important;
    }

    .section-title h4 {
        font-size: 1.1rem !important;
    }

    .position-relative.mb-3 img {
        height: 180px;
    }

    .bg-white.border.p-4 {
        padding: 12px !important;
    }

    /* Smaller buttons for very small screens */
    .btn {
        padding: 10px 14px;
        font-size: 14px;
    }
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */
@media (max-width: 991px) {
    /* Lazy loading placeholder */
    img[data-src] {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }

    @keyframes loading {
        0% {
            background-position: 200% 0;
        }
        100% {
            background-position: -200% 0;
        }
    }

    /* Reduce animations on mobile */
    * {
        animation-duration: 0.5s !important;
        transition-duration: 0.3s !important;
    }

    /* Improve scrolling performance */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========== ACCESSIBILITY ========== */
@media (max-width: 991px) {
    /* Focus states for keyboard navigation */
    a:focus,
    button:focus,
    input:focus,
    textarea:focus {
        outline: 3px solid #814C9E;
        outline-offset: 2px;
    }

    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: #814C9E;
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 100000;
    }

    .skip-to-content:focus {
        top: 0;
    }
}

/* ========== LANDSCAPE MODE ========== */
@media (max-width: 991px) and (orientation: landscape) {
    .position-relative.overflow-hidden {
        height: 250px !important;
    }

    .owl-carousel .img-fluid {
        height: 250px !important;
    }
}

/* ========== TOUCH IMPROVEMENTS ========== */
@media (max-width: 991px) {
    /* Better tap highlighting */
    a,
    button {
        -webkit-tap-highlight-color: rgba(129, 76, 158, 0.3);
        touch-action: manipulation;
    }

    /* Prevent text selection on double tap */
    .btn,
    .badge,
    .nav-link {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Smooth momentum scrolling */
    .navbar-collapse,
    .modal {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========== LOADING SPINNER ========== */
.mobile-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: none;
}

.mobile-loading.active {
    display: block;
}

.spinner {
    border: 4px solid rgba(129, 76, 158, 0.1);
    border-left-color: #814C9E;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== PULL TO REFRESH INDICATOR ========== */
.pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #814C9E;
    color: white;
    transition: top 0.3s;
    z-index: 1000;
}

.pull-to-refresh.active {
    top: 0;
}

/* ========== SWIPE GESTURES INDICATOR ========== */
.swipe-indicator {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.swipe-indicator.show {
    opacity: 1;
}
