/* ==========================================================================
   ANTARLANGITMODDER - Complete Mobile, Tablet & Desktop Responsive System
   Auto-adapts layout, typography, navigation, forms, and grids across devices
   ========================================================================== */

/* 1. Global Viewport & Box Sizing Safeguards */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden !important;
    position: relative;
    -webkit-text-size-adjust: 100%;
}

img, svg, video, canvas, audio, iframe {
    max-width: 100%;
    height: auto;
}

/* Touch-friendly base */
button, input, select, textarea, a, .clickable {
    touch-action: manipulation;
}

input, select, textarea {
    font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
}

/* 2. Fluid Containers */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ==========================================================================
   3. MOBILE DEVICES (max-width: 767px)
   ========================================================================== */
@media screen and (max-width: 767px) {
    /* Spacing for mobile bottom navigation */
    body {
        padding-bottom: 95px !important;
    }

    /* Header & Brand */
    .header {
        padding: 10px 0 !important;
    }
    
    .header-container {
        padding: 0 12px !important;
    }

    .brand-logo {
        width: 34px !important;
        height: 34px !important;
    }

    .brand-text {
        font-size: 1.05rem !important;
        letter-spacing: -0.3px !important;
    }

    .desktop-nav {
        display: none !important;
    }

    .header-actions {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .header-actions .search-container {
        display: none !important;
    }

    .hamburger {
        display: flex !important;
        width: 38px !important;
        height: 38px !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    .theme-toggle {
        width: 38px !important;
        height: 38px !important;
    }

    /* Mobile Search Bar below header */
    .mobile-search {
        display: block !important;
        padding: 8px 12px 14px 12px !important;
        width: 100% !important;
    }

    .mobile-search-input {
        width: 100% !important;
        padding: 12px 16px 12px 42px !important;
        border-radius: 12px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        color: #fff !important;
    }

    /* Side Menu Drawer */
    .side-menu {
        width: min(85vw, 300px) !important;
        max-width: 320px !important;
        padding: 20px 16px !important;
        z-index: 10002 !important;
    }

    .side-overlay {
        z-index: 10001 !important;
    }

    /* Bottom Navigation Bar */
    .bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 14px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: calc(100% - 24px) !important;
        max-width: 440px !important;
        background: rgba(11, 14, 20, 0.92) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        border-radius: 35px !important;
        padding: 8px 6px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(59, 130, 246, 0.15) !important;
        z-index: 9999 !important;
        justify-content: space-around !important;
    }

    .bottom-nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 3px !important;
        font-size: 0.72rem !important;
        font-weight: 600 !important;
        color: #94a3b8 !important;
        padding: 4px 6px !important;
        min-width: 52px !important;
        text-decoration: none !important;
        transition: all 0.2s ease !important;
    }

    .bottom-nav-item i {
        font-size: 1.15rem !important;
    }

    .bottom-nav-item.active, .bottom-nav-item:hover {
        color: #3b82f6 !important;
    }

    /* Floating Toast & Support Buttons */
    .purchase-toast {
        bottom: 85px !important;
        max-width: calc(100% - 30px) !important;
        left: 15px !important;
        right: 15px !important;
        transform: translateY(150%) !important;
    }

    .purchase-toast.active {
        transform: translateY(0) !important;
    }

    .help-fab-container {
        bottom: 85px !important;
        right: 16px !important;
    }

    /* Banner Slider */
    .banner-slide {
        aspect-ratio: 16 / 9 !important;
        border-radius: 14px !important;
        overflow: hidden !important;
    }

    .banner-slide img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    /* Bento Categories Grid */
    .bento-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        margin-top: 15px !important;
    }

    .bento-card {
        padding: 12px 6px !important;
        border-radius: 12px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    .bento-card img {
        width: 38px !important;
        height: 38px !important;
        border-radius: 8px !important;
    }

    .bento-card span {
        font-size: 0.75rem !important;
        margin-top: 6px !important;
        line-height: 1.2 !important;
    }

    /* Products Grid: 2 Columns on Mobile */
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .product-card {
        border-radius: 12px !important;
        overflow: hidden !important;
        padding: 10px !important;
    }

    .product-img {
        border-radius: 8px !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: cover !important;
    }

    .product-title {
        font-size: 0.85rem !important;
        margin: 6px 0 4px 0 !important;
        font-weight: 700 !important;
    }

    .product-price {
        font-size: 0.95rem !important;
        font-weight: 800 !important;
    }

    .product-badge {
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
    }

    /* Section Titles */
    .section-title {
        font-size: 1.2rem !important;
        margin-bottom: 12px !important;
    }

    .section-header-title {
        font-size: 1.25rem !important;
    }

    /* Features & Steps Grids */
    .features-grid, .steps-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Footer */
    .footer {
        padding: 30px 0 20px 0 !important;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
    }

    .footer-bottom {
        padding-bottom: 20px !important;
        text-align: center !important;
    }

    /* Modals & Dialogs */
    .auth-container, .promo-container, .result-modal, #logout-confirm-box, .modal-content {
        width: min(92vw, 400px) !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        margin: auto !important;
        padding: 22px 16px !important;
        border-radius: 16px !important;
    }

    .auth-title {
        font-size: 1.25rem !important;
    }

    .auth-subtitle {
        font-size: 0.8rem !important;
    }

    /* Dashboard Layout */
    .dashboard-container {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        margin: 15px auto !important;
        padding: 0 12px !important;
    }

    .dash-card {
        padding: 16px !important;
        border-radius: 14px !important;
        margin-bottom: 18px !important;
    }

    .profile-avatar {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
    }

    .profile-name {
        font-size: 1.1rem !important;
    }

    .balance-box {
        padding: 14px !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .balance-amount {
        font-size: 1.25rem !important;
    }

    .btn-topup {
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
    }

    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .action-btn {
        padding: 10px 8px !important;
        font-size: 0.8rem !important;
        gap: 8px !important;
    }

    .action-icon {
        width: 26px !important;
        height: 26px !important;
        font-size: 0.8rem !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .stat-box, .stat-grid-item {
        padding: 14px 10px !important;
    }

    .stat-number {
        font-size: 1.6rem !important;
    }

    .stat-label {
        font-size: 0.78rem !important;
    }

    /* Topup Page */
    .topup-container {
        margin: 20px auto !important;
        padding: 0 12px !important;
    }

    .page-title {
        font-size: 1.6rem !important;
    }

    .page-subtitle {
        font-size: 0.85rem !important;
        margin-bottom: 20px !important;
    }

    .section-card {
        border-radius: 14px !important;
        margin-bottom: 18px !important;
    }

    .section-header {
        padding: 12px 16px !important;
        font-size: 1rem !important;
    }

    .section-body {
        padding: 16px 12px !important;
    }

    .payment-group-header {
        padding: 10px 14px !important;
        font-size: 0.95rem !important;
    }

    .payment-group-body {
        padding: 12px 10px !important;
        gap: 8px !important;
    }

    .payment-method {
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
        min-width: 90px !important;
        flex: 1 1 calc(50% - 10px) !important;
    }

    /* Pengaturan Page */
    .settings-container, .profile-settings-card {
        padding: 16px 12px !important;
        margin: 15px auto !important;
    }

    .nav-tabs, .pengaturan-tabs {
        overflow-x: auto !important;
        white-space: nowrap !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .tab-btn {
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
        flex-shrink: 0 !important;
    }

    /* Order Pages (order_attic, order_necro, etc.) */
    body.order-page, .order-body {
        padding: 12px !important;
    }

    .order-header-bar {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 0 16px 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        margin-bottom: 18px !important;
    }

    .order-back-btn {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        background: rgba(59, 130, 246, 0.15) !important;
        color: #60a5fa !important;
        border: 1px solid rgba(59, 130, 246, 0.3) !important;
        padding: 8px 14px !important;
        border-radius: 8px !important;
        text-decoration: none !important;
        font-size: 0.85rem !important;
        font-weight: 600 !important;
    }

    .animated-title {
        font-size: 1.5rem !important;
    }

    .package-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .package-card {
        padding: 14px 10px !important;
        border-radius: 12px !important;
    }

    .pkg-title {
        font-size: 0.95rem !important;
        margin-bottom: 6px !important;
    }

    .pkg-price {
        font-size: 1.15rem !important;
    }

    .payment-body {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 14px 10px !important;
    }

    .game-tabs {
        gap: 8px !important;
    }

    .game-tab {
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
    }

    .btn-submit {
        padding: 14px !important;
        font-size: 0.95rem !important;
        letter-spacing: 0.5px !important;
    }

    /* Reset License & Cek Pesanan */
    .reset-container, .cek-container {
        margin: 20px auto 60px auto !important;
        padding: 24px 14px !important;
        border-radius: 16px !important;
    }

    .reset-header {
        flex-direction: column !important;
        text-align: center !important;
        gap: 12px !important;
    }

    .reset-title-group h1, .cek-title {
        font-size: 1.35rem !important;
    }

    .reset-title-group p, .cek-subtitle {
        font-size: 0.82rem !important;
    }

    .cek-form-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .cek-btn {
        width: 100% !important;
        padding: 14px !important;
        justify-content: center !important;
    }

    .product-grid-reset, .product-grid[style*="repeat(2"] {
        grid-template-columns: 1fr !important;
    }

    /* Panel Pages (panel_attic, etc.) */
    .panel-container {
        padding: 14px 10px !important;
        margin-top: 10px !important;
    }

    .panel-header {
        flex-direction: column !important;
        text-align: center !important;
        gap: 12px !important;
    }

    .panel-tabs {
        overflow-x: auto !important;
        white-space: nowrap !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .panel-tab {
        flex-shrink: 0 !important;
        padding: 8px 14px !important;
        font-size: 0.85rem !important;
    }

    /* Testimoni Page */
    .testimoni-hero {
        padding: 30px 14px 15px 14px !important;
    }

    .testimoni-hero h1 {
        font-size: 1.6rem !important;
    }

    .testimoni-hero p {
        font-size: 0.88rem !important;
    }

    .testimoni-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 0 12px !important;
    }

    /* Tentang Page */
    .profile-card {
        flex-direction: column !important;
        text-align: center !important;
    }

    /* Universal Tables on Mobile */
    .table-responsive,
    .table-container,
    div[style*="overflow-x: auto"] {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 15px !important;
        border-radius: 8px !important;
    }

    table {
        min-width: 500px !important;
        font-size: 0.82rem !important;
    }

    th, td {
        padding: 8px 10px !important;
    }
}

/* ==========================================================================
   4. TABLET DEVICES (min-width: 768px) and (max-width: 1024px)
   ========================================================================== */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    /* Safe container */
    .container {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Header: Show Hamburger & Clean Tablet Nav */
    .header-container {
        padding: 0 20px !important;
    }

    /* Hide crowded 7-item nav on tablet to prevent multi-line break/overflow */
    .desktop-nav {
        display: none !important;
    }

    .hamburger {
        display: flex !important;
        width: 42px !important;
        height: 42px !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        cursor: pointer !important;
    }

    .header-actions {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }

    .header-actions .search-container {
        display: flex !important;
    }

    .search-input {
        width: 180px !important;
    }

    .search-input:focus {
        width: 220px !important;
    }

    /* Hide mobile bottom nav on tablets if drawer is active */
    .bottom-nav {
        display: none !important;
    }

    body {
        padding-bottom: 30px !important;
    }

    /* Banner Slider */
    .banner-slide {
        aspect-ratio: 18 / 9 !important;
    }

    /* Bento Grid */
    .bento-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
        gap: 14px !important;
    }

    /* Product Grid */
    .product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 18px !important;
    }

    /* Features & Steps */
    .features-grid, .steps-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 18px !important;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
    }

    /* Dashboard */
    .dashboard-container {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
        padding: 0 20px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 14px !important;
    }

    .quick-actions-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px !important;
    }

    /* Order Pages */
    .package-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
        gap: 16px !important;
    }

    .payment-body {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        gap: 12px !important;
    }

    /* Testimoni */
    .testimoni-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 18px !important;
    }
}

