/* =========================================================
   DQ SMS — GLOBAL UI FIX
   Forms • Spacing • Responsive • Tables • Cards
   Colors intentionally unchanged
   ========================================================= */

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

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

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


/* =========================================================
   MAIN CONTENT
   ========================================================= */

.main-content {
    min-width: 0;
}

.page-content {
    width: 100%;
    min-width: 0;
}

.page-content .container-fluid {
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}


/* =========================================================
   CARDS / PANELS
   ========================================================= */

.card,
.panel,
.content-card,
.dashboard-card,
.stat-card {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.card-header,
.panel-header {
    min-width: 0;
}

.card-body,
.panel-body {
    min-width: 0;
}


/* =========================================================
   IMPORTANT:
   FORM GROUP MUST NEVER PUT LABEL + INPUT SIDE BY SIDE
   ========================================================= */

.form-group {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;

    margin: 0 0 18px !important;
    padding: 0 !important;
}

.form-group:last-child {
    margin-bottom: 0 !important;
}


/* LABEL */

.form-group > label,
.form-group label {
    display: block !important;
    width: 100% !important;

    margin: 0 0 8px !important;
    padding: 0 !important;

    line-height: 1.45 !important;
    white-space: normal !important;
}


/* INPUT / SELECT / TEXTAREA */

.form-control,
.form-group input,
.form-group select,
.form-group textarea {
    display: block !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    min-height: 44px;

    margin: 0 !important;

    box-sizing: border-box !important;
}

.form-group textarea {
    min-height: 110px;
    resize: vertical;
}


/* SMALL HELP TEXT */

.form-group small,
.form-group .text-muted {
    display: block !important;

    width: 100% !important;

    margin-top: 7px !important;
    line-height: 1.45 !important;

    white-space: normal !important;
}


/* =========================================================
   BOOTSTRAP-STYLE ROW
   ========================================================= */

form .row {
    width: auto;
}

form .row > [class*="col-"] {
    min-width: 0;
}


/* =========================================================
   FORM ACTIONS
   ========================================================= */

.form-actions,
.form-buttons,
.action-buttons,
form .actions {
    display: flex !important;

    align-items: center;
    justify-content: flex-start;

    flex-wrap: wrap;

    gap: 10px;

    width: 100%;

    margin-top: 20px;
}

.form-actions button,
.form-actions .btn,
.form-buttons button,
.form-buttons .btn,
.action-buttons button,
.action-buttons .btn {
    flex: 0 0 auto;
}


/* =========================================================
   INPUT GROUP
   ========================================================= */

.input-group {
    display: flex !important;
    align-items: stretch;

    width: 100% !important;
    max-width: 100% !important;

    min-width: 0;
}

.input-group .form-control {
    flex: 1 1 auto;
    width: 1% !important;
}

.input-group-text {
    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    white-space: nowrap;
}


/* =========================================================
   FORM GRID
   ========================================================= */

.form-grid {
    display: grid;
    width: 100%;
    gap: 18px;
}

.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}


/* =========================================================
   SEARCH / FILTER
   ========================================================= */

.search-box,
.filters,
.filter-box,
.table-filters {
    display: flex !important;

    align-items: flex-end;
    flex-wrap: wrap;

    gap: 12px;

    width: 100%;
    min-width: 0;

    margin-bottom: 18px;
}

