/* ==========================================================================
   Dhru Fusion - Universal Responsive Engine (Desktop, Tablet & Mobile)
   Applies across Index, Guest Pages, Login/Register, Store & User Panel
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

img, video, svg {
    max-width: 100%;
}

img {
    height: auto;
}

/* Keep icons, avatars, captcha and carousel images crisp */
.banner-hd-img {
    height: clamp(220px, 34vw, 520px) !important;
    object-fit: cover !important;
}

/* Fix hardcoded widths from legacy theme.css that broke mobile & narrow desktop */
.mw-520 {
    min-width: 0 !important;
    width: 100%;
    max-width: 520px;
}

.mw-320 {
    min-width: 0 !important;
    width: 100%;
    max-width: 360px;
}

.mw-300, .mw-360, .mw-400, .mw-500, .mw-600 {
    width: 100%;
}

/* Chosen.js select boxes - never exceed parent width */
.chosen-container,
.chosen-container-single,
.chosen-container-multi {
    width: 100% !important;
    max-width: 100% !important;
}

#service_id_chosen .chosen-drop,
.chosen-container .chosen-drop {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

.chosen-container-single .chosen-single {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Universal table horizontal scroll wrapper (auto-applied + native .table-responsive) */
.gsm-table-scroll,
.table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.gsm-table-scroll {
    margin-bottom: 1rem;
}

.gsm-table-scroll > table {
    width: 100%;
    margin-bottom: 0;
}

/* Clean currency/language nav inside top-header */
.gsm-top-curlang {
    display: flex;
    align-items: center;
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    gap: 2px;
}

.gsm-top-curlang > li {
    list-style: none;
}

.gsm-top-curlang .nav-link {
    padding: 0.35rem 0.55rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Sidebar backdrop for mobile/tablet drawer */
.gsm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.gsm-sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

.sidebar .brand-logo {
    position: relative;
    padding: 0 14px;
}

.gsm-sidebar-close {
    display: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* Desktop medium screens (992px - 1199px): give main-content extra breathing room */
@media (min-width: 992px) and (max-width: 1199.98px) {
    body.gsm-theme .sidebar {
        width: 230px;
    }
    body.gsm-theme .main-content {
        width: calc(100% - 230px);
        margin-left: 230px;
        padding: 18px 20px;
    }
}

/* Top header responsive structure */
body.gsm-theme .top-header {
    gap: 10px;
    flex-wrap: wrap;
}

body.gsm-theme .top-header > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

body.gsm-theme .top-header h4 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

body.gsm-theme .top-header > div:last-child {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 6px;
}

/* Tablet & Mobile (<= 991px) */
@media (max-width: 991.98px) {
    body.gsm-theme .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 270px;
        max-width: 84vw;
        height: 100vh;
        height: 100dvh;
        z-index: 1050 !important;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
        transition: transform 0.28s ease;
    }

    body.gsm-theme .sidebar.active {
        transform: translateX(0);
    }

    body.gsm-theme .gsm-sidebar-close {
        display: inline-flex;
    }

    body.gsm-theme .main-content {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding: 12px !important;
    }

    body.gsm-theme .main-content > .container-fluid {
        padding-left: 4px;
        padding-right: 4px;
    }

    body.gsm-theme .top-header {
        padding: 10px 14px !important;
        margin-bottom: 16px !important;
        border-radius: 10px;
    }

    body.gsm-theme .top-header h4 {
        font-size: 1.05rem;
    }

    body.gsm-theme .top-header .btn-link {
        padding: 4px 8px;
        margin-right: 8px !important;
        font-size: 1.2rem;
    }

    body.gsm-theme .top-header .dropdown-menu {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        max-width: calc(100vw - 24px);
    }

    /* Native default2-6 & store_default* mobile navigation modal */
    .modal-menu .modal-dialog {
        margin: 0 !important;
        width: 310px !important;
        max-width: 86vw !important;
        height: 100% !important;
    }

    header .navbar-brand img {
        max-height: 36px !important;
        max-width: 160px !important;
        object-fit: contain;
    }

    header .header-middle nav {
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        gap: 8px;
    }

    /* Container padding on mobile */
    .container, .container-fluid {
        max-width: 100%;
    }
}

/* Small Tablets & Phones (<= 767px) */
@media (max-width: 767.98px) {
    .card-body {
        padding: 1rem !important;
    }

    .card-registration,
    .page-login .card {
        padding: 1.15rem !important;
    }

    .stat-card .card-body {
        padding: 1rem !important;
        gap: 10px;
    }

    .stat-value {
        font-size: clamp(1.1rem, 4.5vw, 1.45rem) !important;
        line-height: 1.25;
        word-break: break-word;
    }

    .stat-icon {
        width: 46px !important;
        height: 46px !important;
        font-size: 18px !important;
        flex-shrink: 0;
    }

    /* Dashboard quick action buttons fit cleanly without horizontal overflow */
    .dashboard-content .card-body .d-flex.flex-wrap {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .dashboard-content .card-body .d-flex.flex-wrap > a.btn {
        margin: 0 !important;
        width: 100%;
        padding: 0.55rem 0.5rem;
        font-size: 0.82rem;
        white-space: normal;
        text-align: center;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Nav tabs scroll smoothly instead of wrapping into messy blocks */
    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-item,
    .nav-pills .nav-item {
        flex: 0 0 auto;
    }

    /* Modals always fit inside phone viewport */
    .modal-dialog {
        max-width: calc(100vw - 16px) !important;
        margin: 0.5rem auto !important;
    }

    /* Invoice & Add Funds mobile alignment */
    .big-badge.text-right {
        text-align: left !important;
        margin-top: 8px;
    }

    /* DataTables filter & pagination stack cleanly */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        width: 100% !important;
        margin-bottom: 8px;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-top: 4px;
    }

    /* Carousel text scaling on small phones */
    .carousel.index-banner .banner-content h1 {
        font-size: clamp(1.25rem, 6vw, 2rem) !important;
        line-height: 1.25 !important;
    }

    .carousel.index-banner .banner-content h2,
    .carousel.index-banner .banner-content h3 {
        font-size: clamp(1.05rem, 4.8vw, 1.5rem) !important;
    }

    .carousel.index-banner .banner-content p {
        font-size: 0.9rem !important;
    }

    /* Prevent long IMEIs, codes, or links from blowing out containers */
    pre, code, .order-reply, .code-box {
        white-space: pre-wrap;
        word-break: break-word;
        overflow-wrap: anywhere;
        max-width: 100%;
    }
}

/* Extra-small Phones (<= 480px) */
@media (max-width: 480px) {
    body.gsm-theme .top-header {
        padding: 8px 10px !important;
    }

    body.gsm-theme .top-header h4 {
        font-size: 0.95rem;
    }

    body.gsm-theme .top-header .btn {
        padding: 0.32rem 0.6rem;
        font-size: 0.8rem;
    }

    .dashboard-content .card-body .d-flex.flex-wrap {
        grid-template-columns: 1fr;
    }

    .gsm-top-curlang .nav-link {
        padding: 0.25rem 0.35rem;
        font-size: 0.78rem;
    }
}