/* ==========================================================================
   5. DESKTOP SCREENS (min-width: 1025px)
   ========================================================================== */
@media screen and (min-width: 1025px) {
    .desktop-nav {
        display: flex !important;
        gap: 20px !important;
        align-items: center !important;
    }

    .hamburger {
        display: none !important;
    }

    .bottom-nav {
        display: none !important;
    }

    .mobile-search {
        display: none !important;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
        gap: 24px !important;
    }

    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr 2fr !important;
    }
}

/* ==========================================================================
   6. General Utilities & Custom Scrollbars
   ========================================================================== */
.table-responsive::-webkit-scrollbar,
div[style*="overflow-x: auto"]::-webkit-scrollbar,
.panel-tabs::-webkit-scrollbar,
.nav-tabs::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track,
div[style*="overflow-x: auto"]::-webkit-scrollbar-track,
.panel-tabs::-webkit-scrollbar-track,
.nav-tabs::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb,
div[style*="overflow-x: auto"]::-webkit-scrollbar-thumb,
.panel-tabs::-webkit-scrollbar-thumb,
.nav-tabs::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.4);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
div[style*="overflow-x: auto"]::-webkit-scrollbar-thumb:hover,
.panel-tabs::-webkit-scrollbar-thumb:hover,
.nav-tabs::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}


