/* =====================================================
   BYS Utilities — replaces Bootstrap CSS
   ===================================================== */

/* --- Modal structure -------------------------------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1055;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}
.modal.show { display: block; }
.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    max-width: 500px;
    pointer-events: none;
}
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
}
/* On mobile, clamp ALL modal dialogs to the viewport regardless of any inline
   max-width (e.g. 800px / 900px) that would otherwise blow past the screen edge */
@media (max-width: 639px) {
    .modal-dialog {
        max-width: calc(100% - 1rem) !important;
        width: calc(100% - 1rem);
        margin: 0.5rem auto !important;
    }
    .modal-dialog-centered {
        min-height: calc(100% - 1rem);
        align-items: flex-start;
        padding-top: 1.5rem;
    }
}
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    outline: 0;
    background-color: #fff;
    border-radius: 0.375rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
}
.bys-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.5);
}
.bys-backdrop.show { display: block; }
body.modal-open { overflow: hidden; }

/* --- Collapse --------------------------------------- */
.collapse:not(.show) { display: none; }
.collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
}

/* --- Tabs ------------------------------------------ */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid #c2c8bf;
    margin-bottom: 1rem;
    padding-left: 0;
    list-style: none;
}
.nav-tabs .nav-item { margin-bottom: -1px; }
.nav-tabs .nav-link {
    display: block;
    padding: 0.5rem 1rem;
    color: #596059;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 0.25rem 0.25rem 0 0;
}
.nav-tabs .nav-link:hover { color: #44664a; }
.nav-tabs .nav-link.active {
    color: #191c1c;
    background: #fff;
    border-color: #c2c8bf #c2c8bf #fff;
}
.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.show.active { display: block; }

/* --- Global cursor --------------------------------- */
button, input[type="submit"], input[type="button"], input[type="reset"] { cursor: pointer; }

/* --- Buttons --------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    font-family: Manrope, Gadugi, Arial, sans-serif;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.5;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.75rem; }
.bys-btn-primary,
.btn-primary {
    background-color: #44664a;
    color: #fff;
    border-color: #44664a;
}
.bys-btn-primary:hover,
.btn-primary:hover { background-color: #36513b; border-color: #36513b; color: #fff; }
.btn-secondary {
    background-color: #fff;
    color: #44664a;
    border-color: #727971;
}
.btn-secondary:hover { background-color: #edf3ed; }
.btn-danger { background-color: #ba1a1a; color: #fff; border-color: #ba1a1a; }
.btn-danger:hover { background-color: #93000a; }
.btn-info { background-color: #0284c7; color: #fff; border-color: #0284c7; }
.btn-outline-info { color: #0284c7; border-color: #0284c7; background: transparent; }
.btn-outline-danger { color: #ba1a1a; border-color: #ba1a1a; background: transparent; }
.btn-outline-danger:hover { background-color: #ffdad6; }

/* --- Forms ----------------------------------------- */
.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #191c1c;
    background-color: #f0f2f0;
    border: 1px solid #c2c8bf;
    border-radius: 0.75rem;
    outline: none;
    font-family: Manrope, Gadugi, Arial, sans-serif;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}
.form-control:focus { border-color: #44664a; box-shadow: none; }
.form-group { margin-bottom: 1rem; }
.control-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #596059;
    margin-bottom: 0.375rem;
}
.form-horizontal .form-group {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
}

/* --- Bootstrap-compatible grid (minimal) ----------- */
.row { display: flex; flex-wrap: wrap; margin-left: -0.75rem; margin-right: -0.75rem; }
[class*="col-"] { padding-left: 0.75rem; padding-right: 0.75rem; box-sizing: border-box; width: 100%; }
@media (min-width: 768px) {
    .col-md-2  { width: 16.6667%; }
    .col-md-3  { width: 25%; }
    .col-md-4  { width: 33.3333%; }
    .col-md-5  { width: 41.6667%; }
    .col-md-6  { width: 50%; }
    .col-md-8  { width: 66.6667%; }
    .col-md-10 { width: 83.3333%; }
    .col-md-12 { width: 100%; }
}

