/* ============================================================
   RESET & VARIÁVEIS
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary: #1a6bb5;
  --c-primary-dark: #145290;
  --c-primary-light: #e8f0fb;
  --c-secondary: #4caf50;
  --c-danger: #e53935;
  --c-warning: #f59e0b;
  --c-text: #1e293b;
  --c-muted: #64748b;
  --c-border: #e2e8f0;
  --c-bg: #f1f5f9;
  --c-white: #ffffff;
  --c-sidebar: #0f172a;
  --c-sidebar-text: #94a3b8;
  --c-sidebar-active: #1a6bb5;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --font: 'Segoe UI', system-ui, sans-serif;
}

body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); font-size: 14px; }

/* ============================================================
   LOGIN
============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1a6bb5 100%);
}
.login-box {
  background: var(--c-white);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 340px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: .75rem;
}
.login-logo { display: flex; align-items: center; gap: .5rem; justify-content: center; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.3rem; color: var(--c-primary); }
.logo-icon { font-size: 1.8rem; }
.login-box label { font-weight: 600; font-size: .85rem; color: var(--c-muted); }
.login-box input { padding: .6rem .9rem; border: 1px solid var(--c-border); border-radius: var(--radius); font-size: .95rem; transition: border-color .2s; }
.login-box input:focus { outline: none; border-color: var(--c-primary); }
.btn-block { width: 100%; margin-top: .5rem; }

/* ============================================================
   LAYOUT PRINCIPAL
============================================================ */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--c-sidebar);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100%;
  z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.25rem 1rem; color: #fff;
  font-weight: 700; font-size: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-item {
  display: block; padding: .65rem 1.25rem;
  color: var(--c-sidebar-text);
  text-decoration: none; font-size: .92rem;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.ativo { background: rgba(26,107,181,.2); color: #fff; border-left-color: var(--c-primary); }
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: .5rem;
}
#sidebar-user { flex: 1; color: var(--c-sidebar-text); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-content { margin-left: 220px; flex: 1; padding: 2rem; min-height: 100vh; }

/* ============================================================
   ABAS / SEÇÕES
============================================================ */
.tab-section { display: none; }
.tab-section.ativo { display: block; }

.sub-tabs { display: flex; gap: .5rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--c-border); }
.sub-tab {
  padding: .5rem 1.25rem; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; cursor: pointer; font-size: .9rem; color: var(--c-muted); font-weight: 600;
}
.sub-tab.ativo { border-bottom-color: var(--c-primary); color: var(--c-primary); }

/* ============================================================
   COMPONENTES COMUNS
============================================================ */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-header h2 { font-size: 1.4rem; font-weight: 700; }
.page-header h3 { font-size: 1.1rem; font-weight: 600; }

.filtros-bar { display: flex; gap: .75rem; margin-bottom: 1rem; align-items: center; }
.inp-busca { flex: 1; max-width: 340px; padding: .55rem .9rem; border: 1px solid var(--c-border); border-radius: var(--radius); font-size: .9rem; }

.table-wrap { overflow-x: auto; background: var(--c-white); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--c-primary-light); color: var(--c-primary-dark); font-weight: 700; padding: .75rem 1rem; text-align: left; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.table td { padding: .65rem 1rem; border-bottom: 1px solid var(--c-border); font-size: .9rem; vertical-align: middle; }
.table tbody tr:hover { background: var(--c-primary-light); }
.table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block; padding: .2rem .65rem;
  border-radius: 99px; font-size: .75rem; font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #16a34a; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-gray   { background: #f1f5f9; color: #64748b; }