.search-box input,
.filters input,
.filter-box input,
.table-filters input,
.search-box select,
.filters select,
.filter-box select,
.table-filters select {
    min-width: 0;
    max-width: 100%;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn,
button {
    box-sizing: border-box;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}


/* =========================================================
   TABLE
   ========================================================= */

.table-responsive {
    display: block;

    width: 100%;
    max-width: 100%;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    width: 100%;
    margin: 0;
}

table th,
table td {
    vertical-align: middle;
}


/* =========================================================
   SECTION SPACING
   ========================================================= */

.settings-section,
.form-section,
.content-section,
.page-section {
    width: 100%;
    min-width: 0;

    margin-bottom: 24px;
}

.settings-section:last-child,
.form-section:last-child,
.content-section:last-child,
.page-section:last-child {
    margin-bottom: 0;
}


/* =========================================================
   SECTION HEADINGS
   ========================================================= */

.settings-section h4,
.form-section h4,
.content-section h4,
.section-title {
    margin-top: 0;
    margin-bottom: 18px;
}


/* Remove decorative unwanted underline */

.section-title::before,
.section-title::after,
.page-title::before,
.page-title::after,
.card-title::before,
.card-title::after {
    display: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6,
a {
    text-decoration: none !important;
}


/* =========================================================
   REMOVE UNWANTED HR LINES
   ========================================================= */

form > hr,
.settings-section + hr {
    display: none !important;
}


/* =========================================================
   NAVBAR
   ========================================================= */

.dqsms-navbar {
    width: 100% !important;

    display: flex !important;
    align-items: center !important;

    justify-content: space-between !important;

    min-width: 0;

    border-bottom: 0 !important;
    box-shadow: none !important;
}

.dqsms-navbar .navbar-left {
    display: flex !important;
    align-items: center !important;

    min-width: 0;
    flex: 1 1 auto;
}

.dqsms-navbar .navbar-right {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;

    margin-left: auto !important;

    flex: 0 0 auto;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
    overflow-x: hidden !important;
}

.sidebar-nav {
    min-width: 0;
    overflow-x: hidden !important;
}

.nav-menu {
    min-width: 0;
}

.nav-link {
    text-decoration: none !important;
}


/* =========================================================
   ALERTS
   ========================================================= */

.alert {
    width: 100%;
    min-width: 0;

    margin-bottom: 16px;
}


/* =========================================================
   MODALS
   ========================================================= */

.modal-dialog {
    width: auto;
    max-width: calc(100vw - 30px);
}

.modal-content {
    max-width: 100%;
    overflow: hidden;
}


/* =========================================================
   DESKTOP
   ========================================================= */

@media (min-width: 993px) {

    .page-content {
        padding: 24px;
    }

}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 992px) {

    .page-content {
        padding: 18px 14px;
    }

    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 640px) {

    .page-content {
        padding: 14px 10px;
    }

    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
        gap: 15px;
    }


    /*
       Bootstrap-style columns become full width
       on mobile.
    */

    form .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    form .row > [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;

        flex: 0 0 100% !important;

        padding-left: 0 !important;
        padding-right: 0 !important;

        margin-bottom: 15px;
    }


    /* Form spacing */

    .form-group {
        margin-bottom: 16px !important;
    }

    .form-group > label,
    .form-group label {
        margin-bottom: 7px !important;
    }


    /* Inputs */

    .form-control,
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100% !important;
        max-width: 100% !important;
    }


    /* Buttons */

    .form-actions,
    .form-buttons,
    .action-buttons,
    form .actions {
        width: 100%;
        gap: 8px;
    }


    /* Search/filter */

    .search-box,
    .filters,
    .filter-box,
    .table-filters {
        align-items: stretch !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .search-box > *,
    .filters > *,
    .filter-box > *,
    .table-filters > * {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }


    /* Cards */

    .card-body,
    .panel-body {
        padding: 15px;
    }


    /* Tables */

    .table-responsive {
        margin-left: 0;
        margin-right: 0;
    }


    /* Navbar */

    .dqsms-navbar {
        min-height: 60px;
        padding: 8px 10px !important;
    }

}


/* =========================================================
   VERY SMALL MOBILE
   ========================================================= */

@media (max-width: 380px) {

    .page-content {
        padding: 10px 8px;
    }

    .card-body,
    .panel-body {
        padding: 12px;
    }

    .btn {
        max-width: 100%;
    }

}


/* =========================================================
   PREVENT HORIZONTAL OVERFLOW
   ========================================================= */

.row,
.container,
.container-fluid,
.card,
.card-body,
.form-group,
form,
section {
    min-width: 0;
}

pre {
    max-width: 100%;
    overflow-x: auto;
}


/* =========================================================
   DQ SMS — GLOBAL FORM SPACING & MOBILE FIX
   Layout only — existing colors preserved
   ========================================================= */

/* Prevent width calculation problems */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Main content must never create horizontal overflow */
html,
body,
#app,
.main-content,
.page-content,
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
}

/* Bootstrap-like row */
.row {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    margin-left: -8px;
    margin-right: -8px;
}

.row > [class*="col-"] {
    padding-left: 8px;
    padding-right: 8px;
    min-width: 0;
}

/* Card spacing */
.card {
    width: 100%;
    max-width: 100%;
}

.card-body {
    width: 100%;
}

/* =========================================================
   FORM LAYOUT
   ========================================================= */

form {
    width: 100%;
    max-width: 100%;
}

.form-group {
    display: block !important;
    width: 100%;
    margin-bottom: 18px !important;
}

.form-group:last-child {
    margin-bottom: 0 !important;
}

/* Labels MUST stay above inputs */
.form-group > label,
.form-group label {
    display: block !important;
    width: 100%;
    margin: 0 0 7px 0 !important;
    line-height: 1.4;
    white-space: normal;
}

