/* ==========================================================================
   SIMVOICE - Global Responsive Stylesheet
   Mobile first adjustments for the DeskApp based layout.
   Loaded after core.css / style.css so it can safely override component
   defaults without touching the vendor files.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Global safety nets
   -------------------------------------------------------------------------- */
html,
body {
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   1b. Bootstrap 5 utility compatibility
   Some pages use Bootstrap 5 helper classes while the template ships BS4.
   -------------------------------------------------------------------------- */
.form-select {
    display: block;
    width: 100%;
    height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-select-sm {
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.fw-bold {
    font-weight: 700 !important;
}

.fs-6 {
    font-size: 1rem !important;
}

.g-3 > [class*="col-"] {
    padding-right: 8px;
    padding-left: 8px;
}

@media (min-width: 768px) {
    .text-md-end {
        text-align: right !important;
    }

    .text-md-start {
        text-align: left !important;
    }

    .w-100.w-md-auto {
        width: auto !important;
    }
}

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

* {
    min-width: 0;
}

/* Tables never widen their container on their own */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   2. Tablet & below (<= 991.98px)
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .page-header .title h4 {
        font-size: 1.35rem;
        line-height: 1.3;
    }

    .card-box > .pd-20,
    .card-box.pd-20 {
        padding: 18px;
    }

    .table-responsive > .table {
        margin-bottom: 0;
    }
}

/* --------------------------------------------------------------------------
   3. Mobile (<= 767.98px)
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    html,
    body {
        overflow-x: hidden;
    }

    /* ---------- Layout shell ---------- */
    .main-container {
        padding-left: 6px;
        padding-right: 6px;
    }

    .xs-pd-20-10,
    .pd-ltr-20 {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .header {
        padding: 0 10px;
    }

    .header-right {
        padding-right: 6px !important;
    }

    .header-right .user-info-dropdown .dropdown-menu {
        right: 0;
        left: auto;
        min-width: 220px;
    }

    .left-side-bar {
        max-width: 86vw;
    }

    .left-side-bar .brand-logo a img,
    .left-side-bar .brand-logo a .dark-logo {
        max-width: 100%;
        height: auto;
    }

    /* ---------- Page header ---------- */
    .page-header {
        margin-bottom: 18px;
        padding: 14px;
    }

    .page-header .row {
        display: block;
    }

    .page-header .row > [class*="col-"] {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    .page-header .title h4 {
        font-size: 1.25rem;
        line-height: 1.3;
        margin-bottom: 6px;
        word-break: break-word;
    }

    .page-header .breadcrumb {
        background: transparent;
        padding: 0;
        margin-bottom: 10px;
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    .page-header .breadcrumb-item + .breadcrumb-item::before {
        padding-right: 4px;
        padding-left: 4px;
    }

    /* Action buttons in page headers: full width, easy to tap */
    .page-header .text-right,
    .page-header .text-md-right,
    .page-header .text-end {
        text-align: left !important;
    }

    .page-header .d-flex {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }

    .page-header .btn,
    .page-header .btn.right {
        display: block;
        width: 100%;
        margin: 0 0 8px 0 !important;
        text-align: center;
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .page-header .btn:last-child {
        margin-bottom: 0 !important;
    }

    .page-header .btn.mr-2 {
        margin-right: 0 !important;
    }

    /* ---------- Cards & spacing ---------- */
    .card-box {
        border-radius: 8px;
    }

    .card-box > .pd-20,
    .card-box.pd-20,
    .pd-20 {
        padding: 14px;
    }

    .card-box .pb-20,
    .card-box .pd-20.pb-20 {
        padding-bottom: 10px;
    }

    .mb-30 {
        margin-bottom: 18px !important;
    }

    .page-header.pb-0,
    .page-header.pt-0 {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* ---------- Forms ---------- */
    .form-group {
        margin-bottom: 12px;
    }

    .form-group > label,
    .form-label {
        font-size: 0.82rem;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .form-control,
    .custom-select,
    .form-select,
    .input-group-text,
    .select2-search__field {
        font-size: 16px !important; /* prevents iOS auto zoom on focus */
        line-height: 1.4;
        height: auto;
        min-height: 40px;
    }

    textarea.form-control {
        min-height: 90px;
    }

    .input-group.custom {
        flex-wrap: nowrap;
    }

    .select2-container {
        width: 100% !important;
    }

    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple {
        min-height: 40px;
        height: auto;
    }

    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 38px;
        padding-left: 8px;
    }

    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        margin-top: 6px;
        max-width: 100%;
        white-space: normal;
    }

    /* Buttons inside form/footer areas */
    .text-right > .btn,
    .text-end > .btn,
    .form-group .btn {
        max-width: 100%;
    }

    .text-right > .btn,
    .text-end > .btn {
        margin-bottom: 6px;
    }

    .card-box .text-right > .btn,
    .card-box .text-end > .btn,
    .card-box .col-auto > .btn {
        display: block;
        width: 100%;
        margin-left: 0 !important;
        margin-bottom: 8px;
    }

    .btn-block-mobile {
        display: block;
        width: 100%;
    }

    /* ---------- Tables ---------- */
    .table {
        font-size: 0.82rem;
    }

    .table th,
    .table td {
        white-space: normal;
        word-break: break-word;
        padding: 8px;
        vertical-align: middle;
    }

    .table thead th {
        white-space: nowrap;
    }

    /* Keep total / summary rows readable */
    .table tfoot td,
    .table tfoot th {
        font-weight: 600;
    }

    /* ---------- DataTables ---------- */
    .dataTables_wrapper {
        width: 100%;
        font-size: 0.82rem;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        width: 100%;
        text-align: left;
        margin-bottom: 10px;
    }

    .dataTables_wrapper .dataTables_filter label,
    .dataTables_wrapper .dataTables_length label {
        width: 100%;
        display: block;
        font-weight: 500;
        margin-bottom: 0;
    }

    .dataTables_wrapper .dataTables_filter input {
        display: block;
        width: 100%;
        margin: 6px 0 0 0;
        min-height: 40px;
    }

    .dataTables_wrapper .dataTables_length select {
        display: inline-block;
        width: auto;
        min-height: 38px;
        margin: 0 4px;
    }

    .dataTables_wrapper .dataTables_info {
        width: 100%;
        text-align: left;
        padding-top: 8px;
        font-size: 0.78rem;
        white-space: normal;
    }

    .dataTables_wrapper .dataTables_paginate {
        width: 100%;
        text-align: left;
        padding-top: 6px;
        white-space: normal;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 5px 8px;
        margin: 0 2px 4px 0;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
        top: 50%;
        left: 6px;
        transform: translateY(-50%);
        margin-right: 6px;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
        padding-left: 30px !important;
        position: relative;
    }

    ul.dtr-details {
        width: 100%;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    ul.dtr-details li {
        padding: 8px 10px;
        border-bottom: 1px solid #e9ecef;
        display: flex;
        align-items: baseline;
        gap: 8px;
        flex-wrap: wrap;
    }

    ul.dtr-details li:last-child {
        border-bottom: none;
    }

    ul.dtr-details .dtr-title {
        font-weight: 600;
        color: #495057;
        font-size: 0.78rem;
        flex: 0 0 100%;
    }

    ul.dtr-details .dtr-data {
        word-break: break-word;
        font-size: 0.84rem;
    }

    /* Action buttons rendered inside responsive detail rows */
    ul.dtr-details .btn-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    ul.dtr-details .btn-list .btn {
        flex: 1 1 auto;
        min-width: 44px;
        min-height: 36px;
    }

    /* Wrapper for tables with no responsive plugin support */
    .table-scroll-mobile,
    .table-responsive-custom {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---------- Modals ---------- */
    .modal-dialog {
        margin: 10px auto;
        max-width: calc(100% - 16px);
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100% - 16px);
    }

    .modal-content {
        border-radius: 10px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px;
    }

    .modal-title {
        font-size: 1rem;
        line-height: 1.35;
    }

    .modal-body .table {
        font-size: 0.8rem;
    }

    .modal-body {
        overflow-x: auto;
    }

    .modal-footer .btn {
        margin: 0 0 6px 0;
        width: 100%;
    }

    .modal-footer {
        display: block;
        text-align: right;
    }

    /* ---------- Info tables (show/detail pages) ---------- */
    .info-table-mobile {
        border-collapse: separate;
        border-spacing: 0;
        width: 100%;
    }

    .info-table-mobile,
    .info-table-mobile tbody,
    .info-table-mobile tr,
    .info-table-mobile th,
    .info-table-mobile td {
        display: block;
        width: 100% !important;
    }

    .info-table-mobile tr {
        background: #fafbfc;
        border: 1px solid #e9ecef;
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    .info-table-mobile th {
        font-size: 0.72rem;
        font-weight: 600;
        letter-spacing: 0.3px;
        text-transform: uppercase;
        color: #6c757d;
        padding: 0;
        border: 0;
        text-align: left;
        background: transparent;
    }

    .info-table-mobile td {
        padding: 0 0 8px;
        border: 0;
        font-size: 0.86rem;
        font-weight: 600;
        color: #333;
        word-break: break-word;
    }

    .info-table-mobile td:last-child {
        padding-bottom: 0;
    }

    /* ---------- Typography / dashboard ---------- */
    .font-24 {
        font-size: 1.25rem !important;
    }

    .font-30 {
        font-size: 1.35rem !important;
        line-height: 1.3;
    }

    .widget-style3 .widget-data {
        flex: 1 1 auto;
    }

    .widget-style3 .widget-icon {
        flex: 0 0 auto;
    }

    /* ---------- Custom filter bars (list pages) ---------- */
    .custom-filter-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .custom-filter-bar .form-group {
        width: 100%;
        margin-bottom: 0;
    }

    .custom-filter-bar label {
        font-size: 0.82rem;
        font-weight: 600;
        margin-bottom: 4px;
    }

    .custom-filter-bar .form-control {
        width: 100%;
    }

    .custom-filter-bar > div {
        width: 100%;
    }

    .custom-filter-bar .btn {
        width: 100%;
        min-height: 40px;
    }

    /* ---------- Misc components ---------- */
    .alert {
        font-size: 0.85rem;
        padding: 10px 12px;
    }

    .card-box,
    .card-body,
    .modal-body {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    .badge {
        font-size: 0.72rem;
        white-space: normal;
    }

    .swal2-popup {
        width: calc(100% - 24px) !important;
        padding: 18px !important;
        font-size: 0.9rem !important;
    }

    .swal2-title {
        font-size: 1.15rem !important;
    }

    .swal2-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .swal2-actions button {
        margin: 0 !important;
    }

    .card .card-body {
        padding: 14px;
    }

    .ro-header-card .card-body {
        padding: 14px;
    }

    /* Utility used across custom pages */
    .w-md-auto {
        width: 100%;
    }

    .fs-5 {
        font-size: 1rem !important;
    }
}

/* --------------------------------------------------------------------------
   4. Small phones (<= 420px)
   -------------------------------------------------------------------------- */
@media (max-width: 420px) {
    .page-header .title h4 {
        font-size: 1.1rem;
    }

    .card-box > .pd-20,
    .card-box.pd-20,
    .pd-20 {
        padding: 11px;
    }

    .table {
        font-size: 0.76rem;
    }

    .table th,
    .table td {
        padding: 6px;
    }

    .btn {
        font-size: 0.82rem;
        padding: 8px 12px;
    }

    .header-right .user-info-dropdown .dropdown-menu {
        min-width: 190px;
    }
}

/* --------------------------------------------------------------------------
   5. Login page
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    body.login-page {
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
    }

    .login-wrap {
        min-height: 100vh;
        padding: 24px 12px;
    }

    .login-box {
        padding: 28px 20px !important;
    }

    .login-title h2 {
        font-size: 1.45rem;
    }
}

@media (max-width: 420px) {
    .login-box {
        padding: 22px 14px !important;
    }

    .login-title h2 {
        font-size: 1.25rem;
    }
}
