/* ================================================================
   LAYOUT - Sidebar, Header, Content do Painel Admin
   Consistente com Design System dos Prontuários Aprovados
   ================================================================ */

/* === APP LAYOUT === */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.app-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: linear-gradient(180deg, var(--accent-dark) 0%, #062033 100%);
  color: #fff;
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Sidebar Logo / Brand */
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-section-title {
  padding: 16px 20px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  font-weight: 700;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent-blue);
  border-radius: 0 3px 3px 0;
}
.nav-item i, .nav-item .icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}
.nav-item .badge, .nav-badge {
  margin-left: auto;
  background: rgba(239,68,68,0.2);
  color: #fca5a5;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Sidebar User */
.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
}

/* Sidebar Overlay (mobile) */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 499;
}

/* === HEADER === */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
#sidebarToggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  box-shadow: none;
  border-radius: 6px;
}
#sidebarToggle:hover {
  color: var(--accent);
  transform: none;
  box-shadow: none;
}
.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.header-search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
  font-size: 0.9rem;
  color: var(--ink);
  font-family: inherit;
}
.header-search-input:focus {
  outline: none;
  border-color: var(--focus);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(14,165,233,0.15);
}
.header-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-light);
  font-size: 14px;
  pointer-events: none;
}
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 16px;
  transition: all 0.15s;
  position: relative;
  padding: 0;
  box-shadow: none;
}
.header-icon-btn:hover {
  background: #f1f5f9;
  color: var(--accent);
  transform: none;
  box-shadow: none;
}
.header-icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--card-bg);
}
.header-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  box-shadow: none;
}
.header-user-btn:hover {
  background: #f1f5f9;
  transform: none;
  box-shadow: none;
}
.header-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
}
.header-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

/* === PAGE HEADER === */
.page-header {
  padding: 28px 28px 20px;
}
.page-title {
  font-size: 18pt;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  line-height: 1.15;
}
.page-subtitle {
  font-size: 0.9rem;
  color: var(--muted-light);
  margin-top: 4px;
}

/* === MAIN CONTENT AREA === */
.main-wrap {
  flex: 1;
  padding: 0 28px 40px;
}

/* === STAT CARDS (padrão ferramentas) === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.6);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.25s;
  animation: slideUp 0.6s ease-out;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px -10px rgba(0,0,0,0.12);
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.blue { background: rgba(14,165,233,0.1); color: #0284c7; }
.stat-icon.amber { background: rgba(245,158,11,0.1); color: #d97706; }
.stat-icon.red { background: rgba(239,68,68,0.1); color: #dc2626; }
.stat-icon.green { background: rgba(16,185,129,0.1); color: #059669; }
.stat-icon.purple { background: rgba(124,58,237,0.1); color: #7c3aed; }
.stat-info { flex: 1; }
.stat-label {
  font-size: 0.8rem;
  color: var(--muted-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-dark);
  line-height: 1.2;
  margin-top: 2px;
}
.stat-change {
  font-size: 0.75rem;
  margin-top: 4px;
  font-weight: 600;
}
.stat-change.up { color: #059669; }
.stat-change.down { color: #dc2626; }

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.filter-bar select, .filter-bar input {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
  min-width: 140px;
  width: auto;
}

/* === SETTINGS NAV (configurações) === */
.settings-nav {
  display: flex;
  gap: 0;
  background: #fff;
  padding: 0 28px;
  flex-wrap: wrap;
}
.settings-nav::before,
.settings-nav::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
  align-self: center;
}
.settings-nav-item {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 20px 28px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 0;
  box-shadow: none;
}
.settings-nav-item:hover {
  color: var(--accent);
  background: transparent;
  transform: none;
  box-shadow: none;
}
.settings-nav-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}
.settings-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}
.settings-section.active { display: block; }

/* === TIMELINE / ACTIVITY === */
.timeline {
  display: flex;
  flex-direction: column;
}
.timeline-item {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: #f1f5f9;
  color: var(--muted);
}
.timeline-content { flex: 1; }
.timeline-text {
  font-size: 0.9rem;
  color: var(--ink);
}
.timeline-time {
  font-size: 0.75rem;
  color: var(--muted-light);
  margin-top: 2px;
}

/* === NOTIFICATIONS LIST === */
#notificationsList {
  max-height: 300px;
  overflow-y: auto;
}

/* === RESPONSIVIDADE === */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .app-content { margin-left: 0; }
  #sidebarToggle { display: flex; }
  #sidebarOverlay.active { display: block; }
  .settings-nav {
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  .settings-nav-item {
    padding: 14px 20px;
    font-size: 13px;
    white-space: nowrap;
  }
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; }
  .header { padding: 0 16px; }
  .page-header { padding: 20px 16px 12px; }
  .page-title { font-size: 16pt; }
  .main-wrap { padding: 0 16px 30px; }
  .header-search { display: none; }
  .filter-bar { padding: 12px 16px; }
  .filter-bar select, .filter-bar input { min-width: 100%; }
}
