/* public/assets/base.css (DEV V1.1)
   Estilos globais partilhados por todos os módulos.
   Mantém os módulos limpos (apenas estilos específicos por módulo).
*/

:root{
  --bg1:#0b1220;
  --bg2:#0f1b35;
  --card:#0e1729;
  --text:#e9eefc;
  --muted:#9fb0d1;
  --line:rgba(255,255,255,.10);
  --accent:#6ea8ff;
  --danger:#ff6b6b;
  --ok:#55d38a;
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color:var(--text); }
body{
  background:
    radial-gradient(900px 500px at 20% 20%, rgba(110,168,255,.25), transparent 60%),
    radial-gradient(800px 500px at 80% 40%, rgba(255,255,255,.06), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
}

.muted{ color:var(--muted); }
.center{ text-align:center; }

/* Containers */
.crm-wrap{ padding:22px; max-width:1350px; margin:0 auto; }

/* Topbar / Panel (reutilizado em vários módulos) */
.topbar{
  display:flex; justify-content:space-between; align-items:flex-start; gap:12px;
  padding:14px 16px; border:1px solid var(--line);
  background: rgba(14,23,41,.55); border-radius:16px; backdrop-filter: blur(10px);
}
.title{ font-weight:900; letter-spacing:.3px; font-size:18px; }
.subtitle{ font-size:12px; margin-top:4px; }
.right{ display:flex; gap:10px; flex-wrap:wrap; }

.panel{
  margin-top:16px; border:1px solid var(--line);
  background: rgba(14,23,41,.55); border-radius:16px; padding:14px; backdrop-filter: blur(10px);
}

.toolbar{ display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.controls{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.search{ flex:1; min-width:260px; }

/* Inputs / Selects */
.in, .sel, textarea.ta{
  width:100%; border-radius:12px; border:1px solid var(--line);
  background: rgba(255,255,255,.04); padding:11px 12px; color:var(--text); outline:none;
}
.sel{ width:auto; cursor:pointer; }
.in:focus, .sel:focus, textarea.ta:focus{
  border-color: rgba(110,168,255,.55);
  box-shadow: 0 0 0 4px rgba(110,168,255,.14);
}

::placeholder{ color: rgba(159,176,209,.70); }

/* Botões */
.btn{
  border:1px solid var(--line); border-radius:12px; padding:10px 12px;
  font-weight:800; cursor:pointer; background: rgba(255,255,255,.04); color: var(--text);
}
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }
.btn.primary{ border:0; background: linear-gradient(180deg, #8ab8ff, #5f9cff); color:#061024; }
.btn.danger{ border:1px solid rgba(255,107,107,.35); background: rgba(255,107,107,.12); color:#ffd0d0; }
.btn.ghost{ background: transparent; }
.small{ padding:8px 10px; border-radius:10px; font-size:12px; }

/* Tabelas */
.table-wrap{ overflow:auto; border-radius:12px; border:1px solid var(--line); }
.tbl{ width:100%; border-collapse:collapse; min-width:980px; }
.tbl thead th{
  text-align:left; font-size:12px; color:var(--muted); font-weight:800;
  padding:12px 12px; border-bottom:1px solid var(--line);
  background: rgba(255,255,255,.03); position: sticky; top: 0; backdrop-filter: blur(10px);
}
.tbl td{ padding:12px 12px; border-bottom:1px solid rgba(255,255,255,.06); font-size:13px; }
.tbl tr:last-child td{ border-bottom:none; }
.actions{ display:flex; gap:8px; flex-wrap:wrap; }

/* chips / badges */
.badge{
  display:inline-flex; align-items:center; gap:6px;
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--line); background: rgba(255,255,255,.03);
  font-size:12px; font-weight:900;
}

/* Paginação */
.pager{ margin-top:12px; display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.pagerBtns{ display:flex; gap:10px; align-items:center; }
.pageBox{ border:1px solid var(--line); background: rgba(255,255,255,.03); border-radius:12px; padding:8px 12px; }

/* Modal base */
.modal-backdrop{
  position:fixed; inset:0; background: rgba(0,0,0,.55);
  display:none; align-items:center; justify-content:center; padding:18px; z-index:9999;
}
.modal-backdrop.open{ display:flex; }
.modal{
  width: min(820px, 100%);
  background: rgba(14,23,41,.92);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow: 0 20px 70px rgba(0,0,0,.45);
  backdrop-filter: blur(14px);
  max-height: calc(100vh - 36px);
  display:flex; flex-direction:column; overflow:hidden;
}
.modal-head{
  display:flex; justify-content:space-between; align-items:flex-start; gap:10px;
  padding:14px 14px; border-bottom:1px solid rgba(255,255,255,.08);
}
.modal-title{ font-weight:900; letter-spacing:.2px; }
.modal-subtitle{ font-size:12px; margin-top:4px; }
.icon-btn{
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius:12px;
  padding:8px 10px;
  font-weight:900;
  cursor:pointer;
}
.icon-btn:active{ transform: translateY(1px); }
.modal-body{ padding:14px; overflow:auto; }
.modal-foot{ padding:14px; border-top:1px solid rgba(255,255,255,.08); display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap; }

/* Dropdown contrast fix (global) */
select, .sel{
  color: var(--text, #e9eefc) !important;
  background-color: rgba(255,255,255,.04) !important;
  border-color: rgba(255,255,255,.10) !important;
}
select option,
select optgroup{
  color: #e9eefc !important;
  background-color: #0e1729 !important;
}

datalist option{
  color: #e9eefc !important;
  background-color: #0e1729 !important;
}

/* Toasts (global) */
.crm-toasts{
  position: fixed;
  right: 18px;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
  max-width: min(420px, calc(100vw - 36px));
}
.toast{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:10px 10px 10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(14,23,41,.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  transform: translateY(0);
  opacity: 1;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.hide{ opacity:0; transform: translateY(-6px); }
.toast-msg{ flex:1; font-size:13px; line-height:1.35; color: var(--text); }
.toast-x{
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-radius: 12px;
  padding: 4px 9px;
  font-weight: 900;
  cursor: pointer;
}
.toast-x:active{ transform: translateY(1px); }

.toast.info{ border-color: rgba(110,168,255,.35); }
.toast.success{ border-color: rgba(85,211,138,.40); }
.toast.warning{ border-color: rgba(255,210,92,.35); }
.toast.error{ border-color: rgba(255,107,107,.40); }

/* Melhor contraste no dropdown (options) */
select option{
  background: #0e1729;
  color: #e8f0ff;
}



/* =========================
   APP SHELL + NAVBAR (V1.2)
   ========================= */
.app-shell{ min-height:100vh; display:flex; flex-direction:column; }
.app-nav{
  position:sticky; top:0; z-index:50;
  display:flex; align-items:center; gap:14px;
  padding:12px 16px;
  border-bottom:1px solid var(--line);
  background: rgba(14,23,41,.72);
  backdrop-filter: blur(12px);
}
.brand{ display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--text); font-weight:900; letter-spacing:.2px; }
.brand-mark{
  width:32px; height:32px; display:grid; place-items:center;
  border-radius:12px;
  background: radial-gradient(120% 120% at 20% 20%, rgba(110,168,255,.35), rgba(255,255,255,.06));
  border:1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 22px rgba(0,0,0,.25);
}
.brand-name{ font-size:14px; opacity:.95; }

.nav-links{ display:flex; align-items:center; gap:6px; margin-left:6px; }
.nav-link{
  text-decoration:none; color: rgba(233,238,252,.86);
  padding:8px 10px; border-radius:12px; font-weight:800; font-size:13px;
  border:1px solid transparent;
}
.nav-link:hover{ background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); }
.nav-link.active{ background: rgba(110,168,255,.12); border-color: rgba(110,168,255,.25); color: var(--text); }

.nav-actions{ margin-left:auto; display:flex; align-items:center; gap:10px; }
.nav-user{ display:flex; align-items:center; gap:8px; max-width:260px; }
.nav-user-name{ font-weight:800; font-size:12px; color: rgba(233,238,252,.86); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.icon-btn{
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  color: var(--text);
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
  font-weight:900;
  display:none;
}
.icon-btn:hover{ background: rgba(255,255,255,.09); }

.nav-drawer{
  position:absolute; left:12px; right:12px; top:56px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(14,23,41,.94);
  backdrop-filter: blur(14px);
  border-radius:16px;
  padding:10px;
  box-shadow: 0 16px 30px rgba(0,0,0,.35);
}
.drawer-link{
  display:flex; padding:10px 12px; border-radius:12px;
  text-decoration:none; color: rgba(233,238,252,.90); font-weight:800;
  border:1px solid transparent;
}
.drawer-link:hover{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.10); }
.drawer-link.active{ background: rgba(110,168,255,.12); border-color: rgba(110,168,255,.22); color: var(--text); }
.drawer-sep{ height:1px; background: rgba(255,255,255,.10); margin:8px 6px; }

.app-main{ padding:18px 16px 26px; }

/* Page head (para títulos dentro do main) */
.page-head{
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  padding:14px 16px;
  border:1px solid var(--line);
  background: rgba(14,23,41,.55);
  border-radius:16px;
  backdrop-filter: blur(10px);
}
.page-head .left{ display:flex; flex-direction:column; gap:3px; }
.page-head .title{ margin:0; }
.page-head .subtitle{ margin:0; }
.page-head .actions{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }

/* Multi-screen / Responsivo */
@media (max-width: 980px){
  .crm-wrap{ padding:14px; }
}
@media (max-width: 860px){
  .nav-links{ display:none; }
  .icon-btn{ display:inline-flex; }
  .nav-user{ display:none; }
  .nav-logout{ display:none; }
  .app-main{ padding:14px 12px 22px; }
}
@media (max-width: 520px){
  .page-head{ padding:12px 12px; }
  .panel{ padding:12px; }
  .toolbar{ gap:10px; }
  .controls{ width:100%; justify-content:space-between; }
  .controls .btn{ width:100%; }
  .tbl th, .tbl td{ padding:10px 8px; font-size:12px; }
}

/* Melhor scroll horizontal em tabelas no mobile */
.table-wrap{ overflow:auto; -webkit-overflow-scrolling: touch; }
.table-wrap::-webkit-scrollbar{ height:10px; }
.table-wrap::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.10); border-radius:999px; }



/* Mobile: tables must not force width beyond viewport */
@media (max-width:520px){
  .tbl{ min-width: 0 !important; }
  .crm-wrap, .app-main, .container{ max-width:100%; }
}


/* Lookup (cliente/lead) – usado em Agenda e Tarefas */
.lookup{ position:relative; }
.lookup .in{ padding-right:44px; }
.lookup .pill{
  position:absolute; right:10px; top:50%; transform:translateY(-50%);
  font-size:12px; padding:4px 10px; border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  max-width: 48%;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.lookup .list{
  position:absolute; left:0; right:0; top:calc(100% + 6px);
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(10,16,28,.98);
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  overflow:hidden;
  z-index: 50;
  display:none;
}
.lookup .list.open{ display:block; }
.lookup .item{
  padding:10px 12px;
  display:flex; flex-direction:column; gap:2px;
  cursor:pointer;
}
.lookup .item:hover{ background: rgba(255,255,255,.06); }
.lookup .item .t{ font-weight:800; }
.lookup .item .s{ font-size:12px; color: var(--muted); }

/* ================================
   Cards + Responsive Grids (DEV V1_3)
   ================================ */

.card-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap:12px;
  margin-top:12px;
}
@media (max-width: 760px){
  .card-grid{ grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 520px){
  .card-grid{ grid-template-columns: 1fr; }
}

.card{
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  border-radius:14px;
  padding:12px;
}
.card-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.card-left{
  display:flex;
  align-items:flex-start;
  gap:10px;
  min-width: 0;
}
.card-avatar{
  width:40px;
  height:40px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  letter-spacing:.4px;
  flex: 0 0 auto;
}
.card-title{
  font-weight:900;
  font-size:16px;
  line-height:1.15;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.card-sub{
  margin-top:3px;
  color: var(--muted);
  font-size:12px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.card-badge{
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  white-space:nowrap;
}
.card-body{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.card-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
}
.card-k{ color: var(--muted); font-size:12px; }
.card-v{ font-weight:650; text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:70%; }
.card-actions{
  margin-top:12px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

/* Make sure tables never force page width on small screens */
@media (max-width: 520px){
  .tbl{ min-width: 0 !important; }
  .table-wrap{ overflow:auto; -webkit-overflow-scrolling: touch; }
}
