/* ============ Camada servidor (CodeIgniter) ============
 * Mapeia o HTML que o backend PHP já emite (alerts do Bootstrap,
 * tabelas legadas, DataTables) para os tons Valoriza.
 * Carregada DEPOIS de valoriza.css (cópia fiel do demo). */

/* Alerts emitidos pelos models ($message, validation_errors) */
.alert { padding: 12px 16px; margin: 0 0 16px; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-control); background: var(--surface); color: var(--text); font-size: 14px; }
.alert-danger { border-left-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.alert-success { border-left-color: var(--success); color: var(--success); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.alert-warning { border-left-color: var(--warning); color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.alert-info { border-left-color: var(--info); color: var(--info); background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.alert p { margin: 0 0 6px; }
.alert p:last-child { margin-bottom: 0; }

/* Utilitários que o backend usa inline */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Conteúdo legado dentro do corpo da página */
.page-body img { max-width: 100%; height: auto; }
.page-body table { width: 100%; border-collapse: collapse; background: var(--surface); }
.page-body th, .page-body td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.page-body thead th { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }

/* DataTables (carregado via $jsLoader em telas admin) */
.dataTables_wrapper { width: 100%; margin-top: 8px; font-size: 14px; }
.dataTables_wrapper .row { margin: 0 0 8px; }
.dataTables_wrapper label { font-weight: 600; }
.dataTables_wrapper .pagination { margin: 8px 0 0; }

/* Dropdowns do shell servidor (notificações, usuário) */
.top-actions { display: flex; align-items: center; gap: 8px; }
[data-dropdown] { position: relative; }
[data-dropdown] .drop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; display: none; width: min(340px, 86vw); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); }
[data-dropdown].is-open .drop { display: block; }
.drop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.drop-list { max-height: 320px; overflow: auto; padding: 8px; margin: 0; list-style: none; }
.drop-list li { padding: 10px 12px; border-radius: 8px; }
.drop-list li + li { border-top: 1px solid var(--border); }
.drop-list small { display: block; color: var(--text-muted); }
.drop-foot { padding: 10px 16px; border-top: 1px solid var(--border); }
.icon-btn { position: relative; display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font-weight: 600; }
.icon-btn .badge { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; color: #fff; background: var(--danger); font-size: 12px; font-weight: 700; line-height: 22px; text-align: center; }

/* Drawer mobile do shell servidor (espelha o comportamento do demo) */
@media (max-width: 1199px) {
  .bar { position: fixed; inset: 0 auto 0 0; z-index: 70; width: min(300px, 86vw); transform: translateX(-105%); transition: transform .2s ease; }
  .bar.is-open { transform: none; }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 65; border: 0; background: rgba(20, 28, 33, .5); }
  .drawer-backdrop[hidden] { display: none; }
  .drawer-close { display: inline-flex; }
  .burger { display: inline-flex; }
}
@media (min-width: 1200px) {
  .drawer-backdrop, .drawer-close { display: none; }
}

/* Auth: fileira de senha com olho, centralização e botão bloco (era inline) */
.pass-row { display: flex; gap: 8px; }
.pass-row input { flex: 1; min-width: 0; }
.auth-card .hint, .auth-card .fine { text-align: center; }
.auth-card form > .btn-line { display: flex; width: 100%; margin-top: 8px; }

/* Compat Bootstrap mínima: telas cliente não carregam o CSS do Bootstrap,
 * mas as views usam modal/badges/utils. Camada nativa Valoriza (sem reboot). */
.d-none { display: none !important; }
.img-fluid { max-width: 100%; height: auto; }
.mt-3 { margin-top: 16px !important; }
.mb-1 { margin-bottom: 4px !important; }
.px-4 { padding-right: 24px !important; padding-left: 24px !important; }
.alert-link { font-weight: 700; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.badge-success { color: #fff; background: var(--success); }
.badge-dark { color: #fff; background: var(--brand-slate); }
.badge-warning { color: #fff; background: var(--warning); }
.badge-info { color: #fff; background: var(--info); }
.badge-danger { color: #fff; background: var(--danger); }
.form-inline { display: inline; }
.tabs-row { display: flex; gap: 8px; list-style: none; padding: 0; margin: 12px 0; }
.mt-2 { margin-top: 8px !important; }
.table-thumb { max-width: 80px; }
.card-narrow { max-width: 560px; margin: 0 auto; }
.page-stack.tight { gap: 12px; margin: 12px 0; }
.modal { position: fixed; inset: 0; z-index: 80; display: none; overflow-x: hidden; overflow-y: auto; outline: 0; }
.modal.show { display: block; }
.modal-dialog { position: relative; width: auto; max-width: 520px; margin: 48px auto; pointer-events: none; }
.modal-dialog-centered { display: flex; align-items: center; min-height: calc(100% - 96px); }
.modal-lg { max-width: 800px; }
.modal-content { position: relative; display: flex; flex-direction: column; width: 100%; pointer-events: auto; border: 1px solid var(--border); border-radius: var(--radius-dialog); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(20, 28, 33, .28); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-body > :last-child { margin-bottom: 0; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-footer:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(20, 28, 33, .55); }
body.modal-open { overflow: hidden; }
@media (max-width: 600px) { .modal-dialog { margin: 24px 16px; } .modal-lg { max-width: none; } }

/* Sanfona nativa (substitui o accordion BS3 sem CSS/JS): <details> estilizado */
.vz-disclosure { border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); }
.vz-disclosure + .vz-disclosure { margin-top: 8px; }
.vz-disclosure summary { cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none; }
.vz-disclosure summary::-webkit-details-marker { display: none; }
.vz-disclosure summary::marker { content: ""; }
.vz-disclosure summary::after { content: "+"; float: right; color: var(--text-muted); font-weight: 700; }
.vz-disclosure[open] summary::after { content: "\2013"; }
.vz-disclosure .vz-disclosure-body { padding: 0 16px 14px; font-size: 14px; }

/* Texto colorido (paridade Bootstrap) + fileira de opção + fieldset + fade */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.field-row { flex-direction: row; align-items: center; gap: 10px; }
.field-row input[type="radio"], .field-row input[type="checkbox"] { width: auto; min-height: 0; flex: none; }
.vz-fieldset { border: 0; padding: 0; margin: 16px 0 0; }
.vz-fieldset legend { margin-bottom: 8px; }
.fade-in { animation: vzFadeIn .5s ease-in-out; }
@keyframes vzFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.field-snug { margin-bottom: 6px; }
.input-xs { max-width: 120px; }
.money-sm { font-size: clamp(20px, 1.8vw, 26px); }
.product-image { max-width: 220px; height: auto; }
.progress { min-width: 120px; height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--primary-bg); }
.vz-fieldset.flush { margin: 0; }
.video-frame { border: 0; border-radius: 12px; width: 100%; }
.neg { color: var(--danger); font-weight: 700; }

/* Admin carrega o Bootstrap 3: a regra `.nav .open > a` dele pinta os itens
 * do submenu de #eee (pílula clara com texto branco = ilegível). Anula aqui. */
.admin-bar .nav .open > a { background-color: transparent; border-color: transparent; }
.admin-bar .nav .open > a:hover, .admin-bar .nav .open > a:focus { background-color: rgba(255, 255, 255, .07); border-color: transparent; }

/* Planos (cliente): o texto do card é centralizado por planos.css (.plan { text-align:center }),
 * mas valoriza.css:231 fixa `.plan .btn { align-self:flex-start }` num card em coluna flex e o botão
 * COMPRAR ficava colado à esquerda. Escopado à tela de planos (wrapper .plans-loja), vale em desktop e mobile. */
.plans .plan > .btn, .plan > .btn.comprarPlano { align-self: center; }

/* Notificações do cliente: cada item é um <button> que abre o modal #vz-notif-modal */
.notif-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 6px; color: inherit; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.notif-open:hover .notif-text { text-decoration: underline; }
.notif-open:focus-visible { outline: 2px solid var(--primary-bg); outline-offset: 2px; }
.notif-text { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.notif-item.is-unread .notif-text { font-weight: 700; }
.notif-item.is-unread .notif-text::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--danger); vertical-align: middle; }
.drop-foot .btn-line { width: 100%; }
#vz-notif-modal .notif-modal-texto { margin: 0 0 12px; white-space: pre-line; overflow-wrap: anywhere; }

/* Rodapé do sino (Marcar todas como lidas / Limpar / Ver tudo) e página "Ver tudo" (cliente/notificacoes) */
.drop-foot.notif-acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.drop-foot.notif-acoes .btn-line { width: auto; flex: 1 1 auto; }
.drop-foot.notif-acoes .notif-ver-tudo { flex: 1 0 100%; }
.notif-pagina-acoes { margin-bottom: 14px; }
.card.flat.notif-card { padding: 0; overflow: hidden; }
.notif-page-list { margin: 0; padding: 0; list-style: none; }
.notif-page-list .notif-item { padding: 14px 16px; border-left: 4px solid transparent; }
.notif-page-list .notif-item + .notif-item { border-top: 1px solid var(--border); }
.notif-page-list .notif-item.is-unread { border-left-color: var(--danger); background: var(--selected); }
.notif-page-list .notif-text { -webkit-line-clamp: 3; line-clamp: 3; }
.notif-page-list small { display: block; margin-top: 4px; color: var(--text-muted); }
.notif-vazio { margin: 0; padding: 22px 16px; color: var(--text-muted); text-align: center; }
.notif-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

/* Mobile (<768px): o sino fica no meio da linha (nao no canto direito); com o dropdown ancorado em right:0 ele saia pela
 * esquerda da tela. Aqui ancora no .top-meta (largura total) e o dropdown ocupa a largura do conteudo. So area cliente. */
@media (max-width: 767px) {
  html[data-area="cliente"] .top-meta { position: relative; }
  html[data-area="cliente"] .top-actions [data-dropdown] { position: static; }
  html[data-area="cliente"] .top-actions [data-dropdown] .drop { left: 0; right: 0; width: auto; }
}
