/*
 * SMATECH shared UI fixes. Loaded after bootstrap/app.min.css by the layout and the login pages.
 * Replaces the inline <style> block that used to live in _Layout.cshtml, which set labels to
 * 1.2rem, inputs to 1.5rem, h6 to 1.6rem, etc. - the "big and small letters" on every page.
 */

/* ---------- Typography: one consistent scale ---------- */
body { font-size: 0.875rem; }

label,
.form-label { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; }
.form-check-label { font-weight: 400; }

input,
select,
textarea,
.form-control,
.form-select { font-size: 0.875rem; }

input[type="text"].form-control,
input[type="number"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
input[type="date"].form-control { padding: 0.47rem 0.75rem; height: auto; }

input[readonly] { color: #343a40; }

.btn { font-size: 0.875rem; }
.btn-sm { font-size: 0.8125rem; }

h6.m-0 { font-size: 0.95rem; }

/* Bare <select> elements (page size pickers, filters) look like Bootstrap selects. */
select:not(.form-select):not(.form-control):not([multiple]) {
    display: inline-block;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #495057;
    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 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 14px 10px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    appearance: none;
    -webkit-appearance: none;
}

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

/* select2 boxes fill their column (they were sized at load time and cut text like "All Zones"). */
.select2-container { width: 100% !important; max-width: 100%; }
.select2-container .select2-selection--single { height: calc(1.5em + 0.94rem + 2px); }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: calc(1.5em + 0.94rem); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: calc(1.5em + 0.94rem); }

/* Page titles: same size everywhere, no forced capitals. */
.page-title-box { padding-bottom: 1rem; }
.page-title-box h4,
h4.font-size-18 { font-size: 1.05rem !important; font-weight: 600; text-transform: none; margin-bottom: 0; }

/* ---------- Tables ---------- */
.table > :not(caption) > * > * { padding: 0.6rem 0.75rem; }
.table th,
.table td { font-size: 0.875rem; vertical-align: middle; }
.table th { font-weight: 600; white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: #556ee6; }
.table td label { font-size: inherit; font-weight: inherit; margin: 0; }
.table td label.badge,
.table td .badge { font-size: 0.75rem; font-weight: 600; }
.table-bordered > :not(caption) > * > * { border-color: #eff2f7; }

/* Tables that sat directly on the page get a white card + horizontal scroll (see smat-ui.js). */
.smat-table-card { padding: 0; overflow: hidden; }
.smat-table-card .table-responsive { margin: 0; }
.smat-table-card .table { margin-bottom: 0; }
.dataTables_scrollBody { min-height: 300px; }

/* Action dropdowns in table rows: plain menu items, not coloured button blocks. */
.dropdown-menu .dropdown-item.btn {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: #212529;
    font-size: 0.85rem;
    padding: 0.45rem 1.2rem;
}
.dropdown-menu .dropdown-item.btn:hover,
.dropdown-menu .dropdown-item.btn:focus { background: #f8f9fa; color: #16181b; }
.dropdown-menu .dropdown-item.btn-danger { color: #f46a6a; }

/* ---------- Cards placed directly in a .row (no column) ---------- */
/* Bootstrap gives row children the gutter padding and full width, so these cards stuck out
   past the cards next to them. */
.row > .card {
    width: calc(100% - var(--bs-gutter-x));
    max-width: calc(100% - var(--bs-gutter-x));
    padding-left: 0;
    padding-right: 0;
    margin-left: calc(var(--bs-gutter-x) * 0.5);
    margin-right: calc(var(--bs-gutter-x) * 0.5);
}

/* ---------- List page toolbar: page size + search + pagination (classes added by smat-ui.js) ---------- */
.smat-toolbar-card { margin-bottom: 1rem; }
.smat-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 0.75rem 1rem; }
.smat-toolbar > * { margin: 0 !important; }
.smat-toolbar .flex-grow-1 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; min-width: 0; }

/* Search / filters: one wrapping row. Filter boxes share the width evenly, the search box gets
   more, the Search button keeps its natural size. A plain search box (no filters) may sit next
   to the pager; a filter row (.smat-filters, set by smat-ui.js) gets its own line. */
.smat-toolbar form,
.smat-toolbar .flex-grow-1 > .row { flex: 1 1 360px; order: 1; margin: 0; min-width: 0; }
.smat-toolbar form.smat-filters,
.smat-toolbar .flex-grow-1 > .row.smat-filters { flex-basis: 100%; }
.smat-toolbar form .row,
.smat-toolbar .flex-grow-1 > .row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; --bs-gutter-x: 0; }
.smat-toolbar form .row > [class*="col-"],
.smat-toolbar .flex-grow-1 > .row > [class*="col-"] { flex: 1 1 180px; width: auto; max-width: 100%; min-width: 0; padding: 0; margin-top: 0 !important; }
.smat-toolbar .row > .col-md-9,
.smat-toolbar .row > .col-md-10 { flex: 2 1 260px; }
.smat-toolbar .row > .col-md-1,
.smat-toolbar .row > .col-md-2 { flex: 0 0 auto; }
.smat-toolbar .btn { margin: 0 !important; white-space: nowrap; }

/* Pager column: after the filters, right-aligned. */
.smat-toolbar .flex-grow-1 > [class*="col-"] { order: 2; flex: 1 1 auto; width: auto; max-width: 100%; min-width: 0; padding: 0; display: flex; justify-content: flex-end; }
.smat-pagesize { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.smat-pagesize label { margin: 0; font-weight: 400; color: #74788d; }
.smat-pagesize .form-select { width: auto; padding-right: 2rem; }
.smat-pager-card .smat-toolbar { justify-content: flex-end; }
.smat-pager-card .smat-toolbar .flex-grow-1 { justify-content: flex-end; }

/* Pagination */
.pagination { flex-wrap: wrap; gap: 4px; margin-bottom: 0; }
/* Page buttons wrap as whole buttons; a number like 32 never breaks into "3" over "2". */
.smat-pager { justify-content: flex-end; }
.smat-pager .page-item { flex: 0 0 auto; }
.smat-pager .page-link { white-space: nowrap; border-radius: 6px !important; min-width: 34px; text-align: center; padding: 0.35rem 0.65rem; font-size: 0.85rem; line-height: 1.4; }
.smat-pager .page-item.active .page-link { background-color: #556ee6; border-color: #556ee6; color: #fff; }

/* ---------- Header ---------- */
#page-topbar .navbar-brand-box { overflow: hidden; }
#page-topbar .navbar-brand-box img { max-width: 180px; object-fit: contain; }
/* The small logo (collapsed menu / narrow screens) is the same wide company image; keep it inside
   its box so it doesn't run under the menu button. */
#page-topbar .navbar-brand-box .logo-sm img { max-width: 46px; max-height: 34px; width: auto; height: auto; }

/* One focus style for text boxes (some showed a plain black outline). */
.form-control:focus,
.form-select:focus { border-color: #a6b2f1; box-shadow: 0 0 0 0.15rem rgba(85, 110, 230, 0.15); outline: 0; }
#page-topbar .company-name { padding-left: 0.5rem; }
#page-topbar .company-title {
    display: inline-block;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.05rem;
    font-weight: 600;
    color: #495057;
    padding: 0.35rem 0.85rem;
    border: 1px solid #e9ebec;
    border-radius: 6px;
    background: #f8f9fa;
}
.header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #556ee6;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.header-user-text { line-height: 1.15; }
.header-user-name { font-weight: 600; font-size: 0.85rem; color: #495057; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-user-role { font-size: 0.75rem; color: #74788d; }

/* ---------- Sidebar ---------- */
/* Fixed under the header with its own scroll; long labels are cut off instead of wrapping. */
.vertical-menu { position: fixed; top: 70px; bottom: 0; }
.vertical-menu > [data-simplebar] { height: 100%; }
#sidebar-menu { padding-bottom: 30px; }
#sidebar-menu ul li a { font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar-menu ul li ul.sub-menu li a { font-size: 0.8125rem; }
body[data-sidebar=dark] .navbar-brand-box { background: transparent; }
body[data-sidebar=dark] #sidebar-menu ul li a:hover { color: #fff; }
body[data-sidebar=dark] #sidebar-menu ul li a:hover i { color: #fff; }
/* Collapsed (icon-only) sidebar: keep it fixed too so it doesn't scroll away with the page. */
@media (min-width: 992px) {
    body.vertical-collpsed .vertical-menu { position: fixed; }
}

/* ---------- Dashboard contacts ---------- */
.dashboard-contacts .dashboard-contacts-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #74788d;
    padding: 0.75rem 1rem 0.35rem;
}
.dashboard-contacts .dashboard-contacts-title:first-child { padding-top: 0; }
.dashboard-contacts .nav-link { padding: 0.45rem 1rem; margin-bottom: 2px; color: #495057; }
.dashboard-contacts .nav-link.active { color: #fff; }
.dashboard-address { min-height: 0 !important; resize: none; }

/* Customer (view-only) logins: add/edit/delete controls are hidden by smat-ui.js. */
.smat-hidden-edit { display: none !important; }

/* Row action menus in tables float above the scroll box (smat-ui.js floatTableMenus).
   The theme pins open menus to top:100% / right:0 and slides them in with a transform animation;
   both would override the position Popper sets, so they are switched off here. */
.dropdown-menu.smat-float-menu.show { top: 0 !important; left: 0 !important; right: auto !important; bottom: auto !important; animation: none !important; }

/* ---------- Misc ---------- */
.alert { margin-top: 0; }
.company-name h2 { border: 0; padding: 0; }

.smat-messages .smat-message-link {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-left: 4px solid #556ee6;
    background: #f8f9fa;
    border-radius: 4px;
    color: #495057;
    text-decoration: none;
}
.smat-messages .smat-message-link:hover { background: #eef0fd; }

/* Loader overlay (showLoader / hideLoader) */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: none;
}
.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #556ee6;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: smat-spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
@keyframes smat-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
@media (max-width: 576px) {
    .smat-toolbar form .row,
    .smat-toolbar .flex-grow-1 > .row { flex-wrap: wrap; }
    .smat-toolbar .flex-grow-1 > .row > [class*="col-"] { flex: 1 1 100%; width: 100%; }
    .smat-toolbar .flex-grow-1 > .row > .col-md-1 { flex: 0 0 auto; width: auto; }
}
@media (max-width: 768px) {
    .loader { width: 40px; height: 40px; border-width: 4px; }
    .page-content { padding-left: 0.25rem; padding-right: 0.25rem; }
    .smat-toolbar .flex-grow-1 > [class*="col-"] { margin-left: 0; }
}

/* ---------- Login / activation pages ---------- */
.auth-body { background: #f8f8fb; }
.login-type .btn { font-size: 0.85rem; }
