/**
 * Bootstrap Scoped Styles — mrserver-crm2
 * Extracted from Bootstrap 5.3.3 and scoped to avoid global conflicts.
 * Form/button/utility rules scoped under .mrserver-crm-form-wrapper.
 * Modal rules at root level (Bootstrap JS appends modals to <body>).
 */

/* ============================================================
   UTILITIES — scoped
   ============================================================ */
.mrserver-crm-form-wrapper .d-none { display: none !important; }
.mrserver-crm-form-wrapper .mt-3  { margin-top: 1rem !important; }
.mrserver-crm-form-wrapper .ms-2  { margin-left: 0.5rem !important; }

/* ============================================================
   TYPOGRAPHY — scoped
   ============================================================ */
.mrserver-crm-form-wrapper .text-danger { color: #dc3545 !important; }
.mrserver-crm-form-wrapper .text-muted  { color: #6c757d !important; }

/* ============================================================
   FORM ELEMENTS — scoped
   ============================================================ */
.mrserver-crm-form-wrapper .form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.mrserver-crm-form-wrapper .form-group {
    margin-bottom: 1rem;
}

.mrserver-crm-form-wrapper .form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #6c757d;
}

.mrserver-crm-form-wrapper .form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
}

.mrserver-crm-form-wrapper .form-control:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.mrserver-crm-form-wrapper .form-control::placeholder {
    color: #6c757d;
    opacity: 1;
}

.mrserver-crm-form-wrapper .form-control:disabled {
    background-color: #e9ecef;
    opacity: 1;
}

.mrserver-crm-form-wrapper textarea.form-control {
    min-height: calc(1.5em + 0.75rem + 2px);
    resize: vertical;
}

.mrserver-crm-form-wrapper .form-select {
    display: block;
    width: 100%;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    appearance: none;
    box-sizing: border-box;
}

.mrserver-crm-form-wrapper .form-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* ============================================================
   BUTTONS — scoped
   ============================================================ */
.mrserver-crm-form-wrapper .btn {
    display: inline-block;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.375rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
                border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
}

.mrserver-crm-form-wrapper .btn:focus,
.mrserver-crm-form-wrapper .btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.mrserver-crm-form-wrapper .btn-primary {
    color: #fff;
    background-color: #0d6efd;
    border-color: #0d6efd;
}
.mrserver-crm-form-wrapper .btn-primary:hover {
    color: #fff;
    background-color: #0b5ed7;
    border-color: #0a58ca;
}
.mrserver-crm-form-wrapper .btn-primary:focus {
    box-shadow: 0 0 0 0.25rem rgba(49, 132, 253, 0.5);
}

.mrserver-crm-form-wrapper .btn-secondary {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}
.mrserver-crm-form-wrapper .btn-secondary:hover {
    color: #fff;
    background-color: #5c636a;
    border-color: #565e64;
}

/* ============================================================
   MODAL — root level (Bootstrap JS appends modals to <body>)
   ============================================================ */

/* fade transition */
.fade {
    transition: opacity 0.15s linear;
}
.fade:not(.show) {
    opacity: 0;
}

/* modal base */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

.modal.show {
    display: block;
}

/* modal backdrop — Bootstrap JS adds this to body */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: 0.5; }

/* modal dialog */
.modal-dialog {
    position: relative;
    width: auto;
    max-width: calc(100% - 1rem);
    margin: 0.5rem auto;
    pointer-events: none;
    /* allow internal scrolling without growing beyond viewport */
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 1rem);
}
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}
.modal.show .modal-dialog {
    transform: none;
}

/* ≥576px — centered, capped width */
@media (min-width: 576px) {
    .modal-dialog {
        max-width: 500px;
        margin: 1.75rem auto;
        max-height: calc(100vh - 3.5rem);
    }
}

/* modal-lg — medium screens use 90vw, large screens use 800px */
@media (min-width: 576px) {
    .modal-lg {
        max-width: min(90vw, 600px);
    }
}
@media (min-width: 992px) {
    .modal-lg {
        max-width: min(90vw, 800px);
    }
}

/* modal content wrapper */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;          /* allow flex children to shrink */
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    outline: 0;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* modal header / footer / body */
.modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: calc(0.5rem - 1px);
    border-top-right-radius: calc(0.5rem - 1px);
    background: #f8f9fa;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    border-top: 1px solid #dee2e6;
    border-bottom-right-radius: calc(0.5rem - 1px);
    border-bottom-left-radius: calc(0.5rem - 1px);
    gap: 0.5rem;
    background: #f8f9fa;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
    overflow-y: auto;       /* scroll if image is tall */
    min-height: 0;          /* required for flex overflow to work */
}

/* Cropper image container — fills body but respects max height */
.modal-body .img-container {
    width: 100%;
    max-height: 55vh;
    overflow: hidden;
    border-radius: 4px;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-body .img-container img {
    display: block;
    max-width: 100%;
    max-height: 55vh;
    object-fit: contain;
}

/* Mobile — tighter padding */
@media (max-width: 575.98px) {
    .modal-body {
        padding: 0.75rem;
    }
    .modal-body .img-container {
        max-height: 45vh;
    }
    .modal-body .img-container img {
        max-height: 45vh;
    }
    .modal-footer {
        padding: 0.5rem 0.75rem;
    }
    .modal-footer .btn {
        flex: 1;
        text-align: center;
    }
}

.modal-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-weight: 600;
    font-size: 1.05rem;
}

/* btn-close — used in modal header */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em 0.25em;
    color: #000;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.375rem;
    opacity: 0.5;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-close:hover  { opacity: 0.75; }
.btn-close:focus  { opacity: 1; outline: 0; box-shadow: 0 0 0 0.25rem rgba(13,110,253,0.25); }
