/* ============================================================
   app.css — Painel Diaconal Design System
   ============================================================ */

/* ── RESET & BASE ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  background: #f3f4f6;
  height: 100vh;
  overflow: hidden;
}

#app { height: 100vh; display: flex; flex-direction: column; }

/* ── SHELL LAYOUT ───────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 224px;
  min-width: 224px;
  background: #162032;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-nav { flex: 1; padding: 10px 8px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 8px;
  margin-bottom: 1px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }
.sidebar-nav a.active { background: #2563eb; color: #fff; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { line-height: 1; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.07); }

.sidebar-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: #64748b;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  transition: all 0.15s;
  font-family: inherit;
}
.sidebar-logout:hover { border-color: #ef4444; color: #fca5a5; }

/* Main wrapper */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Topbar */
.topbar {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  color: #374151;
  line-height: 1;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.notif-btn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 4px; opacity: 0.65; }
.notif-btn:hover { opacity: 1; }

.user-name { font-size: 13px; color: #6b7280; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── LOGIN ───────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
}

.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 44px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 28px rgba(0,0,0,0.09);
}

.login-card h1 { font-size: 22px; font-weight: 700; color: #1e40af; margin-bottom: 4px; }
.login-card p  { color: #6b7280; margin-bottom: 28px; font-size: 13px; }
.login-card .field { margin-bottom: 16px; }
.login-card label { font-size: 12.5px; font-weight: 500; color: #374151; display: block; margin-bottom: 5px; }
.login-card input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.login-card input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
  font-family: inherit;
}

.btn:disabled       { opacity: 0.5; cursor: not-allowed; }
.btn-primary        { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover:not(:disabled)  { background: #1d4ed8; }
.btn-secondary      { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover:not(:disabled){ background: #f9fafb; }
.btn-danger         { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-success        { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover:not(:disabled)  { background: #15803d; }
.btn-warning        { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover:not(:disabled)  { background: #b45309; }
.btn-ghost          { background: transparent; color: #374151; border-color: transparent; }
.btn-ghost:hover:not(:disabled)    { background: #f3f4f6; }
.btn-ghost.btn-danger { color: #ef4444; }
.btn-ghost.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-sm             { padding: 4px 10px; font-size: 12.5px; }
.btn-full           { width: 100%; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-green   { background: #dcfce7; color: #166534; }
.badge-gray    { background: #f3f4f6; color: #4b5563; }
.badge-yellow  { background: #fef9c3; color: #854d0e; }
.badge-purple  { background: #f3e8ff; color: #6b21a8; }
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-orange  { background: #ffedd5; color: #9a3412; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-cyan    { background: #cffafe; color: #155e75; }

/* ── FORMS ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 140px; }

.field label,
.field > span { font-size: 12.5px; font-weight: 500; color: #374151; }

.field input,
.field select,
.field textarea {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: #111827;
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.field textarea { resize: vertical; min-height: 80px; }

.form-row              { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row-checks       { align-items: center; flex-wrap: wrap; gap: 16px; }

.form-section-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 6px;
  margin-top: 4px;
}

.field-grow { flex: 2; min-width: 200px; }
.field-sm   { flex: 0 0 80px; min-width: 60px; }
.field-md   { flex: 1; min-width: 120px; }

.check-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #374151; cursor: pointer; user-select: none;
}
.check-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: #2563eb; }

.search-input {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 13.5px;
  width: 260px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.search-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.filter-select {
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 13.5px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
}

/* Person search autocomplete */
.person-search-wrap { position: relative; flex: 1; }
.person-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
}
.person-search-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.person-search-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 500;
  max-height: 200px;
  overflow-y: auto;
}

.person-search-opt {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  border-bottom: 1px solid #f9fafb;
  transition: background 0.1s;
}
.person-search-opt:last-child { border-bottom: none; }
.person-search-opt:hover { background: #f0f4ff; }
.person-search-opt small { color: #9ca3af; font-size: 12px; }

/* ── TABLES ──────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.data-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.1s;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
  padding: 10px 12px;
  color: #374151;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .actions-col  { width: 48px; }
.data-table .actions-cell { padding: 6px 8px; }

.person-name { font-weight: 500; color: #111827; }

/* ── MODULE LAYOUT ───────────────────────────────────────────── */
.module-container { max-width: 1200px; }

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.module-header h1 { font-size: 22px; font-weight: 700; color: #111827; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.loading-state,
.empty-state,
.error-state,
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: #9ca3af;
  text-align: center;
  font-size: 14px;
}

/* ── PAGINATION ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-top: 8px;
}

.pagination-info       { font-size: 13px; color: #6b7280; }
.pagination-controls   { display: flex; align-items: center; gap: 8px; }
.pagination-page       { font-size: 13px; color: #374151; min-width: 60px; text-align: center; }

/* ── MODALS ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  animation: slideUp 0.2s ease;
}

.modal-large { max-width: 700px; }
.modal-xl    { max-width: 900px; }

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 16px;
  border-bottom: 1px solid #f3f4f6;
  position: sticky; top: 0; background: #fff; z-index: 1;
}

.modal-header h2 { font-size: 17px; font-weight: 600; color: #111827; }

.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: #9ca3af; padding: 2px 6px; border-radius: 4px; line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: #374151; }

.modal-body {
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid #f3f4f6;
}

.confirm-modal { max-width: 380px; }
.confirm-message { padding: 24px 24px 0; font-size: 15px; color: #374151; line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; }

/* ── TOAST ───────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 9999; opacity: 0; transform: translateY(8px);
  transition: all 0.2s ease; max-width: 360px; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { background: #16a34a; color: #fff; }
.toast-error   { background: #ef4444; color: #fff; }
.toast-info    { background: #2563eb; color: #fff; }
.toast-warning { background: #d97706; color: #fff; }

/* ── LOADING OVERLAY ─────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.65);
  display: none; align-items: center; justify-content: center;
  z-index: 5000;
}
#loading-overlay.visible { display: flex; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── DASHBOARD — KPI CARDS ───────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border: 1px solid #e9edf2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.09); }

.stat-header { display: flex; align-items: center; justify-content: space-between; }

.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-icon-blue   { background: #dbeafe; }
.stat-icon-green  { background: #dcfce7; }
.stat-icon-orange { background: #ffedd5; }
.stat-icon-red    { background: #fee2e2; }
.stat-icon-purple { background: #f3e8ff; }
.stat-icon-yellow { background: #fef9c3; }

.stat-value { font-size: 32px; font-weight: 700; color: #111827; line-height: 1; }
.stat-label { font-size: 12.5px; color: #6b7280; font-weight: 500; }
.stat-trend { font-size: 11.5px; color: #9ca3af; }

/* ── DASHBOARD — QUICK LISTS ─────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.dashboard-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e9edf2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  overflow: hidden;
}

.dashboard-card-header {
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
  display: flex; align-items: center; justify-content: space-between;
}

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid #f9fafb;
  font-size: 13px;
}
.list-item:last-child { border-bottom: none; }
.list-item-name { font-weight: 500; color: #111827; flex: 1; }
.list-item-sub  { font-size: 12px; color: #9ca3af; }
.list-item-icon { font-size: 18px; }

.empty-list { padding: 28px; text-align: center; color: #9ca3af; font-size: 13px; }

/* ── VISITS PRIORITY ─────────────────────────────────────────── */
.priority-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.priority-low    { background: #9ca3af; }
.priority-normal { background: #3b82f6; }
.priority-high   { background: #f59e0b; }
.priority-urgent { background: #ef4444; }

/* ── DETAIL PANEL (SLIDE-OVER) ───────────────────────────────── */
.detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 900;
  animation: fadeIn 0.15s;
}

.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 100vw;
  background: #fff;
  z-index: 901;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0,0,0,0.1);
  animation: slideInRight 0.2s ease;
  display: flex; flex-direction: column;
}

@keyframes slideInRight {
  from { transform: translateX(32px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.detail-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f3f4f6;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.detail-title { font-size: 17px; font-weight: 600; color: #111827; }
.detail-sub   { font-size: 13px; color: #6b7280; margin-top: 2px; }
.detail-body  { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; flex: 1; }

.detail-section {
  display: flex; flex-direction: column; gap: 10px;
}

.detail-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: #9ca3af; margin-bottom: 2px;
}

.detail-row { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11.5px; color: #9ca3af; font-weight: 500; }
.detail-value { font-size: 13.5px; color: #111827; }

.detail-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.detail-actions {
  padding: 16px 24px;
  border-top: 1px solid #f3f4f6;
  display: flex; gap: 8px; flex-wrap: wrap;
  position: sticky; bottom: 0; background: #fff;
}

/* ── TABLE CARD WRAPPER ─────────────────────────────────────── */
.table-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e9edf2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  overflow: hidden;
}

/* ── RESPONSIVE – MOBILE ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
  .search-input { width: 100%; }
  .form-row { flex-direction: column; }
  .detail-panel { width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .modal-large { max-width: 100%; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .content { padding: 12px; }
}
