/* ═══════════════════════════════════════════════════════════════
   CivilPro — Layout (Sidebar, Header, Content)
   ═══════════════════════════════════════════════════════════════ */

/* ═══════ APP SHELL ═══════ */
#app {
  display: flex;
  min-height: 100vh;
}

/* ═══════ SIDEBAR ═══════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--t-slow);
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--grad-blue);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--blue-glow);
  flex-shrink: 0;
}

.logo-icon svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.3px;
}

.logo-tagline {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ═══════ SIDEBAR NAV ═══════ */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 16px 16px 4px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  margin: 1px 0;
  cursor: pointer;
  transition: all var(--t);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item:hover .nav-icon {
  color: var(--blue);
}

.nav-item.active {
  background: var(--blue-surface);
  color: var(--blue-light);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--blue);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--blue);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: color var(--t);
  color: var(--text-muted);
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}

.nav-badge.info { background: var(--blue); }
.nav-badge.warning { background: var(--warning); color: #000; }
.nav-badge.success { background: var(--success); }

/* ═══════ SIDEBAR FOOTER ═══════ */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t);
}

.user-card:hover { background: var(--bg-hover); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

/* ═══════ MAIN CONTENT AREA ═══════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ═══════ HEADER ═══════ */
.header {
  height: var(--header-h);
  background: rgba(6, 11, 24, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
}

.breadcrumb-sep {
  color: var(--text-muted);
}

.breadcrumb-current {
  font-weight: 600;
  color: var(--text-primary);
}

.header-search {
  position: relative;
  flex: 0 0 320px;
  transition: flex var(--t);
}

.header-search:focus-within {
  flex: 0 0 420px;
}

.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: all var(--t);
}

.header-search input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.header-search input::placeholder { color: var(--text-muted); }

.header-search .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px;
  height: 15px;
}

/* Dropdown de Busca Global */
.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 480px;
  max-width: 90vw;
  max-height: 480px;
  overflow-y: auto;
  background: rgba(13, 21, 38, 0.96);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: none;
  animation: searchDrop 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.search-results-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.search-results-section:last-child {
  border-bottom: none;
}

.search-section-title {
  padding: 6px 14px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--t);
  text-decoration: none;
}

.search-result-item:hover, .search-result-item.selected {
  background: rgba(59, 130, 246, 0.12);
}

.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.search-result-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.search-footer-action {
  padding: 9px 14px;
  background: rgba(59, 130, 246, 0.08);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--blue-light);
  cursor: pointer;
}
.search-footer-action:hover {
  background: rgba(59, 130, 246, 0.15);
}

.search-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t);
  color: var(--text-secondary);
  position: relative;
}

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

.header-btn svg {
  width: 17px;
  height: 17px;
}

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 15px;
  height: 15px;
  border-radius: var(--r-full);
  background: var(--danger);
  border: 1.5px solid var(--bg-surface);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ═══════ DROPDOWN DE NOTIFICAÇÕES (SEM SOBREPOSIÇÃO) ═══════ */
.notif-wrapper {
  position: relative;
  display: inline-block;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 380px;
  max-width: 92vw;
  background: rgba(13, 21, 38, 0.98);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(59, 130, 246, 0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1200;
  display: none;
  overflow: hidden;
  animation: notifDrop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.notif-dropdown.open {
  display: block;
}

@keyframes notifDrop {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.notif-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.notif-body {
  max-height: 380px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.notif-item:hover {
  background: rgba(59, 130, 246, 0.08);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item.lida {
  opacity: 0.65;
}

.notif-item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-item-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notif-item-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.notif-item-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.notif-footer {
  padding: 10px 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border);
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left {}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ═══════ FILTERS BAR ═══════ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

/* ═══════ MOBILE HAMBURGER ═══════ */
.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 6px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--t);
}

/* ═══════ SIDEBAR OVERLAY (mobile) ═══════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .header-search {
    flex: 0 0 200px;
  }

  .page-content {
    padding: 16px;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .header-search {
    display: none;
  }
}
