/* ============================================================
   OptiVision CRM — Estilos globais
   Paleta: Azul #1E6EBF | Verde #2ECC71 | Escuro #1A1A2E
   Mobile-first
   ============================================================ */

/* ── Reset & variáveis ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --azul        : #1E6EBF;
  --azul-esc    : #155499;
  --azul-claro  : #e8f1fb;
  --verde       : #2ECC71;
  --verde-esc   : #27ae60;
  --escuro      : #1A1A2E;
  --escuro-2    : #16213e;
  --cinza-100   : #f8f9fa;
  --cinza-200   : #e9ecef;
  --cinza-400   : #ced4da;
  --cinza-600   : #6c757d;
  --cinza-800   : #343a40;
  --branco      : #ffffff;
  --vermelho    : #e74c3c;
  --laranja     : #f39c12;
  --roxo        : #9b59b6;

  --sidebar-w   : 240px;
  --header-h    : 56px;
  --radius      : 10px;
  --shadow      : 0 2px 12px rgba(0,0,0,.08);
  --shadow-md   : 0 4px 24px rgba(0,0,0,.12);
  --transition  : .2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family : 'Inter', system-ui, sans-serif;
  background  : var(--cinza-100);
  color       : var(--cinza-800);
  line-height : 1.5;
  min-height  : 100vh;
}

/* ── Layout principal ──────────────────────────────────────── */
.layout {
  display    : flex;
  min-height : 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width      : var(--sidebar-w);
  background : var(--escuro);
  color      : var(--branco);
  display    : flex;
  flex-direction: column;
  position   : fixed;
  top        : 0;
  left       : 0;
  height     : 100vh;
  z-index    : 100;
  transform  : translateX(-100%);
  transition : transform var(--transition);
  overflow-y : auto;
}

/* Sidebar aberta (mobile toggle ou desktop) */
.sidebar.aberta { transform: translateX(0); }

@media (min-width: 768px) {
  .sidebar { transform: translateX(0); position: sticky; }
}

