/* ============================================================
   layout.css — Sidebar, header, grid principal e telas
   ============================================================ */

/* ── Tela de Login ── */
#login-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(201, 168, 76, 0.07) 0%, transparent 70%),
    var(--bg);
  z-index: var(--z-modal);
}

#login-screen.visible { display: flex; }

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-9) var(--sp-8);
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease;
}

.login-logo {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semi);
  color: var(--gold);
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-1);
}

.login-sub {
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: var(--sp-8);
}

.login-card label {
  display: block;
  text-align: left;
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: var(--sp-2);
}

.login-card .input {
  margin-bottom: var(--sp-5);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: var(--sp-3);
  min-height: 18px;
}

/* ── App Screen ── */
#app-screen {
  display: none;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#app-screen.visible { display: grid; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Sidebar lateral (navegação) ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.sidebar-brand-title {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  font-weight: var(--fw-semi);
  color: var(--gold);
}

.sidebar-brand-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  background: var(--surface2);
  color: var(--gold);
  border-left-color: var(--gold);
}

.nav-item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-item-label { flex: 1; }

.nav-divider {
  margin: var(--sp-3) var(--sp-3);
  border: 0;
  border-top: 1px solid var(--border-soft);
}

.sidebar-user {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-semi);
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-area {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.btn-logout:hover { color: var(--text); background: var(--surface2); }

/* ── Área principal ── */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.main-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  flex-shrink: 0;
}

.main-title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  color: var(--text);
  font-weight: var(--fw-semi);
  flex: 1;
}

.main-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ── Mobile toggler ── */
.btn-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: var(--sp-2);
}

/* ── Páginas internas ── */
.page {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.page.active { display: flex; }

/* ── Slide-over (painel lateral do lead) ── */
.slideover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.slideover-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.slideover {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--slideover-w);
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  box-shadow: var(--shadow-lg);
}

.slideover.visible { transform: translateX(0); }

.slideover-header {
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.slideover-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-semi);
  flex-shrink: 0;
  border: 1px solid rgba(201, 168, 76, 0.25);
}

.slideover-header-info { flex: 1; min-width: 0; }

.slideover-header-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slideover-header-tel {
  font-size: 12px;
  color: var(--text-dim);
}

.btn-close-slideover {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.btn-close-slideover:hover { background: var(--surface2); color: var(--text); }

.slideover-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.slideover-tab {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.slideover-tab:hover { color: var(--text); }
.slideover-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.slideover-panel {
  flex: 1;
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.slideover-panel.active { display: flex; }

/* ── Responsividade ── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 240px;
    z-index: var(--z-modal);
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.open { transform: translateX(0); }
  .btn-menu { display: inline-flex; }
  .slideover { width: 100vw; }
}

@media (min-width: 901px) {
  .slideover { width: var(--slideover-w-lg); }
}

/* ── Toasts ── */
.toast-container {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: var(--surface);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition);
  pointer-events: auto;
  max-width: 360px;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-left: 3px solid var(--etapa-fechado); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--etapa-aguardando); }
.toast-warning { border-left: 3px solid var(--warning); }