/* ============================================================
   BOTÕES
============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .55rem 1.1rem; border-radius: var(--radius);
  border: none; font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: background .2s, opacity .2s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--c-primary); color: #fff; }
.btn-primary:hover  { background: var(--c-primary-dark); }
.btn-secondary{ background: #e2e8f0; color: var(--c-text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger   { background: var(--c-danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-outline  { background: transparent; color: var(--c-primary); border: 1px solid var(--c-primary); }
.btn-outline:hover { background: var(--c-primary-light); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs { padding: .25rem .55rem; font-size: .75rem; border-radius: 4px; }

/* ============================================================
   DASHBOARD CARDS
============================================================ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.card-stat {
  background: var(--c-white); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .4rem;
}
.card-stat .card-label { font-size: .8rem; color: var(--c-muted); font-weight: 600; text-transform: uppercase; }
.card-stat .card-value { font-size: 2rem; font-weight: 800; color: var(--c-primary); }
.card-stat .card-icon { font-size: 1.5rem; }

/* ============================================================
   FORMULÁRIO (dentro de modais)
============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.form-grid .span2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--c-muted); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: .55rem .8rem; border: 1px solid var(--c-border);
  border-radius: var(--radius); font-size: .9rem; font-family: var(--font);
  transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--c-primary); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input[readonly] { background: #f8fafc; color: var(--c-muted); }

/* ============================================================
   MODAL
============================================================ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.aberto { display: flex; }
.modal-box {
  background: var(--c-white); border-radius: 12px;
  width: min(680px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: fadeUp .2s ease;
}
.modal-lg { width: min(860px, 98vw); }
@keyframes fadeUp { from { opacity:0; transform: translateY(20px) } to { opacity:1; transform: none } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--c-border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-fechar { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--c-muted); }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; gap: .75rem; justify-content: flex-end;
  padding: .9rem 1.25rem; border-top: 1px solid var(--c-border);
}

/* ============================================================
   AGENDA / CALENDÁRIO
============================================================ */
.agenda-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; }
.agenda-calendario { background: var(--c-white); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; font-weight: 700; }
.cal-dias-semana { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: .78rem; font-weight: 700; color: var(--c-muted); margin-bottom: .4rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dia {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: .85rem; cursor: pointer; font-weight: 500;
  transition: background .15s;
}
.cal-dia:hover { background: var(--c-primary-light); }
.cal-dia.hoje { background: var(--c-primary); color: #fff; font-weight: 700; }
.cal-dia.com-evento::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--c-secondary); position: absolute; bottom: 3px;
}
.cal-dia.com-evento { position: relative; }
.cal-dia.outro-mes { color: #c0c0c0; }
.cal-dia.selecionado { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.agenda-lista { background: var(--c-white); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.agenda-lista h3 { margin-bottom: 1rem; font-size: .95rem; font-weight: 700; color: var(--c-muted); }
.agenda-item {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .75rem; border-radius: 6px; margin-bottom: .5rem;
  border-left: 3px solid var(--c-primary); background: var(--c-primary-light);
}
.agenda-hora { font-weight: 700; font-size: .9rem; white-space: nowrap; color: var(--c-primary); }
.agenda-info { flex: 1; }
.agenda-info strong { display: block; font-size: .9rem; }
.agenda-info small { color: var(--c-muted); font-size: .8rem; }

/* ============================================================
   TABELAS DE SELEÇÃO
============================================================ */
.tabelas-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; }
.tabela-cats { background: var(--c-white); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); height: fit-content; }
.tabela-cats h3 { font-size: .9rem; font-weight: 700; color: var(--c-muted); margin-bottom: .75rem; text-transform: uppercase; }
.tabela-cats ul { list-style: none; }
.tabela-cats li {
  padding: .55rem .75rem; border-radius: 6px;
  cursor: pointer; font-size: .9rem; margin-bottom: 2px;
}
.tabela-cats li:hover { background: var(--c-primary-light); }
.tabela-cats li.ativo { background: var(--c-primary); color: #fff; font-weight: 600; }

/* ============================================================
   ALERTAS
============================================================ */
.alerta { padding: .65rem 1rem; border-radius: var(--radius); font-size: .88rem; font-weight: 500; }
.alerta-erro   { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alerta-ok     { background: #dcfce7; color: #16a34a; border: 1px solid #86efac; }
.alerta-warn   { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--c-text); color: #fff;
  padding: .7rem 1.25rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; box-shadow: var(--shadow-lg);
  z-index: 9999; opacity: 0; transform: translateY(10px);
  transition: opacity .3s, transform .3s; pointer-events: none;
}
.toast.visivel { opacity: 1; transform: none; }
.toast.sucesso { background: #16a34a; }
.toast.erro    { background: var(--c-danger); }

/* ============================================================
   RESPONSIVIDADE
============================================================ */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar-logo span, .nav-item span, #sidebar-user, .nav-item { font-size: .7rem; }
  .sidebar-logo span { display: none; }
  .main-content { margin-left: 60px; padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .agenda-layout { grid-template-columns: 1fr; }
  .tabelas-layout { grid-template-columns: 1fr; }
}
