/* Unified project theme on top of SB Admin 2 */

:root {
    --app-primary: #4e73df;
    --app-primary-dark: #224abe;
    --app-bg: #f8f9fc;
    --app-card-border: #e3e6f0;
    --app-text: #3a3b45;
    --app-muted: #858796;
    --app-radius: 0.35rem;
    --app-shadow: 0 0.15rem 1.75rem rgba(58, 59, 69, 0.15);
}

/* Bootstrap 4 fallback utilities for markup using Bootstrap 5 spacing names */
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.border-start-0 { border-left: 0 !important; }
.border-end-0 { border-right: 0 !important; }
.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--app-text);
}

body,
h1, h2, h3, h4, h5, h6,
p, a, li, span, div,
button, label, input, select, textarea, th, td {
    font-family: "Sarabun", "Nunito", sans-serif;
}

body {
    color: var(--app-text);
    background-color: var(--app-bg);
    overflow-x: hidden;
}

html {
    overflow-x: hidden;
}

#wrapper,
#content-wrapper,
#content {
    min-width: 0;
}

#content-wrapper {
    width: 100%;
}

.text-muted {
    color: var(--app-muted) !important;
}

/* Buttons */
.btn {
    border-radius: var(--app-radius);
    font-weight: 600;
    box-shadow: none;
}

.btn-user {
    border-radius: 10rem;
}

.custom-button-shadow {
    box-shadow: 0 0.25rem 0.9rem rgba(58, 59, 69, 0.14) !important;
}

/* Cards */
.card {
    border: 1px solid var(--app-card-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.custom-card-shadow {
    box-shadow: var(--app-shadow) !important;
}

.card-header {
    border-bottom: 1px solid var(--app-card-border);
    background: #f8f9fc;
    color: var(--app-primary);
    font-weight: 700;
}

/* Form controls */
.form-control,
.form-select {
    border: 1px solid #d1d3e2;
    border-radius: var(--app-radius);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.form-select {
    display: block;
    width: 100%;
    padding: .375rem 2rem .375rem .75rem;
    line-height: 1.5;
    color: #6e707e;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(78, 115, 223, 0.65);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
}

.custom-input-focus:focus {
    border-color: rgba(78, 115, 223, 0.65) !important;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15) !important;
}

.form-control-user {
    border-radius: 10rem;
    padding: .8rem 1rem;
}

/* Tables */
.table-responsive {
    border-radius: var(--app-radius);
    -webkit-overflow-scrolling: touch;
}

.table {
    margin-bottom: 0;
    background: #fff;
}

.table thead th {
    background: #f4f6fd;
    color: var(--app-primary);
    border-bottom: 2px solid var(--app-card-border);
    font-weight: 700;
}

.table td,
.table th {
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: break-word;
}

.table-col-xs { width: 80px; }
.table-col-sm { width: 100px; }
.table-col-md { width: 120px; }
.table-col-lg { width: 180px; }
.table-col-xl { width: 240px; }
.table-col-2xl { width: 320px; }

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(78, 115, 223, 0.03);
}

.table-hover tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.06);
}

/* Alerts and badges */
.alert {
    border: 0;
    border-radius: var(--app-radius);
    box-shadow: 0 0.2rem 0.6rem rgba(58, 59, 69, 0.1);
}

.badge {
    border-radius: 999px;
    padding: 0.45em 0.75em;
    font-weight: 700;
}

/* Bootstrap 5 close button compatibility */
.btn-close {
    position: relative;
    float: right;
    opacity: 0.6;
    font-weight: 700;
    line-height: 1;
    color: #000;
    text-shadow: 0 1px 0 #fff;
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    padding: 0;
    margin-left: 0.5rem;
}

.btn-close:hover {
    opacity: 0.85;
}

.btn-close::before {
    content: "\00d7";
}

/* Width helpers for legacy inline style cleanup */
.w-20 { width: 20% !important; }
.w-25rem { width: min(25rem, 100%) !important; }
.w-40 { width: 40% !important; }
.w-50 { width: 50% !important; }
.w-60 { width: 60% !important; }
.w-80 { width: 80% !important; }
.w-100 { width: 100% !important; }
.max-h-10rem { max-height: 10rem !important; }

.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
}

.btn-group-responsive .btn {
    margin-bottom: 0.35rem;
}