/* ==========================================================================
   Live Search Dropdown & Interactive Product Filter Styling
   ========================================================================== */
.search-container {
    position: relative !important;
}

.search-input {
    width: 220px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.search-input:focus {
    width: 280px !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3) !important;
}

.search-suggestions-dropdown {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    width: 380px !important;
    max-width: 95vw !important;
    background: rgba(15, 23, 42, 0.98) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    border-radius: 14px !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8), 0 0 25px rgba(59, 130, 246, 0.2) !important;
    z-index: 999999 !important;
    display: none;
    max-height: 420px !important;
    overflow-y: auto !important;
    padding: 6px !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.5) transparent;
}

.search-suggestions-dropdown.active {
    display: block !important;
    animation: searchFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes searchFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-suggestions-dropdown::-webkit-scrollbar {
    width: 5px;
}
.search-suggestions-dropdown::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.4);
    border-radius: 4px;
}

.search-item-link {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.search-item-link:last-child {
    border-bottom: none !important;
}

.search-item-link:hover,
.search-item-link.highlighted {
    background: rgba(59, 130, 246, 0.2) !important;
    transform: translateX(4px) !important;
}

.search-item-thumb {
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
    object-fit: cover !important;
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    flex-shrink: 0 !important;
}

.search-item-details {
    flex: 1 !important;
    min-width: 0 !important;
}

.search-item-title {
    font-size: 0.92rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    margin-bottom: 4px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
}

.search-item-title mark {
    background: rgba(59, 130, 246, 0.4) !important;
    color: #93c5fd !important;
    border-radius: 3px !important;
    padding: 0 3px !important;
}

.search-item-meta {
    font-size: 0.76rem !important;
    color: #94a3b8 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.search-item-badge {
    background: rgba(59, 130, 246, 0.25) !important;
    color: #93c5fd !important;
    padding: 2px 7px !important;
    border-radius: 4px !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
}

.search-item-price {
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: #fbbf24 !important;
    white-space: nowrap !important;
    margin-left: 8px !important;
    text-align: right !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
}

.search-item-price span.btn-cta {
    font-size: 0.72rem !important;
    color: #60a5fa !important;
    margin-top: 2px !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

.search-empty-state {
    padding: 28px 16px !important;
    text-align: center !important;
    color: #94a3b8 !important;
}
.search-empty-state i {
    font-size: 2.2rem !important;
    color: #64748b !important;
    margin-bottom: 10px !important;
    display: block !important;
}
.search-empty-state p {
    font-size: 0.92rem !important;
    margin: 0 0 6px 0 !important;
    color: #f1f5f9 !important;
    font-weight: 700 !important;
}
.search-empty-state small {
    font-size: 0.78rem !important;
    color: #64748b !important;
    line-height: 1.4 !important;
    display: block !important;
}

@media screen and (max-width: 767px) {
    .search-input {
        width: 100% !important;
    }
    .search-input:focus {
        width: 100% !important;
    }
    .search-suggestions-dropdown {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        max-width: 100% !important;
    }
}
