/* OmniTEA - CSS Principal */
:root {
  --primary: #2B6CB0;
  --primary-dark: #1A4A8A;
  --primary-light: #4299E1;
  --secondary: #68D391;
  --accent: #81C784;
  --sidebar-width: 260px;
  --header-height: 64px;
  --teal: #4A9E8E;
  --teal-light: #6DC2B3;
  --teal-bg: #E6F7F5;
  --blue-bg: #EBF4FF;
  --text-primary: #2D3748;
  --text-secondary: #718096;
  --border: #E2E8F0;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #F7F9FC; color: var(--text-primary); }

/* LAYOUT */
#app { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1A3A5C 0%, #1E4D7B 100%);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img { width: 40px; height: 40px; object-fit: contain; }
.sidebar-logo span { color: white; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.5px; }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-title {
  color: rgba(255,255,255,0.4);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
  font-size: 0.875rem;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  border-left-color: rgba(255,255,255,0.3);
}

.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: white;
  border-left-color: #68D391;
}

.nav-item i { width: 20px; text-align: center; font-size: 0.9rem; }
.nav-item .nav-badge {
  margin-left: auto;
  background: #E53E3E;
  color: white;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.8);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 0.8rem; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); }

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* TOP HEADER */
.top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); flex: 1; }
.header-subtitle { font-size: 0.75rem; color: var(--text-secondary); display: block; font-weight: 400; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  position: relative;
}

.btn-icon:hover { background: var(--blue-bg); color: var(--primary); border-color: var(--primary-light); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #E53E3E;
  border: 2px solid white;
}

/* PAGE CONTENT */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #F7F9FC;
}

/* CARDS */
.card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }

/* STAT CARDS */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.stat-change { font-size: 0.75rem; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-change.up { color: #38A169; }
.stat-change.down { color: #E53E3E; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--teal); color: white; }
.btn-secondary:hover { background: #3A8E7E; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--blue-bg); }
.btn-danger { background: #E53E3E; color: white; }
.btn-danger:hover { background: #C53030; }
.btn-success { background: #38A169; color: white; }
.btn-success:hover { background: #2F855A; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.825rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-label span.required { color: #E53E3E; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.form-control:disabled { background: #F7F9FC; color: var(--text-secondary); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

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

.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-blue { background: #EBF8FF; color: #2B6CB0; }
.badge-green { background: #F0FFF4; color: #276749; }
.badge-yellow { background: #FFFFF0; color: #744210; }
.badge-red { background: #FFF5F5; color: #9B2C2C; }
.badge-purple { background: #FAF5FF; color: #553C9A; }
.badge-teal { background: var(--teal-bg); color: #285E61; }
.badge-gray { background: #EDF2F7; color: #4A5568; }
.badge-orange { background: #FFFAF0; color: #7B341E; }

/* TABLE */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #F7F9FC; padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-secondary); border-bottom: 2px solid var(--border); }
tbody td { padding: 12px 14px; font-size: 0.875rem; border-bottom: 1px solid var(--border); color: var(--text-primary); }
tbody tr:hover { background: #FAFBFD; }
tbody tr:last-child td { border-bottom: none; }

/* PATIENT CARD */
.patient-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: var(--card-shadow);
}

.patient-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); border-color: var(--primary-light); }

.patient-card-header { padding: 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }

.patient-avatar {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.patient-name { font-size: 0.95rem; font-weight: 600; }
.patient-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.patient-card-body { padding: 12px 16px; }
.patient-card-footer { padding: 10px 16px; background: #FAFBFD; display: flex; gap: 8px; border-top: 1px solid var(--border); }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.modal-header h2 { font-size: 1.05rem; font-weight: 700; flex: 1; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* CALENDAR */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-header-day { text-align: center; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); padding: 8px 4px; }
.calendar-day {
  min-height: 80px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: background 0.15s;
}
.calendar-day:hover { background: var(--blue-bg); }
.calendar-day.today { border-color: var(--primary); background: var(--blue-bg); }
.calendar-day.other-month { background: #FAFBFD; opacity: 0.6; }
.calendar-day .day-number { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.calendar-day.today .day-number { color: var(--primary); }
.calendar-event {
  font-size: 0.68rem;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* SEARCH */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box i { position: absolute; left: 12px; color: var(--text-secondary); font-size: 0.85rem; }
.search-box input { padding-left: 36px; }

/* PROGRESS */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

/* SCALE FORM */
.scale-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #FAFBFD;
}
.scale-item .question { font-size: 0.875rem; font-weight: 500; margin-bottom: 10px; }
.scale-options { display: flex; gap: 8px; flex-wrap: wrap; }
.scale-option {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}
.scale-option:hover { border-color: var(--primary); color: var(--primary); }
.scale-option.selected { background: var(--primary); color: white; border-color: var(--primary); }

/* ALERT */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.875rem; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.alert-info { background: #EBF8FF; color: #2C5282; border: 1px solid #BEE3F8; }
.alert-success { background: #F0FFF4; color: #276749; border: 1px solid #9AE6B4; }
.alert-warning { background: #FFFFF0; color: #744210; border: 1px solid #FAF089; }
.alert-error { background: #FFF5F5; color: #9B2C2C; border: 1px solid #FEB2B2; }

/* TIMELINE */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot { position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 2px var(--border); }
.timeline-content { background: white; border-radius: 8px; padding: 12px; border: 1px solid var(--border); }

/* CHIPS */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--blue-bg);
  border: 1px solid #BEE3F8;
  border-radius: 16px;
  font-size: 0.75rem;
  color: var(--primary);
}
.chip.removable { cursor: pointer; }
.chip.removable:hover { background: #FFF5F5; border-color: #FEB2B2; color: #E53E3E; }

/* TOAST */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: white;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  pointer-events: all;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--primary);
  min-width: 300px;
  max-width: 400px;
}
.toast.success { border-left-color: #38A169; }
.toast.error { border-left-color: #E53E3E; }
.toast.warning { border-left-color: #D69E2E; }

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

/* LOADING */
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--text-secondary); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 3rem; opacity: 0.3; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 0.875rem; }

/* GRID UTILS */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* RESPONSIVE */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }

/* SEVERITY LEVELS */
.severity-1 { background: #F0FFF4; color: #276749; border-color: #9AE6B4; }
.severity-2 { background: #FFFFF0; color: #744210; border-color: #FAF089; }
.severity-3 { background: #FFF5F5; color: #9B2C2C; border-color: #FEB2B2; }

/* SCORE INDICATOR */
.score-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }

/* PRINT */
@media print {
  .sidebar, .top-header, .btn, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; overflow: visible !important; }
  .card { box-shadow: none !important; break-inside: avoid; }
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
  .sidebar { background: #000033; }
  .card { border: 2px solid #000; }
  .form-control { border: 2px solid #000; }
}

/* MOBILE SIDEBAR OVERLAY */
@media (max-width: 768px) {
  #sidebar-toggle { display: flex !important; }
  .sidebar { z-index: 200; }
  .sidebar.open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: -1;
  }
}

/* ADMIN STATS ADDITIONS */
.toggle-switch input { width: 20px; height: 20px; }

/* CHAT BUBBLE ANIMATION */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* EMERGENCY BUTTON */
#emergency-samu-btn {
  transition: transform 0.2s;
}
#emergency-samu-btn:hover {
  transform: scale(1.05);
}

/* SIDEBAR MOBILE OVERLAY */
@media (max-width: 768px) {
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
}

/* ACCESSIBILITY IMPROVEMENTS */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* LOADING STATE */
.btn[disabled], button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* SCROLLABLE TABS ON MOBILE */
.tabs::-webkit-scrollbar { height: 3px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border); }

/* ═══════════════════════════════════════════════════════════
   VB-MAPP – Estilos das grades de pontuação
   ═══════════════════════════════════════════════════════════ */

/* Células clicáveis da grade VB-MAPP */
#vbmapp-marcos-modal td[id^="vb-m-"],
#vbmapp-barreiras-modal td[id^="vb-b-"],
#vbmapp-transicao-modal td[id^="vb-t-"],
td[id^="vb-m-"], td[id^="vb-b-"], td[id^="vb-t-"],
td[id^="vb2-b-"], td[id^="vb2-t-"] {
  transition: background-color 0.15s ease, transform 0.1s ease;
}
td[id^="vb-m-"]:hover,
td[id^="vb-b-"]:hover,
td[id^="vb-t-"]:hover,
td[id^="vb2-b-"]:hover,
td[id^="vb2-t-"]:hover {
  opacity: 0.8;
  transform: scale(1.05);
  z-index: 1;
  position: relative;
}

/* Abas do modal VB-MAPP principal */
.vb-tab-btn:hover {
  color: white !important;
  background: rgba(255,255,255,0.1) !important;
}

/* Print do VB-MAPP */
@media print {
  #vbmapp-marcos-modal,
  #vbmapp-barreiras-modal,
  #vbmapp-transicao-modal {
    break-inside: avoid;
  }
  .modal-footer, .modal-header button {
    display: none !important;
  }
  td[id^="vb-m-"],
  td[id^="vb-b-"],
  td[id^="vb-t-"],
  td[id^="vb2-b-"],
  td[id^="vb2-t-"] {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
