/* ============================================================
   ClinPlus — estilos base do SaaS
   Bootstrap 5.3 é carregado via CDN; aqui ficam só os ajustes.
   ============================================================ */

:root {
    --mc-primary: #3C55B4;
    --mc-primary-dark: #2f4391;
    --mc-sidebar-bg: #1e2538;
    --mc-sidebar-hover: #2b3450;
    --mc-sidebar-text: #aab3c5;
    --mc-sidebar-active: #ffffff;
    --mc-body-bg: #f4f6fb;

    /* Override do Bootstrap pra TUDO que usa "primary" seguir o tema da clínica.
       O shell-clinica.php injeta --mc-primary a partir da config do tenant. */
    --bs-primary: var(--mc-primary);
    --bs-primary-rgb: 60, 85, 180;
    --bs-link-color: var(--mc-primary);
    --bs-link-hover-color: var(--mc-primary-dark);

    --bs-nav-link-color: #475569;
    --bs-nav-link-hover-color: var(--mc-primary);
}

/* Bootstrap define --bs-nav-pills-link-active-bg direto em .nav-pills (maior
   especificidade que :root), então precisamos override no mesmo seletor. */
.nav-pills {
    --bs-nav-pills-link-active-bg: var(--mc-primary);
}

/* Tabs nav-pills inativas — fundo cinza claro pra dar definição visual.
   A ativa permanece colorida pelo Bootstrap via --bs-nav-pills-link-active-bg. */
