/* --- Global Hidden States (Desktop) --- */
.sb-quick-links,
#mobile_search {
    display: none !important;
}

/* --- Mobile Header Premium Fix --- */
@media screen and (max-width: 991px) {

    html body #header,
    html body #header.fixed {
        background: rgba(32, 31, 49, 0.98) !important;
        /* Premium dark background matching home.html */
        height: 60px !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        box-shadow: none !important;
        border: none !important;
    }

    #header .container {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        height: 60px !important;
        padding: 0 15px !important;
        max-width: 100% !important;
    }

    /* Hide desktop-only elements */
    .header-group,
    .header-setting,
    .hs-toggles,
    .anw-group,
    #logo .clearfix,
    #pop-anime {
        display: none !important;
    }

    /* Show Login Button on Mobile */
    #guest-actions .btn-login {
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 6px 15px !important;
        font-size: 13px !important;
        height: 32px !important;
        border-radius: 8px !important;
        background: #1e90ff !important;
        box-shadow: 0 4px 12px rgba(30, 144, 255, 0.2) !important;
    }

    /* Search bar hidden by default on mobile, shown when active */
    /* Search bar area on mobile */
    html body #search {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10px 15px !important;
        z-index: 1001;
    }

    html body #search.active {
        display: block !important;
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            transform: translateY(-10px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    #search .search-content {
        margin: 0 !important;
    }

    #search .search-input {
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        color: #fff !important;
        height: 44px !important;
        border-radius: 12px !important;
        padding: 0 15px !important;
    }

    /* Full-width Search Suggestions - Aligned under search bar */
    #search-suggest {
        position: fixed !important;
        top: 124px !important;
        /* Header (60px) + Search Height (64px) = 124px */
        left: 0 !important;
        width: 100vw !important;
        margin: 0 !important;
        background: #1a1927 !important;
        border-radius: 0 !important;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4) !important;
        max-height: calc(100vh - 124px) !important;
        overflow-y: auto !important;
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
        z-index: 1000 !important;
    }

    #search-suggest .result {
        padding: 10px 0 !important;
    }

    #search-suggest .item {
        padding: 12px 15px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    }

    /* Side menu icon */
    #mobile_menu {
        display: block !important;
        margin: 0 !important;
        color: #fff !important;
        font-size: 22px !important;
        cursor: pointer;
        order: 1;
    }

    /* Logo adjustment */
    #logo {
        margin: 0 !important;
        order: 2;
        flex-grow: 1;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        /* Center logo between menus */
    }

    #logo img {
        height: 30px !important;
        width: auto !important;
    }

    /* Right side icons container */
    #header_right {
        display: flex !important;
        align-items: center !important;
        gap: 15px !important;
        order: 4;
        /* Move to the far right */
        height: 100% !important;
    }

    /* Mobile Search Icon */
    #mobile_search {
        display: block !important;
        color: #fff !important;
        font-size: 18px !important;
        cursor: pointer;
        transition: color 0.2s;
        order: 3;
        /* Position before notification/profile but after logo */
        margin-left: auto !important;
        /* Push logo to center by taking up space on the right */
        margin-right: 10px !important;
        /* Space between search and bell */
    }

    #mobile_search:hover {
        color: #1e90ff !important;
    }

    /* Notification Bell */
    .btn-notifications {
        width: 32px !important;
        height: 32px !important;
        font-size: 18px !important;
        margin: 0 !important;
        color: #fff !important;
    }

    .noti-count {
        width: 14px !important;
        height: 14px !important;
        line-height: 12px !important;
        font-size: 9px !important;
        top: 0 !important;
        right: 0 !important;
        border: 1px solid #201f31 !important;
    }

    /* Profile Avatar */
    .header-profile {
        margin: 0 !important;
    }

    .header-profile img {
        width: 30px !important;
        height: 30px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }

    /* --- Sidebar Premium Fixes --- */
    #sidebar_menu {
        background: rgba(255, 255, 255, .1) !important;
        /* Premium Sidebar Background */
        padding: 20px 0 !important;
    }

    /* Simple Close Button (Matches image) */
    #sidebar_menu .toggle-sidebar {
        background: transparent !important;
        border: none !important;
        color: #fff !important;
        font-size: 16px !important;
        font-weight: 500 !important;
        padding: 10px 20px !important;
        text-align: left !important;
        width: 100% !important;
        display: block !important;
        margin-bottom: 15px !important;
        box-shadow: none !important;
    }

    /* Quick Links Container (Random & Community) */
    .sb-quick-links {
        display: flex !important;
        gap: 12px !important;
        padding: 0 15px 15px !important;
    }

    .sb-quick-links .btn-quick {
        flex: 1 !important;
        background: rgba(255, 255, 255, 0.08) !important;
        color: #fff !important;
        border-radius: 16px !important;
        padding: 12px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        text-align: center !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        transition: all 0.2s;
    }

    .sb-quick-links .btn-quick:hover {
        background: rgba(30, 144, 255, 0.2) !important;
        border-color: #1e90ff !important;
    }

    /* News Button Styling */
    .sb-donate {
        padding: 0 15px 20px !important;
        margin: 0 !important;
    }

    .hr-community {
        margin: 0 !important;
    }

    .hr-community .btn-sm {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #1e90ff !important;
        border: 1px solid rgba(30, 144, 255, 0.3) !important;
        padding: 6px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        transition: all 0.2s;
    }

    .hr-community .btn-sm:hover {
        background: #1e90ff !important;
        color: #fff !important;
    }

    /* Hide redundant desktop sidebar elements on mobile */
    .sb-setting {
        display: none !important;
    }

    /* --- Footer Premium Mobile Fix --- */
    #footer {
        position: relative !important;
        padding-top: 20px !important;
    }

    .footer-top {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 0 !important;
        margin-bottom: 20px !important;
    }

    .footer-joingroup {
        width: 100% !important;
        margin: 0 !important;
        float: none !important;
    }

    .footer-joingroup .anw-group {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .footer-joingroup .zrg-title {
        display: none !important;
        /* Cleaner look focusing on icons */
    }

    .footer-joingroup .zrg-list {
        display: flex !important;
        gap: 10px !important;
        height: auto !important;
    }

    .footer-logo {
        display: none !important;
    }



    .footer-az {
        text-align: center !important;
    }

    .footer-az .az-list {
        justify-content: center !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 3px !important;
        /* Tighter gap */
        margin-bottom: 10px !important;
    }

    .footer-links {
        text-align: center !important;
    }

    .footer-links .ulclear {
        display: flex !important;
        justify-content: center !important;
        gap: 10px !important;
        /* Tighter gap */
        margin-bottom: 10px !important;
    }

    .about-text,
    .copyright {
        text-align: center !important;
        padding: 0 15px !important;
    }

    .schedule-date-nav {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        /* Enable smooth momentum scroll on mobile */
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        gap: 10px !important;
        padding-bottom: 15px !important;
        flex-wrap: nowrap !important;
        /* Prevent buttons from wrapping to next line */
    }

    .schedule-date-nav::-webkit-scrollbar {
        display: none !important;
    }

    .schedule-area .block_area-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        margin-bottom: 25px !important;
        /* Increased space to prevent overlap */
        border: none !important;
    }

    .schedule-area .bah-heading {
        display: none !important;
        /* Hide Estimated Schedule text */
    }

    .schedule-area .float-right {
        float: none !important;
        margin: 0 !important;
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .schedule-date-btn {
        min-width: 90px !important;
        padding: 8px 5px !important;
    }

    .schedule-date-btn .day {
        font-size: 14px !important;
    }

    .schedule-date-btn .date {
        font-size: 10px !important;
    }

    .schedule-item {
        padding: 10px !important;
        gap: 8px !important;
    }

    .sch-time {
        width: 50px !important;
        font-size: 12px !important;
    }

    .sch-info {
        padding: 0 !important;
    }

    .sch-title {
        font-size: 13px !important;
    }

    .sch-ep {
        width: 70px !important;
        font-size: 11px !important;
    }

    /* --- Watch Page Mobile Relative Fix (Refined) --- */
    .layout-page-watchtv {
        padding-top: 5px !important;
    }

    .layout-page-watchtv #main-wrapper {
        margin-top: 0 !important;
    }

    .layout-page-watchtv .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
        max-width: 100% !important;
    }

    .layout-page-watchtv .anis-watch-tv {
        margin: 0 -15px !important;
        padding: 0 !important;
        background: #201f31 !important;
        border: none !important;
    }

    .layout-page-watchtv .player-frame {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9 !important;
    }

    .layout-page-watchtv .player-controls {
        background: #201f31 !important;
        padding: 12px 15px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    }

    .player-controls .pc-resize {
        display: none !important;
    }

    .player-controls .pc-right {
        float: none !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        gap: 5px !important;
    }

    .player-controls .pc-item {
        margin: 0 !important;
    }

    .player-controls .btn-sm {
        background: transparent !important;
        border: none !important;
        padding: 8px 5px !important;
        font-size: 13px !important;
        color: #fff !important;
        font-weight: 500 !important;
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
    }

    .player-controls .btn-sm i {
        font-size: 16px !important;
    }

    .layout-page-watchtv .player-servers {
        padding: 15px !important;
        background: #201f31 !important;
        margin: 0 -15px !important;
        border-radius: 0 !important;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.05) !important;
    }

    .player-servers #servers-content {
        flex-direction: column !important;
        gap: 15px !important;
    }

    .ps_-block {
        margin-bottom: 12px !important;
    }

    .ps_-block:last-child {
        margin-bottom: 0 !important;
    }

    .ps_-info {
        max-width: 100% !important;
        width: 100% !important;
        margin-right: 0 !important;
        padding: 15px 18px !important;
        background: rgba(255, 255, 255, 0.04) !important;
        border-left: 4px solid #1e90ff !important;
        border-radius: 12px !important;
        min-width: auto !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
    }

    .ps_-info .ep-num {
        font-size: 17px !important;
        margin-bottom: 5px !important;
        font-weight: 700 !important;
        color: #fff !important;
    }

    .ps_-info .info-text {
        font-size: 12px !important;
        margin-bottom: 4px !important;
        color: #1e90ff !important;
        font-weight: 500 !important;
    }

    .ps_-info .server-notice {
        font-size: 11px !important;
        opacity: 0.8 !important;
    }

    .ps__-title {
        min-width: 65px !important;
        font-size: 11px !important;
        color: #888 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.8px !important;
        font-weight: 600 !important;
    }

    .ps__-list {
        gap: 8px !important;
    }

    .server-item {
        padding: 7px 15px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
        min-width: auto !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
    }

    .server-item.active {
        background: #1e90ff !important;
        color: #000 !important;
        border-color: #1e90ff !important;
        font-weight: 600 !important;
    }

    .schedule-alert {
        margin: 15px -15px 0 -15px !important;
    }

    .schedule-alert .alert {
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 15px 20px !important;
        font-size: 13px !important;
        border: none !important;
        background: #0088cc !important;
    }

    .layout-page-watchtv #episodes-content {
        margin-top: 25px !important;
    }

    .ep-header {
        padding: 15px 20px !important;
        background: rgba(255, 255, 255, 0.04) !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        border-bottom: none !important;
    }

    .ep-header .title {
        font-size: 15px !important;
        font-weight: 600 !important;
    }

    .ep-search {
        max-width: 100px !important;
    }

    .ep-search input {
        padding: 6px 12px !important;
        border-radius: 8px !important;
        font-size: 12px !important;
    }

    .episodes-list-container {
        height: 380px !important;
        border-radius: 0 0 12px 12px !important;
        background: #1a1b24 !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        border-top: none !important;
    }

    .ssl-item-ep {
        padding: 14px 20px !important;
        font-size: 14px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    }

    .ssl-item-ep:last-child {
        border-bottom: none !important;
    }

    .anis-watch-detail {
        margin: 20px 0 !important;
        position: relative !important;
        z-index: 1 !important;
    }

    .anis-watch-detail .anis-content {
        display: block !important;
        text-align: center !important;
        padding: 0 !important;
        position: relative !important;
    }

    .anis-watch-detail .anisc-poster {
        width: 140px !important;
        min-width: 140px !important;
        max-width: 140px !important;
        height: 210px !important;
        min-height: 210px !important;
        max-height: 210px !important;
        margin: 0 auto 20px auto !important;
        position: relative !important;
        display: block !important;
        left: auto !important;
        top: auto !important;
    }

    .anis-watch-detail .anisc-poster .film-poster {
        width: 140px !important;
        height: 210px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
        border-radius: 12px !important;
        margin: 0 !important;
        display: block !important;
        overflow: hidden !important;
    }

    .anis-watch-detail .anisc-poster .film-poster img {
        width: 140px !important;
        min-width: 140px !important;
        height: 210px !important;
        min-height: 210px !important;
        object-fit: cover !important;
        border-radius: 12px !important;
        display: block !important;
    }

    .anis-watch-detail .anisc-detail {
        width: 100% !important;
        padding: 0 15px !important;
        margin: 0 !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        display: block !important;
        text-align: center !important;
    }

    .anis-watch-detail .film-name {
        font-size: 22px !important;
        font-weight: 700 !important;
        margin-bottom: 12px !important;
        display: block !important;
        width: 100% !important;
        line-height: 1.3 !important;
        color: #fff !important;
        text-align: center !important;
    }

    .anis-watch-detail .film-stats {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        margin-bottom: 15px !important;
        width: 100% !important;
        color: #aaa !important;
    }

    /* Vote Logic Fix - Preventing Overlap */
    .dt-rate {
        margin: 20px 0 !important;
        width: 100% !important;
        position: relative !important;
        display: block !important;
    }

    #vote-info {
        position: relative !important;
        width: 100% !important;
        display: block !important;
    }

    .vote-box-container {
        position: relative !important;
        width: 100% !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 12px !important;
        padding: 15px !important;
        margin: 0 !important;
        display: block !important;
        box-shadow: none !important;
    }

    .vote-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 15px !important;
    }

    .vote-options {
        display: flex !important;
        gap: 8px !important;
        width: 100% !important;
        position: relative !important;
    }

    .vote-option {
        flex: 1 !important;
        padding: 10px 5px !important;
        background: #2a2b32 !important;
        border-radius: 8px !important;
        text-align: center !important;
    }

    .anis-watch-detail .dt-comment {
        display: none !important;
    }

    .anis-cover-wrap {
        display: none !important;
    }

    .film-description.m-hide {
        display: none !important;
    }

    /* --- Comments Section Mobile Fix --- */
    .block_area-comment {
        padding: 0 !important;
        margin-top: 30px !important;
    }

    .comment-tree-item {
        gap: 10px !important;
        margin-bottom: 20px !important;
    }

    .c-avatar-container {
        width: 35px !important;
        /* Fixed width container for avatar */
        max-width: 35px !important;
        min-width: 35px !important;
    }

    .c-avatar {
        width: 35px !important;
        height: 35px !important;
    }

    .c-meta {
        display: flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        margin-bottom: 6px !important;
    }

    .c-author {
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    .c-time {
        font-size: 11px !important;
        width: auto !important;
        color: #777 !important;
        white-space: nowrap !important;
    }

    .role-badge {
        font-size: 9px !important;
        padding: 1px 4px !important;
    }

    .c-text {
        font-size: 13px !important;
        line-height: 1.4 !important;
        word-break: break-word !important;
    }

    .c-actions {
        gap: 12px !important;
        margin-top: 8px !important;
    }

    .ca-btn {
        font-size: 11px !important;
    }

    .ca-btn i {
        font-size: 12px !important;
    }

    /* Decrease indentation for replies on mobile to save space */
    .comment-replies-container {
        margin-left: 15px !important;
        padding-left: 12px !important;
        margin-top: 15px !important;
    }

    .new-cm-box {
        padding: 15px !important;
        border-radius: 12px !important;
    }

    .cm-textarea-styled {
        font-size: 13px !important;
        min-height: 80px !important;
    }

    .cm-header-user {
        margin-bottom: 12px !important;
        font-size: 13px !important;
    }

    .cm-avatar-img {
        width: 30px !important;
        height: 30px !important;
    }

    .cm-footer-controls {
        flex-direction: row !important;
        /* Keep buttons side by side if possible */
        justify-content: space-between !important;
        align-items: center !important;
    }

    .cm-actions-right {
        gap: 8px !important;
    }

    .cm-btn-submit,
    .cm-btn-close {
        padding: 6px 15px !important;
        font-size: 12px !important;
    }

    /* Stack Sidebar for mobile */
    #main-content,
    #main-sidebar {
        width: 100% !important;
        float: none !important;
        padding: 0 !important;
    }

    #main-sidebar {
        margin-top: 40px !important;
    }
}