/* --- Alerts (used by _MessageToasts hidden divs) --- */
.alert { padding: 0.75rem 1rem; border-radius: 0.5rem; margin-bottom: 0; }
.alert-success { background-color: #c6ecc8; color: #44664a; }
.alert-info    { background-color: #dae2d9; color: #44664a; }
.alert-danger  { background-color: #ffdad6; color: #ba1a1a; }

/* --- Text utilities -------------------------------- */
.text-danger  { color: #ba1a1a !important; }
.text-success { color: #44664a !important; }
.text-warning { color: #856404 !important; }
.text-muted   { color: #596059 !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-left    { text-align: left; }

/* --- Visibility / display -------------------------- */
.d-none  { display: none !important; }
.d-block { display: block !important; }
.hidden  { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* --- Spacing / layout ------------------------------ */
.w-100       { width: 100%; }
.mt-1        { margin-top: 0.25rem; }
.mt-2        { margin-top: 0.5rem; }
.mt-3        { margin-top: 1rem; }
.mb-0        { margin-bottom: 0; }
.mb-1        { margin-bottom: 0.25rem; }
.mb-2        { margin-bottom: 0.5rem; }
.mb-3        { margin-bottom: 1rem; }
.mb-4        { margin-bottom: 1.5rem; }
.m-0         { margin: 0; }
.p-0         { padding: 0; }
.float-right { float: right; }
.center      { display: block; margin-left: auto; margin-right: auto; }
.centertext  { text-align: center; }
.center.centertext { text-align: center; margin-left: auto; margin-right: auto; }

/* --- Close button ---------------------------------- */
.close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: #596059;
    padding: 0.25rem;
    opacity: 0.7;
}
.close:hover { opacity: 1; }

/* --- Modal structural sections --------------------- */
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e7e8e7;
}
.modal-title { margin: 0; font-size: 1.125rem; font-weight: 700; color: #191c1c; line-height: 1.3; }
.modal-body { padding: 1.25rem; flex: 1 1 auto; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid #e7e8e7;
}

/* --- Additional spacing / layout ------------------- */
.pt-1  { padding-top: 0.25rem; }
.pt-2  { padding-top: 0.5rem; }
.pt-3  { padding-top: 1rem; }
.pb-1  { padding-bottom: 0.25rem; }
.pb-2  { padding-bottom: 0.5rem; }
.pr-1  { padding-right: 0.25rem; }
.pr-2  { padding-right: 0.5rem; }
.pr-3  { padding-right: 1rem; }
.pr-4  { padding-right: 1.5rem; }
.pl-1  { padding-left: 0.25rem; }
.pl-2  { padding-left: 0.5rem; }
.ml-1  { margin-left: 0.25rem; }
.ml-2  { margin-left: 0.5rem; }
.mr-1  { margin-right: 0.25rem; }
.mr-2  { margin-right: 0.5rem; }
.small { font-size: 0.875rem; }
.w-75  { width: 75%; }
.w-50  { width: 50%; }
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.flex-column { flex-direction: column; }
.gap-2 { gap: 0.5rem; }
.m-1   { margin: 0.25rem; }
.m-2   { margin: 0.5rem; }

/* --- Responsive columns (sm breakpoint) ------------ */
@media (min-width: 576px) {
    .col-sm-12 { width: 100%; }
    .col-sm-6  { width: 50%; }
    .col-sm-4  { width: 33.3333%; }
}

/* --- Form row -------------------------------------- */
.form-row { display: flex; flex-wrap: wrap; margin-left: -0.375rem; margin-right: -0.375rem; }
.form-row > [class*="col-"] { padding-left: 0.375rem; padding-right: 0.375rem; }
.form-row > .form-group { margin-bottom: 0.75rem; }

/* --- Typography ------------------------------------ */
.font-weight-bold { font-weight: 700 !important; }
.font-weight-semibold { font-weight: 600 !important; }
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem; }

/* --- Additional buttons ---------------------------- */
.btn-default { background-color: #fff; color: #191c1c; border-color: #c2c8bf; }
.btn-default:hover { background-color: #f0f2f0; }
.btn-link { background: none; border: none; color: #44664a; text-decoration: underline; cursor: pointer; padding: 0; font-size: inherit; }

/* --- Layout containers ----------------------------- */
.container {
    width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    margin-right: auto;
    margin-left: auto;
}
@media (min-width: 576px)  { .container { max-width: 540px; } }
@media (min-width: 768px)  { .container { max-width: 720px; } }
@media (min-width: 992px)  { .container { max-width: 960px; } }
@media (min-width: 1200px) { .container { max-width: 1140px; } }
.container-fluid { width: 100%; padding-right: 0.75rem; padding-left: 0.75rem; margin-right: auto; margin-left: auto; }

/* --- Navbar compatibility (legacy views) ----------- */
.navbar { display: flex; align-items: center; padding: 0.5rem 1rem; }