.nav-pills .nav-link:not(.active):not(.dropdown-toggle) {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid transparent;
    transition: all .12s;
}
.nav-pills .nav-link:not(.active):not(.dropdown-toggle):hover {
    background: #e2e8f0;
    color: var(--mc-primary);
    border-color: rgba(60, 85, 180, .15);
}
.nav-pills .nav-link.dropdown-toggle {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.nav-pills .nav-link.dropdown-toggle:hover {
    background: #f1f5f9;
    color: var(--mc-primary);
    border-color: rgba(60, 85, 180, .2);
}
/* Dropdown item ativo (na overflow das tabs) */
.dropdown-item.active {
    background: var(--mc-primary);
    color: #fff;
}

body {
    background-color: var(--mc-body-bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { text-decoration: none; }

/* ---------- Botões / cor primária ---------- */
.btn-primary {
    --bs-btn-bg: var(--mc-primary);
    --bs-btn-border-color: var(--mc-primary);
    --bs-btn-hover-bg: var(--mc-primary-dark);
    --bs-btn-hover-border-color: var(--mc-primary-dark);
    --bs-btn-active-bg: var(--mc-primary-dark);
}
.text-primary { color: var(--mc-primary) !important; }
.link-primary { color: var(--mc-primary) !important; }

/* ============================================================
   Layout com sidebar
   ============================================================ */
.mc-layout { display: flex; min-height: 100vh; }

.mc-sidebar {
    width: 256px;
    background: var(--mc-sidebar-bg);
    color: var(--mc-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1030;
    transition: transform .25s ease;
}
.mc-sidebar__brand {
    padding: 20px 22px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.mc-sidebar__brand strong { color: #fff; font-size: 1.15rem; }
.mc-sidebar__brand small { color: var(--mc-sidebar-text); }

.mc-sidebar__nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.mc-sidebar__nav .nav-section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #5d6883;
    padding: 14px 12px 6px;
}
.mc-sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--mc-sidebar-text);
    font-size: .92rem;
    margin-bottom: 2px;
}
.mc-sidebar__nav a:hover { background: var(--mc-sidebar-hover); color: #fff; }
.mc-sidebar__nav a.active { background: var(--mc-primary); color: #fff; }
.mc-sidebar__nav a i { font-size: 1.05rem; }

.mc-sidebar__footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
    font-size: .85rem;
}

.mc-main {
    flex: 1;
    margin-left: 256px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.mc-topbar {
    background: #fff;
    border-bottom: 1px solid #e6e9f0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.mc-content { padding: 26px 24px; flex: 1; }

/* ---------- Cards ---------- */
.card { border: 1px solid #e6e9f0; border-radius: 12px; }
.card-kpi .kpi-value { font-size: 1.7rem; font-weight: 700; }
.card-kpi .kpi-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}

/* ---------- Tabelas ---------- */
.table > :not(caption) > * > * { padding: .8rem .9rem; }
.table thead th {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #7b8499;
    border-bottom-width: 1px;
}

/* ---------- Badges de status ---------- */
.badge-status { font-weight: 600; padding: .4em .7em; border-radius: 6px; }
.badge-trial      { background: #fff3cd; color: #8a6d00; }
.badge-ativo,
.badge-ativa      { background: #d1f0dd; color: #1a7a40; }
.badge-suspenso,
.badge-suspensa,
.badge-inadimplente { background: #fde2e1; color: #b32d2a; }
.badge-cancelado,
.badge-cancelada  { background: #e6e9f0; color: #6c757d; }

/* ============================================================
   Tela de login / autenticação
   ============================================================ */
.mc-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3C55B4 0%, #2f4391 100%);
    padding: 24px;
}
.mc-auth__card {
    width: 100%;
    max-width: 410px;
    background: #fff;
    border-radius: 16px;
    padding: 38px 34px;
    box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.mc-auth__logo { text-align: center; margin-bottom: 6px; }
.mc-auth__logo strong { font-size: 1.4rem; color: var(--mc-primary); }

/* ============================================================
   Responsivo — sidebar vira off-canvas no mobile
   ============================================================ */
.mc-sidebar__backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1029;
}
@media (max-width: 991.98px) {
    .mc-sidebar { transform: translateX(-100%); }
    .mc-sidebar.is-open { transform: translateX(0); }
    .mc-sidebar.is-open + .mc-sidebar__backdrop { display: block; }
    .mc-main { margin-left: 0; }
    .mc-toggle-sidebar { display: inline-flex !important; }
}
.mc-toggle-sidebar { display: none; }

/* ============================================================
   Painel da Clínica — layout amplo + sidebar "trilho de ícones"
   Recolhida (só ícones) por padrão · tooltip no hover ·
   flyout de submenus no clique · pode ser fixada expandida.
   ============================================================ */
.mc-clinic { display: flex; min-height: 100vh; }

.mc-rail {
    width: 70px;
    background: var(--mc-sidebar-bg);
    color: var(--mc-sidebar-text);
    position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 1040;
    display: flex; flex-direction: column;
    transition: width .2s ease;
}
.mc-clinic.rail-expanded .mc-rail { width: 244px; }

.mc-rail__brand {
    height: 60px; display: flex; align-items: center; justify-content: center;
    gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    overflow: hidden; white-space: nowrap;
}
.mc-clinic.rail-expanded .mc-rail__brand { justify-content: flex-start; padding-left: 22px; }
/* Fechado: só o ícone. Aberto: só o logo branco. */
.mc-rail__brand-icon { width: 34px; height: 34px; object-fit: contain; }
.mc-clinic.rail-expanded .mc-rail__brand-icon { display: none; }
.mc-rail__brand-logo { display: none; height: 34px; object-fit: contain; }
.mc-clinic.rail-expanded .mc-rail__brand-logo { display: inline-block; }

.mc-rail__nav { flex: 1; padding: 10px 0; overflow-y: auto; overflow-x: hidden; }

.mc-rail__item {
    position: relative;
    display: flex; align-items: center; gap: 14px;
    width: 100%; border: 0; background: transparent; text-align: left;
    color: var(--mc-sidebar-text);
    padding: 12px 0 12px 23px;
    cursor: pointer; font-size: .9rem; white-space: nowrap;
}
.mc-rail__item:hover { background: var(--mc-sidebar-hover); color: #fff; }
.mc-rail__item.active { color: #fff; box-shadow: inset 3px 0 0 #fff; background: var(--mc-primary); }
.mc-rail__item i.mc-rail__icon { font-size: 1.2rem; min-width: 24px; text-align: center; }
.mc-rail__label { display: none; }
.mc-clinic.rail-expanded .mc-rail__label { display: inline; }
.mc-rail__caret { display: none; margin-left: auto; margin-right: 16px; font-size: .8rem; transition: transform .2s; }
.mc-clinic.rail-expanded .mc-rail__caret { display: inline; }
.mc-rail__group.is-open > .mc-rail__item .mc-rail__caret { transform: rotate(90deg); }

/* Tooltip do trilho — aparece no hover em qualquer modo,
   posicionado à direita do ícone (não interfere no label). */
.mc-rail__tip {
    position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%);
    background: #111827; color: #fff;
    padding: 6px 11px; border-radius: 7px; font-size: .8rem; font-weight: 500;
    white-space: nowrap; opacity: 0; pointer-events: none;
    transition: opacity .12s ease, transform .12s ease; z-index: 1060;
    box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.mc-rail__tip::before {
    content: ''; position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
    border: 4px solid transparent; border-right-color: #111827;
}
/* Mostra tooltip no modo recolhido (sempre que hover) */
.mc-clinic:not(.rail-expanded) .mc-rail__item:hover .mc-rail__tip { opacity: 1; }
/* Active state nos sub-links — destaque mais leve para o filho */
.mc-rail__sub a.active,
.mc-flyout a.active { background: var(--mc-primary); color: #fff; }
.mc-rail__sub a.active i,
.mc-flyout a.active i { color: #fff; }

/* Flyout de submenus — aparece ao lado do trilho (modo recolhido) */
.mc-flyout {
    position: fixed; left: 70px; top: 0; bottom: 0;
    width: 234px; background: #fff;
    border-right: 1px solid #e6e9f0;
    box-shadow: 10px 0 30px rgba(0,0,0,.10);
    z-index: 1035; padding: 16px 14px; display: none;
}
.mc-flyout.is-open { display: block; }
.mc-flyout__title { font-size: .95rem; font-weight: 700; color: #1f2738; padding: 6px 10px 14px; }
.mc-flyout a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 11px; border-radius: 8px;
    color: #44506a; font-size: .9rem;
}
.mc-flyout a:hover { background: #f0f2f8; color: var(--mc-primary); }
.mc-flyout a.active { background: var(--mc-primary); color: #fff; }
.mc-flyout a.is-soon { opacity: .5; cursor: not-allowed; }
.mc-flyout a.is-soon:hover { background: transparent; color: #44506a; }
.mc-flyout .mc-soon-tag,
.mc-rail__sub .mc-soon-tag {
    margin-left: auto; font-size: .62rem; text-transform: uppercase;
    letter-spacing: .04em; background: #eef0f6; color: #8b94a7;
    padding: 2px 6px; border-radius: 5px;
}

/* Submenu inline — modo expandido (acordeão) */
.mc-rail__sub { display: none; background: rgba(0,0,0,.22); }
.mc-clinic.rail-expanded .mc-rail__group.is-open .mc-rail__sub { display: block; }
.mc-rail__sub a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px 9px 62px; color: var(--mc-sidebar-text); font-size: .85rem;
}
.mc-rail__sub a:hover { color: #fff; background: var(--mc-sidebar-hover); }
.mc-rail__sub a.active { color: #fff; }
.mc-rail__sub a.is-soon { opacity: .45; pointer-events: none; }

.mc-rail__footer { border-top: 1px solid rgba(255,255,255,.06); padding: 12px; }
.mc-rail__footer .mc-rail__userline { display: none; }
.mc-clinic.rail-expanded .mc-rail__footer .mc-rail__userline { display: block; }

/* Conteúdo amplo (edge-to-edge) */
.mc-clinic-main {
    flex: 1; margin-left: 70px; min-width: 0;
    display: flex; flex-direction: column; transition: margin-left .2s ease;
}
.mc-clinic.rail-expanded .mc-clinic-main { margin-left: 244px; }
.mc-clinic-topbar {
    background: #fff; border-bottom: 1px solid #e6e9f0; height: 60px;
    display: flex; align-items: center; gap: 14px; padding: 0 22px;
    position: sticky; top: 0; z-index: 1020;
}
.mc-clinic-content { padding: 22px 26px; flex: 1; }
.mc-clinic-search {
    flex: 1; max-width: 460px; border: 1px solid #e6e9f0;
    background: #f4f6fb; border-radius: 9px; padding: 8px 14px; font-size: .9rem;
}
.mc-clinic-search:focus { outline: none; border-color: var(--mc-primary); background: #fff; }

/* Cards do dashboard da clínica */
.mc-stat { border: 1px solid #e6e9f0; border-radius: 14px; background: #fff; padding: 20px; }
.mc-stat .mc-stat__value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.mc-stat .mc-stat__icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}

/* Responsivo — trilho vira off-canvas */
.mc-rail__backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1034; }
@media (max-width: 991.98px) {
    .mc-rail { transform: translateX(-100%); width: 244px; }
    .mc-rail.is-mobile-open { transform: translateX(0); }
    .mc-rail.is-mobile-open ~ .mc-rail__backdrop { display: block; }
    .mc-clinic-main, .mc-clinic.rail-expanded .mc-clinic-main { margin-left: 0; }
    .mc-flyout { left: 0; }
    .mc-clinic-rail-toggle { display: inline-flex !important; }
}
.mc-clinic-rail-toggle { display: none; }

/* ============================================================
   Padrão de formulário do Painel da Clínica
   Cabeçalho com título + ações, seções em cards com ícone colorido,
   labels em caixa alta sutil, inputs de fundo suave.
   ============================================================ */

/* Cabeçalho do formulário ------------------------------------ */
.mc-form-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 18px; flex-wrap: wrap; margin-bottom: 22px;
}
.mc-form-head__title    { font-size: 1.55rem; font-weight: 700; margin: 0; line-height: 1.15; }
.mc-form-head__subtitle { color: #7b8499; margin: 6px 0 0; font-size: .9rem; max-width: 720px; }
.mc-form-head__actions  { display: flex; gap: 10px; align-items: center; }
.mc-btn-link {
    background: none; border: 0; color: #6c7593; font-weight: 500;
    padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
.mc-btn-link:hover { color: #1f2738; background: #eef0f6; }

/* Card de seção --------------------------------------------- */
.mc-section {
    background: #fff; border: 1px solid #e6e9f0; border-radius: 16px;
    padding: 22px 24px; margin-bottom: 16px;
}
.mc-section__head {
    display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.mc-section__icon {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.mc-section__icon--blue   { background: #e7eaf8; color: var(--mc-primary); }
.mc-section__icon--green  { background: #d8f3e3; color: #1a7a40; }
.mc-section__icon--yellow { background: #fff5d6; color: #8a6d00; }
.mc-section__icon--purple { background: #ece4fb; color: #5b3fc1; }
.mc-section__icon--red    { background: #fde2e1; color: #b32d2a; }
.mc-section__title        { font-size: 1.05rem; font-weight: 700; margin: 0; flex: 1; color: #1f2738; }

/* Labels e inputs do padrão --------------------------------- */
.mc-label {
    font-size: .72rem; font-weight: 600; letter-spacing: .07em;
    text-transform: uppercase; color: #7b8499; margin-bottom: 6px; display: block;
}
.mc-input, .mc-select, .mc-textarea {
    width: 100%; background: #f4f6fb; border: 1px solid transparent;
    border-radius: 10px; padding: 11px 14px; font-size: .94rem; color: #1f2738;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.mc-input:focus, .mc-select:focus, .mc-textarea:focus {
    background: #fff; border-color: var(--mc-primary);
    box-shadow: 0 0 0 3px rgba(60, 85, 180, .10); outline: none;
}
.mc-input.is-invalid, .mc-select.is-invalid, .mc-textarea.is-invalid {
    background: #fff5f5; border-color: #d9534f;
}
.mc-textarea { min-height: 90px; resize: vertical; }
.mc-prefix-input {
    position: relative;
}
.mc-prefix-input .mc-prefix {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: #7b8499; font-size: .9rem; pointer-events: none;
}
.mc-prefix-input .mc-input { padding-left: 38px; }

/* Toggle bonito (Bootstrap form-switch redesenhado) --------- */
.mc-switch {
    display: inline-flex; align-items: center; gap: 10px;
    background: #eef0f6; border-radius: 999px; padding: 4px 14px;
    cursor: pointer; user-select: none; font-size: .82rem; color: #6c7593;
}
.mc-switch:hover { background: #e6e9f0; }
.mc-switch input { display: none; }
.mc-switch__dot {
    width: 32px; height: 18px; background: #c3c9d6; border-radius: 999px;
    position: relative; transition: background .15s;
}
.mc-switch__dot::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; background: #fff; border-radius: 50%;
    transition: transform .15s;
}
.mc-switch:has(input:checked) { background: rgba(60, 85, 180, .10); color: var(--mc-primary); font-weight: 600; }
.mc-switch:has(input:checked) .mc-switch__dot { background: var(--mc-primary); }
.mc-switch:has(input:checked) .mc-switch__dot::after { transform: translateX(14px); }

/* Card-toggle (toggle inteiro como cartão) ------------------ */
.mc-toggle-card {
    display: flex; align-items: center; gap: 14px;
    background: #f4f6fb; border-radius: 12px; padding: 12px 16px; cursor: pointer;
}
.mc-toggle-card:has(input:checked) { background: rgba(60, 85, 180, .08); }
.mc-toggle-card:has(input:checked) .mc-switch__dot { background: var(--mc-primary); }
.mc-toggle-card:has(input:checked) .mc-switch__dot::after { transform: translateX(14px); }
.mc-toggle-card__icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: #fff; color: var(--mc-primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.mc-toggle-card__text { flex: 1; min-width: 0; }
.mc-toggle-card__title { font-weight: 600; font-size: .92rem; color: #1f2738; }
.mc-toggle-card__hint  { font-size: .78rem; color: #7b8499; }

/* Card colorido de seleção (Tipo de Cadastro / Categorias) -- */
.mc-pick-card {
    background: linear-gradient(160deg, var(--mc-primary) 0%, var(--mc-primary-dark) 100%);
    color: #fff; border-radius: 16px; padding: 22px 22px;
}
.mc-pick-card__title { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }
.mc-pick-option {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px; border-radius: 12px;
    background: rgba(255,255,255,.08); margin-bottom: 10px;
    cursor: pointer; transition: background .15s; color: #fff;
}
.mc-pick-option:hover { background: rgba(255,255,255,.16); }
.mc-pick-option input[type=radio],
.mc-pick-option input[type=checkbox] { display: none; }
.mc-pick-option__radio {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.55); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .15s, background .15s;
}
.mc-pick-option:has(input:checked) {
    background: rgba(255,255,255,.20); box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}
.mc-pick-option:has(input:checked) .mc-pick-option__radio { border-color: #fff; background: #fff; }
.mc-pick-option:has(input:checked) .mc-pick-option__radio::after {
    content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--mc-primary);
}
.mc-pick-option__body { min-width: 0; }
.mc-pick-option__title { font-weight: 700; line-height: 1.1; }
.mc-pick-option__hint  { font-size: .78rem; opacity: .82; margin-top: 2px; }
.mc-pick-card__tip {
    margin-top: 12px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.18);
    font-size: .82rem; opacity: .88;
}
.mc-pick-card__tip strong {
    display: block; font-size: .7rem; letter-spacing: .07em;
    text-transform: uppercase; margin-bottom: 4px; opacity: .8;
}

/* Botão principal de salvar com ícone ----------------------- */
.btn-primary i { margin-right: 4px; }

/* Pills de info no header do prontuário (próxima consulta + alerta retorno) */
.mc-info-pill {
    background: #f8fafc; border: 1px solid #e6e9f0; border-radius: 12px;
    padding: 8px 14px; min-width: 130px; text-align: left; line-height: 1.2;
}
.mc-info-pill__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: #94a3b8; font-weight: 600; margin-bottom: 3px; }
.mc-info-pill__value { font-size: .92rem; font-weight: 700; color: #1e293b; }
.mc-info-pill--btn { cursor: pointer; transition: all .15s; }
.mc-info-pill--btn:hover { border-color: var(--mc-primary); background: #fff; }
.mc-info-pill--btn.is-set { border-color: #f59e0b55; background: #fffbeb; }
.mc-info-pill--btn.is-overdue { border-color: #ef444455; background: #fef2f2; }