/* Inputs / selects / textarea */
.form-control,
input.form-control,
select.form-control,
textarea.form-control {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 44px;
    box-sizing: border-box;
}

/* Textarea should not use input height */
textarea.form-control {
    height: auto;
    min-height: 110px;
    resize: vertical;
}

/* Select arrow / text spacing */
select.form-control {
    padding-right: 40px;
}

/* Validation messages */
.invalid-feedback,
.text-danger {
    display: block;
    margin-top: 5px;
    line-height: 1.4;
}

/* Small helper text */
.form-group small,
.form-group .text-muted {
    display: block;
    margin-top: 5px;
    line-height: 1.4;
}

/* =========================================================
   FORM BUTTON AREA
   ========================================================= */

form .btn {
    margin-top: 4px;
    margin-right: 8px;
    margin-bottom: 4px;
}

form .btn:last-child {
    margin-right: 0;
}

/* =========================================================
   CREATE / EDIT PAGES
   ========================================================= */

.card-body > form {
    padding: 2px 0;
}

/* Keep medium columns usable */
.col-md-8 {
    width: 66.666667%;
}

.col-md-6 {
    width: 50%;
}

.col-md-4 {
    width: 33.333333%;
}

.col-md-3 {
    width: 25%;
}

/* =========================================================
   SETTINGS / SECTION SPACING
   ========================================================= */

.settings-section {
    width: 100%;
    margin: 0 0 28px 0 !important;
    padding: 0 !important;
}

.settings-section h4 {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    margin: 0 0 20px 0 !important;
    line-height: 1.4;
}

.settings-section .row {
    row-gap: 0;
}

.settings-section .form-group {
    margin-bottom: 20px !important;
}

/* Section separator */
.settings-section + hr {
    margin: 8px 0 28px 0 !important;
}

/* =========================================================
   CARD HEADER
   ========================================================= */

.card-header {
    min-width: 0;
    gap: 12px;
}

.card-header > h3 {
    min-width: 0;
    line-height: 1.35;
}

.card-header > div {
    min-width: 0;
}

/* =========================================================
   USER / AGENT / MANAGER CARDS
   ========================================================= */

.user-card {
    min-width: 0;
    width: 100%;
}

.user-card .user-info {
    min-width: 0;
    overflow: hidden;
}

.user-card .user-info .name,
.user-card .user-info .email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card .footer {
    min-width: 0;
}

.user-card .footer .actions {
    flex-wrap: wrap;
    max-width: 100%;
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 992px) {

    .col-md-8,
    .col-md-6,
    .col-md-4,
    .col-md-3 {
        width: 100% !important;
    }

    .card {
        border-radius: var(--radius-md, 14px);
    }

    .card-body {
        padding: 18px !important;
    }

    .form-group {
        margin-bottom: 17px !important;
    }

    .form-control,
    input.form-control,
    select.form-control,
    textarea.form-control {
        width: 100% !important;
        max-width: 100% !important;
    }

    .card-header {
        flex-wrap: wrap;
    }

    .card-header > div {
        width: 100%;
    }

    .card-header > div .btn {
        margin-top: 8px;
    }
}

@media (max-width: 576px) {

    .row {
        margin-left: 0;
        margin-right: 0;
    }

    .row > [class*="col-"] {
        width: 100% !important;
        padding-left: 0;
        padding-right: 0;
    }

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

    .card-header {
        padding: 16px !important;
    }

    .card-header h3 {
        font-size: 18px;
    }

    .form-group {
        margin-bottom: 16px !important;
    }

    .form-group > label,
    .form-group label {
        margin-bottom: 7px !important;
        font-size: 13px;
    }

    .form-control,
    input.form-control,
    select.form-control,
    textarea.form-control {
        height: 44px;
        font-size: 14px;
    }

    form .btn {
        margin-top: 5px;
        margin-bottom: 5px;
    }

    /* Settings sections */
    .settings-section {
        margin-bottom: 24px !important;
    }

    .settings-section h4 {
        margin-bottom: 16px !important;
        font-size: 16px;
    }
}

/* =========================================================
   TOUCH / ANIMATION
   ========================================================= */

.form-control,
.btn {
    transition:
        border-color var(--transition, 220ms ease),
        box-shadow var(--transition, 220ms ease),
        transform var(--transition, 220ms ease);
}

.form-control:focus {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

/* Never allow long text to break the page */
input,
select,
textarea,
button {
    max-width: 100%;
}