.topbar .nav-item .nav-link .topbar-username {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

/* Improve text wrapping on small screens */
.nav-link span,
.card-body,
.alert,
.custom-control-label,
.dropdown-item,
.badge {
    overflow-wrap: anywhere;
}

.table-kyset-status th,
.table-kyset-status td {
    word-break: normal;
    overflow-wrap: break-word;
}

.sidebar-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1039;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sidebar-mobile-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.row.g-3 {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.row.g-3 > .col,
.row.g-3 > [class^="col-"],
.row.g-3 > [class*=" col-"] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
    .container,
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .topbar {
        margin-bottom: 0.75rem !important;
    }

    .card-body {
        padding: 1rem;
    }

    .table {
        font-size: 0.92rem;
    }

    .table td,
    .table th {
        padding: 0.45rem;
    }

    .table-kyset-status {
        font-size: 0.78rem;
        table-layout: fixed;
    }

    .table-kyset-status th,
    .table-kyset-status td {
        padding: 0.35rem 0.3rem;
        vertical-align: middle;
    }

    .table-kyset-status th:nth-child(2),
    .table-kyset-status td:nth-child(2) {
        display: none;
    }

    .table-kyset-status th:nth-child(1) { width: 30%; }
    .table-kyset-status th:nth-child(3) { width: 22%; }
    .table-kyset-status th:nth-child(4) { width: 25%; }
    .table-kyset-status th:nth-child(5) { width: 23%; }

    .table-kyset-status .badge {
        font-size: 0.68rem;
        line-height: 1.2;
        white-space: normal;
        padding: 0.28rem 0.42rem;
    }

    .table-kyset-status .kyset-action-cell .btn {
        width: 100%;
        font-size: 0.72rem;
        line-height: 1.15;
        padding: 0.35rem 0.4rem;
        margin-right: 0;
        white-space: normal;
    }

    .table-kyset-status .kyset-action-cell .btn + .btn {
        margin-top: 0.35rem;
    }

    .table-col-xs,
    .table-col-sm,
    .table-col-md,
    .table-col-lg,
    .table-col-xl,
    .table-col-2xl {
        width: auto;
    }

    .btn-group {
        display: flex;
        flex-wrap: wrap;
    }

    .btn-group > .btn {
        margin-bottom: 0.35rem;
    }

    .btn {
        white-space: normal;
    }

    .custom-control.custom-radio.custom-control-inline {
        display: block;
        margin-right: 0;
        margin-bottom: 0.45rem;
    }

    .sidebar .sidebar-brand .sidebar-brand-text {
        font-size: 0.78rem;
        line-height: 1.2;
        white-space: normal;
        text-align: center;
        margin-left: 0.5rem !important;
        margin-right: 0.5rem !important;
    }

    .sidebar .nav-item .nav-link {
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .sidebar .nav-item .nav-link span {
        white-space: normal;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 14rem !important;
        overflow-y: auto;
        z-index: 1040;
        transition: transform 0.2s ease;
    }

    .sidebar.toggled {
        width: 14rem !important;
        overflow: auto;
        transform: translateX(-100%);
    }

    body.sidebar-toggled .sidebar {
        transform: translateX(-100%);
    }

    body:not(.sidebar-toggled) .sidebar {
        transform: translateX(0);
    }

    .sidebar .sidebar-brand .sidebar-brand-text {
        display: inline;
    }

    .sidebar .nav-item .nav-link {
        display: block;
        text-align: left;
        width: 14rem;
        padding: 0.85rem 1rem;
    }

    .sidebar .nav-item .nav-link span {
        display: inline;
        font-size: 0.85rem;
    }

    .sidebar .nav-item .nav-link i {
        margin-right: 0.5rem;
        font-size: 0.85rem;
    }

    .sidebar .nav-item .nav-link[data-toggle="collapse"]::after {
        width: 1rem;
        text-align: center;
        float: right;
        border: 0;
        font-weight: 900;
        content: '\f107';
        font-family: 'Font Awesome 5 Free';
    }

    .sidebar .nav-item .nav-link[data-toggle="collapse"].collapsed::after {
        content: '\f105';
    }

    .sidebar .nav-item .collapse,
    .sidebar .nav-item .collapsing {
        margin: 0 1rem;
        position: relative;
        left: 0;
        top: 0;
    }

    .topbar .nav-item .nav-link .topbar-username {
        max-width: 110px;
    }

    .dropdown-menu {
        max-width: calc(100vw - 1rem);
        white-space: normal;
    }

    .modal-dialog {
        margin: 0.75rem;
    }

    div.dataTables_wrapper div.dataTables_length,
    div.dataTables_wrapper div.dataTables_filter,
    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_paginate {
        text-align: left !important;
    }

    div.dataTables_wrapper div.dataTables_filter input {
        width: 100%;
        margin-left: 0 !important;
    }
}

/* Validation helper classes */
.just-validate-success-field {
    border-color: #1cc88a !important;
}

.just-validate-error-field {
    border-color: #e74a3b !important;
}

.just-validate-error-label {
    color: #e74a3b !important;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Typeahead */
.tt-menu {
    background: #fff;
    border: 1px solid #d1d3e2;
    border-radius: 0.5rem;
    box-shadow: var(--app-shadow);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1051;
}

.tt-suggestion {
    padding: 0.55rem 0.75rem;
    cursor: pointer;
}

.tt-suggestion:hover,
.tt-suggestion.tt-cursor {
    background-color: #f4f6fd;
}

.tt-suggestion p {
    margin: 0;
}

/* Auth page backgrounds */
.bg-login-image,
.bg-register-image,
.bg-password-image {
    background-position: center;
    background-size: cover;
    min-height: 480px;
}

.bg-login-image {
    background-image: url("../img/image_e49fbe.png");
}

.bg-register-image {
    background-image: url("../img/undraw_posting_photo.svg");
}

.bg-password-image {
    background-image: url("../img/image_1932f8.png");
}