.sidebar-header {
  display    : flex;
  align-items: center;
  gap        : .75rem;
  padding    : 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.logo-icon  { width: 36px; height: 36px; flex-shrink: 0; }
.logo-texto {
  font-size  : 1.1rem;
  font-weight: 700;
  color      : var(--branco);
  letter-spacing: -.3px;
}

/* Menu */
.menu {
  list-style : none;
  padding    : .75rem 0;
  flex       : 1;
}
.menu li { margin: 2px 0; }

.menu-item {
  display    : flex;
  align-items: center;
  gap        : .75rem;
  width      : 100%;
  padding    : .75rem 1.25rem;
  background : none;
  border     : none;
  color      : rgba(255,255,255,.7);
  font-family: inherit;
  font-size  : .9rem;
  cursor     : pointer;
  border-radius: var(--radius);
  transition : background var(--transition), color var(--transition);
  text-align : left;
}
.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.menu-item:hover  { background: rgba(255,255,255,.08); color: var(--branco); }
.menu-item.active {
  background: var(--azul);
  color     : var(--branco);
  font-weight: 600;
}

/* Footer da sidebar */
.sidebar-footer {
  display    : flex;
  align-items: center;
  gap        : .5rem;
  padding    : 1rem;
  border-top : 1px solid rgba(255,255,255,.1);
}

.avatar {
  width          : 36px;
  height         : 36px;
  border-radius  : 50%;
  background     : var(--azul);
  color          : var(--branco);
  display        : flex;
  align-items    : center;
  justify-content: center;
  font-weight    : 700;
  font-size      : .9rem;
  flex-shrink    : 0;
}

.usuario-info { flex: 1; overflow: hidden; }
.usuario-nome {
  font-size    : .85rem;
  font-weight  : 600;
  color        : var(--branco);
  white-space  : nowrap;
  overflow     : hidden;
  text-overflow: ellipsis;
}
.usuario-perfil {
  font-size  : .72rem;
  color      : rgba(255,255,255,.5);
  text-transform: capitalize;
}

.btn-sair {
  background : none;
  border     : none;
  color      : rgba(255,255,255,.5);
  cursor     : pointer;
  padding    : .4rem;
  border-radius: 6px;
  transition : color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-sair svg { width: 18px; height: 18px; display: block; }
.btn-sair:hover { color: var(--vermelho); background: rgba(231,76,60,.15); }

/* ── Botão hamburger mobile ────────────────────────────────── */
.menu-toggle {
  display    : flex;
  align-items: center;
  justify-content: center;
  position   : fixed;
  top        : .75rem;
  left       : .75rem;
  z-index    : 200;
  width      : 40px;
  height     : 40px;
  background : var(--escuro);
  border     : none;
  border-radius: 8px;
  cursor     : pointer;
  color      : var(--branco);
  box-shadow : var(--shadow);
}
.menu-toggle svg { width: 20px; height: 20px; }

@media (min-width: 768px) {
  .menu-toggle { display: none; }
}

/* ── Overlay mobile ────────────────────────────────────────── */
.overlay {
  position  : fixed;
  inset     : 0;
  background: rgba(0,0,0,.5);
  z-index   : 90;
  backdrop-filter: blur(2px);
}

/* ── Área de conteúdo ──────────────────────────────────────── */
.conteudo {
  flex      : 1;
  padding   : 1.5rem 1rem 2rem;
  min-width : 0;
  margin-top: var(--header-h); /* espaço para o botão hamburger */
}

@media (min-width: 768px) {
  .conteudo {
    margin-top: 0;
    padding   : 2rem 1.5rem;
  }
}

/* ── Páginas ───────────────────────────────────────────────── */
.pagina { animation: fadeIn .2s ease; }
.oculta { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.titulo-pagina {
  font-size  : 1.4rem;
  font-weight: 700;
  color      : var(--escuro);
  margin-bottom: 1.25rem;
}

.pagina-header {
  display    : flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap  : wrap;
  gap        : .75rem;
  margin-bottom: 1.25rem;
}

/* ── Cards de estatística ──────────────────────────────────── */
.cards-grid {
  display              : grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap                  : 1rem;
  margin-bottom        : 1.5rem;
}

.card-stat {
  background   : var(--branco);
  border-radius: var(--radius);
  padding      : 1.25rem;
  display      : flex;
  align-items  : center;
  gap          : 1rem;
  box-shadow   : var(--shadow);
  transition   : box-shadow var(--transition);
}
.card-stat:hover { box-shadow: var(--shadow-md); }

.card-stat-icon {
  width          : 48px;
  height         : 48px;
  border-radius  : 12px;
  display        : flex;
  align-items    : center;
  justify-content: center;
  flex-shrink    : 0;
}
.card-stat-icon svg { width: 22px; height: 22px; }

.card-stat-icon.azul    { background: var(--azul-claro); color: var(--azul); }
.card-stat-icon.verde   { background: #d5f5e3; color: var(--verde-esc); }
.card-stat-icon.roxo    { background: #ede7f6; color: var(--roxo); }
.card-stat-icon.laranja { background: #fef3cd; color: #d68910; }

.card-stat-valor {
  font-size  : 1.8rem;
  font-weight: 700;
  color      : var(--escuro);
  line-height: 1;
}
.card-stat-label {
  font-size : .8rem;
  color     : var(--cinza-600);
  margin-top: .25rem;
}

/* ── Gráficos ──────────────────────────────────────────────── */
.graficos-grid {
  display              : grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap                  : 1rem;
}

.grafico-card {
  background   : var(--branco);
  border-radius: var(--radius);
  padding      : 1.25rem;
  box-shadow   : var(--shadow);
}

.grafico-titulo {
  font-size    : .95rem;
  font-weight  : 600;
  margin-bottom: 1rem;
  color        : var(--escuro);
}

/* ── Kanban ────────────────────────────────────────────────── */
.kanban-board {
  display   : flex;
  gap       : .75rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 60vh;
}

.kanban-coluna {
  flex-shrink: 0;
  width      : 240px;
  background : var(--cinza-200);
  border-radius: var(--radius);
  display    : flex;
  flex-direction: column;
}

.kanban-coluna-header {
  display    : flex;
  align-items: center;
  justify-content: space-between;
  padding    : .75rem 1rem;
  font-size  : .85rem;
  font-weight: 600;
  color      : var(--cinza-800);
  border-bottom: 2px solid transparent;
}

/* Cores da borda por coluna */
.kanban-coluna[data-coluna="novo"]      .kanban-coluna-header { border-color: var(--azul); }
.kanban-coluna[data-coluna="contato"]   .kanban-coluna-header { border-color: var(--laranja); }
.kanban-coluna[data-coluna="agendado"]  .kanban-coluna-header { border-color: var(--verde); }
.kanban-coluna[data-coluna="consulta"]  .kanban-coluna-header { border-color: var(--roxo); }
.kanban-coluna[data-coluna="pos_venda"] .kanban-coluna-header { border-color: #1abc9c; }

.kanban-coluna-badge {
  background   : var(--azul);
  color        : var(--branco);
  border-radius: 20px;
  padding      : .1rem .5rem;
  font-size    : .75rem;
}

.kanban-cards {
  flex       : 1;
  padding    : .5rem;
  display    : flex;
  flex-direction: column;
  gap        : .5rem;
  min-height : 80px;
}

/* Estado vazio da coluna (para SortableJS) */
.kanban-cards.sortable-drag { opacity: .5; }

.kanban-card {
  background   : var(--branco);
  border-radius: 8px;
  padding      : .75rem;
  box-shadow   : var(--shadow);
  cursor       : grab;
  transition   : box-shadow var(--transition), transform var(--transition);
  border-left  : 3px solid var(--cinza-400);
  user-select  : none;
}
.kanban-card:active { cursor: grabbing; transform: rotate(1deg); }
.kanban-card:hover  { box-shadow: var(--shadow-md); }

/* Alerta de lead parado há 2h */
.kanban-card.alerta-tempo { border-left-color: var(--vermelho) !important; }

.kanban-card-nome {
  font-size  : .875rem;
  font-weight: 600;
  color      : var(--escuro);
  margin-bottom: .25rem;
}
.kanban-card-tel {
  font-size: .78rem;
  color    : var(--cinza-600);
}
.kanban-card-tempo {
  font-size : .72rem;
  color     : var(--cinza-600);
  margin-top: .4rem;
}
.kanban-card-tempo.urgente { color: var(--vermelho); font-weight: 600; }

/* Fantasma do SortableJS */
.sortable-ghost {
  opacity      : .4;
  border       : 2px dashed var(--azul);
  background   : var(--azul-claro);
}

/* ── Agenda ────────────────────────────────────────────────── */
.agenda-controles {
  display : flex;
  gap     : .5rem;
  flex-wrap: wrap;
}

.agenda-nav {
  display    : flex;
  align-items: center;
  gap        : .75rem;
  margin-bottom: 1rem;
  flex-wrap  : wrap;
}

.agenda-periodo {
  font-size  : 1rem;
  font-weight: 600;
  flex       : 1;
  text-align : center;
}

.btn-nav {
  background   : var(--branco);
  border       : 1px solid var(--cinza-400);
  border-radius: 6px;
  width        : 32px;
  height       : 32px;
  font-size    : 1.2rem;
  cursor       : pointer;
  display      : flex;
  align-items  : center;
  justify-content: center;
  transition   : background var(--transition);
}
.btn-nav:hover { background: var(--cinza-200); }

/* Grade semanal */
.agenda-semana {
  display              : grid;
  grid-template-columns: 50px repeat(7, 1fr);
  gap                  : 2px;
  background           : var(--branco);
  border-radius        : var(--radius);
  overflow             : hidden;
  box-shadow           : var(--shadow);
  font-size            : .8rem;
}

.agenda-semana-header {
  background: var(--escuro);
  color     : var(--branco);
  padding   : .6rem .25rem;
  text-align: center;
  font-weight: 600;
}

.agenda-semana-header.hoje    { background: var(--azul); }
.agenda-semana-header.destaque { background: var(--verde-esc); } /* terças/quintas/sábados */

.agenda-hora {
  background: var(--cinza-100);
  color     : var(--cinza-600);
  padding   : .4rem .25rem;
  text-align: right;
  font-size : .72rem;
}

.agenda-celula {
  background  : var(--branco);
  border      : 1px solid var(--cinza-200);
  min-height  : 48px;
  position    : relative;
  padding     : 2px;
}
.agenda-celula.hoje    { background: #fffde7; }
.agenda-celula.destaque { background: #f0fff4; }

.agenda-evento {
  background   : var(--azul);
  color        : var(--branco);
  border-radius: 4px;
  padding      : 2px 4px;
  font-size    : .7rem;
  margin-bottom: 2px;
  overflow     : hidden;
  white-space  : nowrap;
  text-overflow: ellipsis;
  cursor       : pointer;
}
.agenda-evento.realizado { background: var(--verde-esc); }
.agenda-evento.cancelado { background: var(--vermelho); }
.agenda-evento.falta     { background: var(--cinza-600); }

/* Grade mensal */
.agenda-mes {
  display              : grid;
  grid-template-columns: repeat(7, 1fr);
  gap                  : 2px;
  background           : var(--branco);
  border-radius        : var(--radius);
  overflow             : hidden;
  box-shadow           : var(--shadow);
}

.agenda-mes-dia-header {
  background : var(--escuro);
  color      : var(--branco);
  text-align : center;
  padding    : .5rem;
  font-size  : .8rem;
  font-weight: 600;
}

.agenda-mes-dia {
  min-height  : 80px;
  background  : var(--branco);
  border      : 1px solid var(--cinza-200);
  padding     : .25rem;
  font-size   : .75rem;
}
.agenda-mes-dia.outro-mes   { background: var(--cinza-100); color: var(--cinza-400); }
.agenda-mes-dia.hoje        { background: #fffde7; }
.agenda-mes-dia.destaque    { background: #f0fff4; }
.agenda-mes-dia-num         { font-weight: 600; margin-bottom: 2px; }

/* ── Tabela de pacientes ───────────────────────────────────── */
.busca-wrap {
  margin-bottom: 1rem;
}
.busca-wrap input {
  width        : 100%;
  max-width    : 400px;
  padding      : .65rem 1rem;
  border       : 1.5px solid var(--cinza-400);
  border-radius: 8px;
  font-size    : .9rem;
  font-family  : inherit;
  outline      : none;
  transition   : border-color var(--transition);
}
.busca-wrap input:focus { border-color: var(--azul); }

.tabela-wrap {
  background   : var(--branco);
  border-radius: var(--radius);
  box-shadow   : var(--shadow);
  overflow     : auto;
}

table {
  width          : 100%;
  border-collapse: collapse;
  font-size      : .875rem;
}

thead {
  background: var(--escuro);
  color     : var(--branco);
}

th {
  padding   : .75rem 1rem;
  text-align: left;
  font-size : .8rem;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding    : .7rem 1rem;
  border-bottom: 1px solid var(--cinza-200);
  white-space: nowrap;
  overflow   : hidden;
  text-overflow: ellipsis;
  max-width  : 200px;
}

tr:last-child td { border-bottom: none; }
tr:hover td      { background: var(--cinza-100); }

/* Paginação */
.paginacao {
  display        : flex;
  justify-content: center;
  align-items    : center;
  gap            : .5rem;
  padding        : 1rem;
  font-size      : .85rem;
}

/* ── Botões globais ────────────────────────────────────────── */
.btn-primario {
  background   : var(--azul);
  color        : var(--branco);
  border       : none;
  border-radius: 8px;
  padding      : .6rem 1.2rem;
  font-size    : .875rem;
  font-weight  : 600;
  font-family  : inherit;
  cursor       : pointer;
  transition   : background var(--transition), transform .1s;
  white-space  : nowrap;
}
.btn-primario:hover  { background: var(--azul-esc); }
.btn-primario:active { transform: scale(.97); }

.btn-secundario {
  background   : var(--branco);
  color        : var(--cinza-800);
  border       : 1.5px solid var(--cinza-400);
  border-radius: 8px;
  padding      : .55rem 1rem;
  font-size    : .875rem;
  font-weight  : 500;
  font-family  : inherit;
  cursor       : pointer;
  transition   : background var(--transition);
  white-space  : nowrap;
}
.btn-secundario:hover  { background: var(--cinza-200); }
.btn-secundario.ativo  { background: var(--azul); color: var(--branco); border-color: var(--azul); }

.btn-perigo {
  background: var(--vermelho);
  color     : var(--branco);
  border    : none;
  border-radius: 6px;
  padding   : .4rem .8rem;
  font-size : .8rem;
  font-family: inherit;
  cursor    : pointer;
  transition: opacity var(--transition);
}
.btn-perigo:hover { opacity: .85; }

.btn-icone {
  background   : none;
  border       : none;
  cursor       : pointer;
  color        : var(--cinza-600);
  padding      : .25rem;
  border-radius: 4px;
  transition   : color var(--transition), background var(--transition);
}
.btn-icone:hover { color: var(--azul); background: var(--azul-claro); }
.btn-icone svg   { width: 16px; height: 16px; display: block; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position       : fixed;
  inset          : 0;
  background     : rgba(0,0,0,.5);
  z-index        : 300;
  display        : flex;
  align-items    : center;
  justify-content: center;
  padding        : 1rem;
  backdrop-filter: blur(3px);
}

.modal {
  background   : var(--branco);
  border-radius: 14px;
  width        : min(560px, 100%);
  max-height   : 90vh;
  display      : flex;
  flex-direction: column;
  box-shadow   : var(--shadow-md);
  animation    : modalIn .2s ease;
}

@keyframes modalIn {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-header {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  padding        : 1.25rem 1.5rem;
  border-bottom  : 1px solid var(--cinza-200);
}

.modal-titulo { font-size: 1.05rem; font-weight: 700; }

.modal-fechar {
  background: none;
  border    : none;
  font-size : 1.5rem;
  cursor    : pointer;
  color     : var(--cinza-600);
  line-height: 1;
  padding   : .1rem .4rem;
  border-radius: 4px;
  transition: color var(--transition);
}
.modal-fechar:hover { color: var(--vermelho); }

.modal-corpo {
  padding  : 1.5rem;
  overflow-y: auto;
}

/* ── Formulários genéricos dentro do modal ─────────────────── */
.form-grupo { margin-bottom: 1rem; }

.form-grupo label {
  display      : block;
  font-size    : .82rem;
  font-weight  : 500;
  margin-bottom: .35rem;
  color        : var(--cinza-800);
}

.form-grupo input,
.form-grupo select,
.form-grupo textarea {
  width        : 100%;
  padding      : .65rem .9rem;
  border       : 1.5px solid var(--cinza-400);
  border-radius: 8px;
  font-size    : .9rem;
  font-family  : inherit;
  outline      : none;
  transition   : border-color var(--transition);
  background   : var(--branco);
}
.form-grupo input:focus,
.form-grupo select:focus,
.form-grupo textarea:focus { border-color: var(--azul); }

.form-grupo textarea { resize: vertical; min-height: 80px; }

.form-linha {
  display             : grid;
  grid-template-columns: 1fr 1fr;
  gap                 : .75rem;
}

.form-acoes {
  display        : flex;
  justify-content: flex-end;
  gap            : .75rem;
  margin-top     : 1.25rem;
}

/* ── Badges de status ──────────────────────────────────────── */
.badge {
  display      : inline-block;
  padding      : .2rem .6rem;
  border-radius: 20px;
  font-size    : .72rem;
  font-weight  : 600;
  text-transform: capitalize;
}
.badge-agendado  { background: #dbeafe; color: #1e40af; }
.badge-confirmado{ background: #d5f5e3; color: #1a6b3f; }
.badge-realizado { background: #d1fae5; color: #065f46; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }
.badge-falta     { background: #f3f4f6; color: #4b5563; }

/* ── Toast / notificação ───────────────────────────────────── */
.toast-container {
  position  : fixed;
  bottom    : 1.5rem;
  right     : 1.5rem;
  z-index   : 400;
  display   : flex;
  flex-direction: column;
  gap       : .5rem;
}

.toast {
  background   : var(--escuro);
  color        : var(--branco);
  padding      : .75rem 1.25rem;
  border-radius: 8px;
  font-size    : .875rem;
  box-shadow   : var(--shadow-md);
  animation    : slideIn .3s ease;
  max-width    : 320px;
}
.toast.sucesso { border-left: 4px solid var(--verde); }
.toast.erro    { border-left: 4px solid var(--vermelho); }
.toast.aviso   { border-left: 4px solid var(--laranja); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Utilitários ───────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--cinza-600); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.w-100{ width: 100%; }

.estado-vazio {
  text-align  : center;
  padding     : 3rem 1rem;
  color       : var(--cinza-600);
  font-size   : .9rem;
}

.spinner {
  width          : 36px;
  height         : 36px;
  border         : 3px solid var(--cinza-200);
  border-top-color: var(--azul);
  border-radius  : 50%;
  animation      : spin .7s linear infinite;
  margin         : 2rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar customizada ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--cinza-100); }
::-webkit-scrollbar-thumb { background: var(--cinza-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cinza-600); }
