/* ==========================================================================
   Modais do mapa no padrão de diálogo do RastreCob Lite.
   Carregado depois de modal-rastrecob.css (Frontend/Layouts/partials/head).
   A cor principal vem do tema escolhido em Aparência (--rc-blue, definido
   por assets/js/menu-theme.js); o modo escuro segue body.rc-dark-theme.
   ========================================================================== */
body .modal {
    --ml-brand: var(--rc-blue, #0b63e5);
    --ml-brand-deep: var(--rc-blue-deep, #084bb3);
    --ml-brand-soft: var(--rc-blue-soft, #e8f1ff);
    --ml-ink: #12233f;
    --ml-ink-soft: #35445b;
    --ml-muted: #68758a;
    --ml-line: #dce5f0;
    --ml-row-line: #edf2f8;
    --ml-surface: #ffffff;
    --ml-surface-soft: #f7faff;
    --ml-hover: #f8fbff;
    --ml-input-bg: #ffffff;
    --ml-input-border: #c7d3e2;
    --ml-th: #8090a8;
    --ml-shadow: 0 18px 45px rgba(18, 42, 78, .16);
    --rc-modal-accent: var(--ml-brand);
    --rc-modal-surface: var(--ml-surface);
    --rc-modal-surface-muted: var(--ml-surface-soft);
    --rc-modal-text: var(--ml-ink);
    --rc-modal-title: var(--ml-ink);
    --rc-modal-muted: var(--ml-muted);
    --rc-modal-line: var(--ml-line);
    --rc-modal-shadow: var(--ml-shadow);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.rc-dark-theme .modal,
body.admin-theme-dark .modal {
    --ml-brand-soft: color-mix(in srgb, var(--ml-brand) 20%, #121b2b);
    --ml-ink: #e6edf7;
    --ml-ink-soft: #c3cfdf;
    --ml-muted: #93a3b8;
    --ml-line: #26344a;
    --ml-row-line: #1e2b3f;
    --ml-surface: #121b2b;
    --ml-surface-soft: #162236;
    --ml-hover: #17243a;
    --ml-input-bg: #0e1727;
    --ml-input-border: #2e3f58;
    --ml-th: #93a3b8;
    --ml-shadow: 0 18px 45px rgba(0, 0, 0, .45);
    color-scheme: dark;
}

/* Fundo escurecido com leve desfoque */
body .modal-backdrop.in { opacity: .54; }
body .modal-backdrop { background: rgb(10 20 17); }
@supports (backdrop-filter: blur(2px)) {
    body .modal-backdrop.in { opacity: .5; backdrop-filter: blur(2px); }
}

/* Caixa */
body .modal .modal-content {
    overflow: hidden;
    border: 0;
    border-radius: 16px;
    background: var(--ml-surface);
    color: var(--ml-ink);
    box-shadow: var(--ml-shadow);
}

/* Cabeçalho: título forte e botão fechar quadrado com borda */
body .modal .modal-header {
    min-height: 0;
    padding: 22px 70px 16px 26px;
    border-bottom: 1px solid var(--ml-line);
    border-radius: 0;
    background: var(--ml-surface);
}
body .modal .modal-title {
    color: var(--ml-ink);
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1.25;
}
body .modal .modal-title > i,
body .modal .modal-title [class*="icon-"],
body .modal .modal-title .fa { color: var(--ml-brand); }
body .modal .modal-header .close {
    top: 18px;
    right: 20px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--ml-line);
    border-radius: 9px;
    background: transparent;
    color: var(--ml-muted);
    font-size: 22px;
}
body .modal .modal-header .close:hover,
body .modal .modal-header .close:focus-visible {
    border-color: color-mix(in srgb, var(--ml-brand) 35%, var(--ml-line));
    background: var(--ml-brand-soft);
    color: var(--ml-brand);
}

/* Corpo */
body .modal .modal-body {
    padding: 22px 26px;
    background: var(--ml-surface);
    color: var(--ml-ink);
}
body .modal .modal-body > p,
body .modal .help-block,
body .modal .modal-body small { color: var(--ml-muted); }

/* Rótulos e campos */
body .modal label,
body .modal .control-label {
    color: var(--ml-ink);
    font-size: 12px;
    font-weight: 750;
}
body .modal .form-control:not(.bootstrap-select),
body .modal .bootstrap-select > .dropdown-toggle,
body .modal .input-group-addon {
    min-height: 42px;
    border: 1px solid var(--ml-input-border);
    border-radius: 8px;
    background-color: var(--ml-input-bg);
    color: var(--ml-ink);
    box-shadow: none;
    font-size: 13px;
}
body .modal .input-group > .form-control:not(:last-child),
body .modal .input-group > .input-group-addon:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
body .modal .input-group > .form-control:not(:first-child),
body .modal .input-group > .input-group-addon:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
body .modal .input-group-addon { background: var(--ml-surface-soft); color: var(--ml-muted); }
body .modal textarea.form-control { min-height: 86px; line-height: 1.5; }
body .modal .bootstrap-select:not(.input-group-btn),
body .modal .bootstrap-select.form-control { height: auto !important; min-height: 42px; }
body .modal .form-control:focus,
body .modal .bootstrap-select > .dropdown-toggle:focus,
body .modal .bootstrap-select.open > .dropdown-toggle {
    border-color: var(--ml-brand);
    outline: 3px solid color-mix(in srgb, var(--ml-brand) 28%, transparent) !important;
    outline-offset: 0;
    box-shadow: none;
}
body .modal .form-control::placeholder { color: #8795a9; }
body .modal .form-control[disabled],
body .modal .form-control[readonly] { background: var(--ml-surface-soft); color: var(--ml-muted); }
body .modal .form-control + small,
body .modal .bootstrap-select + small { display: block; margin-top: 6px; font-size: 11.5px; }

/* Abas no estilo segmentado do Lite */
body .modal .nav-tabs.nav-default {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 0 0 18px;
    padding: 6px;
    overflow-x: auto;
    border: 1px solid var(--ml-line);
    border-radius: 12px;
    background: var(--ml-surface);
}
body .modal .nav-tabs.nav-default::before,
body .modal .nav-tabs.nav-default::after { display: none; }
body .modal .nav-tabs.nav-default > li { float: none; flex: 0 0 auto; margin: 0; }
body .modal .nav-tabs.nav-default.nav-justified > li { flex: 1 1 0; }
body .modal .nav-tabs.nav-default > li > a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    margin: 0;
    padding: 0 14px;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--ml-muted) !important;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
body .modal .nav-tabs.nav-default > li > a:hover { background: var(--ml-brand-soft) !important; color: var(--ml-brand) !important; }
body .modal .nav-tabs.nav-default > li.active > a,
body .modal .nav-tabs.nav-default > li.active > a:hover,
body .modal .nav-tabs.nav-default > li.active > a:focus {
    background: var(--ml-brand) !important;
    color: #fff !important;
}

/* Barra de ícones dentro de modais (ex.: adicionar em tabelas) */
body .modal .nav-tabs.nav-icons { border: 0; }
body .modal .nav-tabs.nav-icons > li > a:not(#ml) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    border: 1px solid var(--ml-line) !important;
    border-radius: 9px !important;
    background: var(--ml-surface) !important;
    color: var(--ml-ink) !important;
    box-shadow: none !important;
}
body .modal .nav-tabs.nav-icons > li > a:not(#ml):hover {
    border-color: color-mix(in srgb, var(--ml-brand) 35%, var(--ml-line)) !important;
    background: var(--ml-brand-soft) !important;
    color: var(--ml-brand) !important;
}

/* Tabelas */
body .modal .table > thead > tr > th {
    padding: 11px 13px;
    border-bottom: 1px solid var(--ml-line) !important;
    background: var(--ml-surface-soft);
    color: var(--ml-th);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}
body .modal .table > tbody > tr > td {
    padding: 11px 13px;
    border-top: 0;
    border-bottom: 1px solid var(--ml-row-line);
    vertical-align: middle;
}
body .modal .table > tbody > tr:hover > td { background: var(--ml-hover); }
body .modal .table-striped > tbody > tr:nth-of-type(odd) { background: transparent; }
body .modal .table-responsive { border: 1px solid var(--ml-line); border-radius: 12px; }

/* Rodapé e botões */
body .modal .modal-footer {
    padding: 14px 26px 20px;
    border-top: 1px solid var(--ml-line);
    border-radius: 0;
    background: var(--ml-surface);
}
body .modal .modal-footer .btn,
body .modal .modal-footer .buttons .btn,
body .modal .modal-body .btn:not(.dropdown-toggle):not(.btn-xs):not(.btn-link) {
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 750;
}
body .modal .btn-action,
body .modal .btn-primary {
    border-color: var(--ml-brand) !important;
    background-color: var(--ml-brand) !important;
    color: #fff !important;
}
body .modal .btn-action:hover,
body .modal .btn-primary:hover {
    border-color: var(--ml-brand-deep) !important;
    background-color: var(--ml-brand-deep) !important;
}
body .modal .btn-default {
    border: 1px solid var(--ml-line);
    background: var(--ml-surface);
    color: var(--ml-ink);
}
body .modal .btn-default:hover {
    border-color: var(--ml-input-border);
    background: var(--ml-hover);
    color: var(--ml-ink);
}
body .modal .btn-danger { border-color: #b43d3d; background: #b43d3d; color: #fff; }

/* Alertas dentro do modal */
body .modal .alert { border-radius: 10px; font-size: 13px; }

/* Celular */
@media (max-width: 560px) {
    body .modal .modal-header { padding: 18px 62px 14px 18px; }
    body .modal .modal-header .close { top: 14px; right: 14px; }
    body .modal .modal-title { font-size: 18px; }
    body .modal .modal-body { padding: 18px; }
    body .modal .modal-footer { padding: 12px 18px 16px; }
}

/* ==========================================================================
   Painéis laterais de criação/edição do mapa no mesmo padrão dos modais:
   Cercas Virtuais, Pontos de Interesse e Rotas.
   ========================================================================== */
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) {
    --ml-brand: var(--rc-blue, #0b63e5);
    --ml-brand-deep: var(--rc-blue-deep, #084bb3);
    --ml-brand-soft: var(--rc-blue-soft, #e8f1ff);
    --ml-ink: #12233f;
    --ml-muted: #68758a;
    --ml-line: #dce5f0;
    --ml-surface: #ffffff;
    --ml-surface-soft: #f7faff;
    --ml-hover: #f8fbff;
    --ml-input-bg: #ffffff;
    --ml-input-border: #c7d3e2;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ml-ink);
}
body.rc-dark-theme :is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) {
    --ml-brand-soft: color-mix(in srgb, var(--ml-brand) 20%, #121b2b);
    --ml-ink: #e6edf7;
    --ml-muted: #93a3b8;
    --ml-line: #26344a;
    --ml-surface: #121b2b;
    --ml-surface-soft: #162236;
    --ml-hover: #17243a;
    --ml-input-bg: #0e1727;
    --ml-input-border: #2e3f58;
}

/* Espaçamento interno */
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) :is(.tab-pane-header, .tab-pane-body) {
    padding-left: 18px !important;
    padding-right: 18px !important;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-header { padding-top: 16px !important; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .form-group { margin-bottom: 14px; }

/* Aviso ("Por favor, desenhe…") como dica do Lite */
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .alert-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--ml-brand) 25%, var(--ml-line));
    border-radius: 10px;
    background: var(--ml-brand-soft);
    color: color-mix(in srgb, var(--ml-brand) 65%, var(--ml-ink));
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .alert-info::before {
    content: "i";
    flex: 0 0 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ml-brand);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
}

/* Rótulos e campos (antes arredondados em pílula) */
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) label {
    margin-bottom: 6px;
    color: var(--ml-ink);
    font-size: 12px;
    font-weight: 750;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) :is(.form-control:not(.bootstrap-select), .bootstrap-select > .dropdown-toggle) {
    min-height: 42px;
    border: 1px solid var(--ml-input-border) !important;
    border-radius: 8px !important;
    background-color: var(--ml-input-bg) !important;
    color: var(--ml-ink) !important;
    box-shadow: none !important;
    font-size: 13px;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) textarea.form-control { min-height: 86px; line-height: 1.5; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .bootstrap-select:not(.input-group-btn) { height: auto !important; min-height: 42px; border-radius: 8px !important; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) :is(.form-control:focus, .bootstrap-select > .dropdown-toggle:focus, .bootstrap-select.open > .dropdown-toggle) {
    border-color: var(--ml-brand) !important;
    outline: 3px solid color-mix(in srgb, var(--ml-brand) 28%, transparent) !important;
    outline-offset: 0;
}

/* Grupo + botão "adicionar grupo" lado a lado, mesmo tamanho */
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group > :first-child { flex: 1 1 auto; min-width: 0; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn { display: block; width: auto; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn > .btn:not(#ml) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    border: 1px solid var(--ml-brand) !important;
    border-radius: 8px !important;
    background: var(--ml-brand) !important;
    color: #fff !important;
    box-shadow: none !important;
    transform: none !important;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn > .btn:not(#ml):hover { background: var(--ml-brand-deep) !important; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn > .btn:not(#ml) > .icon.add {
    position: relative;
    width: 16px;
    height: 16px;
    background: none !important;
    font-size: 0;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn > .btn:not(#ml) > .icon.add::before,
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn > .btn:not(#ml) > .icon.add::after {
    content: "" !important;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 2.2px;
    border-radius: 2px;
    background: #fff;
    transform: translate(-50%, -50%);
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .input-group-btn > .btn:not(#ml) > .icon.add::after { transform: translate(-50%, -50%) rotate(90deg); }

/* Ícones do marcador (Pontos de Interesse): grade com o selecionado contornado na cor principal */
:is(#pois_create, #pois_edit) .icon-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--ml-line);
    border-radius: 12px;
    background: var(--ml-surface-soft);
}
:is(#pois_create, #pois_edit) .icon-list .checkbox { margin: 0 !important; padding: 0; }
:is(#pois_create, #pois_edit) .icon-list .checkbox label {
    display: grid;
    place-items: center;
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent !important;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
:is(#pois_create, #pois_edit) .icon-list .checkbox label::before,
:is(#pois_create, #pois_edit) .icon-list .checkbox label::after { display: none !important; }
:is(#pois_create, #pois_edit) .icon-list .checkbox label:hover { border-color: var(--ml-line); background: var(--ml-surface) !important; }
:is(#pois_create, #pois_edit) .icon-list .checkbox input:checked + label {
    border-color: var(--ml-brand);
    background: var(--ml-brand-soft) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ml-brand) 25%, transparent);
}
:is(#pois_create, #pois_edit) .icon-list .checkbox label img { max-width: 30px; max-height: 30px; }

/* Rodapé com Salvar e Cancelar no padrão do Lite, fixo embaixo do painel */
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding: 12px 18px 16px !important;
    border-top: 1px solid var(--ml-line);
    background: var(--ml-surface);
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer .buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer .btn:not(#ml) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin: 0 !important;
    padding: 8px 14px !important;
    border-radius: 9px !important;
    box-shadow: none !important;
    font-size: 13px;
    font-weight: 750;
    transform: none !important;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer .btn-action:not(#ml) {
    border: 1px solid var(--ml-brand) !important;
    background: var(--ml-brand) !important;
    color: #fff !important;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer .btn-action:not(#ml):hover { background: var(--ml-brand-deep) !important; }
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer .btn-default:not(#ml) {
    border: 1px solid var(--ml-line) !important;
    background: var(--ml-surface) !important;
    color: var(--ml-ink) !important;
}
:is(#geofencing_create, #geofencing_edit, #pois_create, #pois_edit, #routes_create, #routes_edit) .tab-pane-footer .btn-default:not(#ml):hover { border-color: var(--ml-input-border) !important; background: var(--ml-hover) !important; }
