/* ============================================================
   GPS IMOBILIÁRIO — layout.css
   Estrutura principal: screens, topbar, sidebar, app shell
   v0.0.9 · 2026-03-25
   ============================================================ */

/* ─── SCREENS ─── */
#screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(184,150,12,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(45,80,22,0.05) 0%, transparent 50%);
}
#screen-app {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}
#screen-cliente {
  min-height: 100vh;
  background: var(--cream);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(184,150,12,0.06) 0%, transparent 60%);
}

/* ─── TOPBAR ─── */
.topbar {
  height: 56px;
  background: white;
  border-bottom: 1px solid var(--cream-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--font-2xl);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  flex-shrink: 0;
}
.topbar-logo span { color: var(--accent); }
.topbar-spacer { flex: 1; }
.topbar-user {
  font-size: var(--font-sm);
  color: var(--ink-muted);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--cream-dark);
  border: 1px solid var(--cream-border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-sm); font-weight: 500; color: var(--ink-soft);
  flex-shrink: 0; overflow: hidden;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.btn-logout {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--cream-border);
  border-radius: var(--r);
  font-size: var(--font-sm);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all .2s;
  font-family: 'DM Sans', sans-serif;
}
.btn-logout:hover { background: var(--cream); color: var(--ink); }

/* ─── TOPBAR USER PILL ─── */
.topbar-user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 3px;
  background: transparent;
  border: 1px solid var(--cream-border);
  border-radius: var(--r);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  font-family: 'DM Sans', sans-serif;
  flex-shrink: 0;
}
.topbar-user-pill .topbar-avatar {
  width: 24px;
  height: 24px;
  font-size: var(--font-xs);
}
.topbar-user-pill:hover {
  background: var(--cream);
  border-color: var(--accent-light);
}
.topbar-pill-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.topbar-pill-nome {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-pill-role {
  font-size: var(--font-xs);
  color: var(--ink-muted);
  line-height: 1;
  white-space: nowrap;
}

/* ─── ROLE BADGE ─── */
.role-badge {
  padding: 3px 10px;
  border-radius: 10px;
  font-size: var(--font-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.role-badge.admin      { background: var(--accent-bg);    color: var(--accent);      border: 1px solid rgba(184,150,12,0.25); }
.role-badge.comercial  { background: var(--blue-bg);    color: var(--blue-soft); border: 1px solid rgba(26,58,92,0.15); }
.role-badge.processual { background: var(--green-light); color: var(--green);    border: 1px solid rgba(45,80,22,0.2); }

/* ─── APP LAYOUT ─── */
.app-layout { display: flex; flex: 1; min-height: 0; }
.main-content { flex: 1; overflow-y: auto; min-width: 0; }
.app-body { flex: 1; padding: 24px 20px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--cream-border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar-section-label {
  font-size: var(--font-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 16px;
  margin: 16px 0 6px;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.sidebar-section-label:hover { color: var(--ink-soft); }
.sidebar-section-label::after {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-right: 1.5px solid var(--cream-border);
  border-bottom: 1.5px solid var(--cream-border);
  transform: rotate(45deg);
  transition: transform .2s;
  margin-left: 6px;
  flex-shrink: 0;
}
.sidebar-section-label:hover::after { border-color: var(--ink-muted); }
.sidebar-section-label.collapsed::after {
  transform: rotate(-45deg);
}
.sidebar-section-items {
  overflow: hidden;
  max-height: 500px;
  flex-shrink: 0;
  transition: max-height .25s ease;
}
.sidebar-section-label { flex-shrink: 0; }
.sidebar-section-label.collapsed + .sidebar-section-items {
  max-height: 0;
}
.sidebar-section-label:first-child { margin-top: 0; }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: var(--font-base);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.sidebar-item:hover { background: var(--cream); color: var(--ink); }
.sidebar-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.sidebar-item svg { flex-shrink: 0; opacity: 0.6; }
.sidebar-item.active svg { opacity: 1; }
/* ─── SIDEBAR MINI (icons only) ─── */
.sidebar-collapse-btn {
  width: 100%; padding: 8px; background: var(--cream); border: 1px solid var(--cream-border);
  border-radius: var(--r); cursor: pointer; color: var(--ink-muted); transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-collapse-btn:hover { background: var(--cream-dark); color: var(--ink); }
.sidebar-mini .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-mini { width: 52px; transition: width .2s ease; overflow: hidden; }
.sidebar-mini .sidebar-section-label { display: none; }
.sidebar-mini .sidebar-section-items {
  max-height: 500px !important;
  padding: 4px 0;
  border-bottom: 1px solid var(--cream-border);
}
.sidebar-mini .sidebar-section-items:last-child { border-bottom: none; }
.sidebar-mini .sidebar-item {
  padding: 10px 0; justify-content: center; gap: 0;
  font-size: 0; border-left-width: 0;
}
.sidebar-mini .sidebar-item svg { opacity: 0.7; }
.sidebar-mini .sidebar-item:hover svg { opacity: 1; }
.sidebar-mini .sidebar-item.active { border-left-width: 0; background: var(--accent-bg); }
.sidebar-mini .sidebar-item.active svg { opacity: 1; }
.sidebar-mini .sidebar-badge { display: none; }

.sidebar-badge {
  margin-left: auto;
  background: var(--red-soft);
  color: white;
  border-radius: 10px;
  font-size: var(--font-xs);
  font-weight: 600;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26,24,20,0.4);
  z-index: 149;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.visible { display: block; }

/* ─── TABS ─── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── MEDIA QUERIES ─── */

/* Tablet (≤ 1024px) */
@media (max-width: 1024px) {
  .sidebar { width: 180px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-col { min-width: 200px; }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {

  /* Layout */
  .app-body { padding: 12px; }
  .action-bar { gap: 6px; flex-wrap: wrap; }

  /* Login */
  .login-card { padding: 32px 20px; max-width: 100%; margin: 0 16px; }

  /* Topbar */
  .topbar { padding: 0 14px; height: 52px; }
  .topbar-user span.user-email { display: none; }
  .btn-nosso-gps span { display: none; }
  .btn-nosso-gps { padding: 6px 8px; }
  .role-badge { display: none; }
  /* Pill — só avatar em mobile */
  .topbar-user-pill { padding: 3px; border-radius: var(--r); border-color: transparent; gap: 0; }
  .topbar-user-pill:hover { border-color: var(--cream-border); }
  .topbar-pill-info { display: none; }

  /* Sidebar — drawer com hamburger */
  .sidebar {
    position: fixed;
    top: 52px; left: 0; bottom: 0;
    width: 240px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .btn-hamburger { display: flex !important; }

  /* Mobile: sidebar drawer ignora mini-mode — sempre mostra labels e itens completos */
  .sidebar.mobile-open,
  .sidebar.mobile-open.sidebar-mini { width: 240px; }
  .sidebar.mobile-open .sidebar-section-label,
  .sidebar.mobile-open.sidebar-mini .sidebar-section-label { display: block; }
  .sidebar.mobile-open .sidebar-item,
  .sidebar.mobile-open.sidebar-mini .sidebar-item {
    padding: 10px 14px;
    justify-content: flex-start;
    gap: 10px;
    font-size: var(--font-base);
    border-left-width: 3px;
  }
  .sidebar.mobile-open.sidebar-mini .sidebar-item svg { opacity: 0.7; }
  .sidebar.mobile-open .sidebar-badge,
  .sidebar.mobile-open.sidebar-mini .sidebar-badge { display: flex; }
  .sidebar.mobile-open .sidebar-collapse-btn,
  .sidebar.mobile-open.sidebar-mini .sidebar-collapse-btn { display: none; }

  /* Kanban — scroll horizontal com snap */
  .kanban-board {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    padding-bottom: 8px;
  }
  .kanban-col {
    min-width: calc(100vw - 40px);
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  /* Lista */
  .view-toggle { display: flex; }
  .lista-table th:nth-child(4),
  .lista-table td:nth-child(4),
  .lista-table th:nth-child(5),
  .lista-table td:nth-child(5) { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }

  /* Painel lateral — full screen */
  .panel-drawer { max-width: 100%; width: 100%; border-radius: 0; }

  /* Modais — deslizam de baixo */
  .modal { max-width: 100%; width: 100%; margin: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* KPIs */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 14px; }

  /* Dashboard cliente */
  .cliente-body { padding: 16px 14px 60px; }
  .fases-progresso { gap: 0; }
  .fase-label { font-size: 8px; }
  .cliente-header-card { padding: 16px; }

  /* Inês */
  .ines-header { padding: 14px 16px 12px; }
  .ines-chat-area { padding: 14px 16px; }
  .ines-input-area { padding: 12px 16px; }

  /* O Nosso GPS */
  .nosso-gps-drawer { max-width: 100%; width: 100%; }
  .gps-links-grid { grid-template-columns: repeat(2, 1fr); }

  /* Minha Área */
  .minha-area-drawer { max-width: 100%; width: 100%; }

  /* Processual */
  .proc-table th:nth-child(4),
  .proc-table td:nth-child(4),
  .proc-table th:nth-child(5),
  .proc-table td:nth-child(5) { display: none; }

  /* Rodapé */
  #app-footer { font-size: var(--font-xs); padding: 3px 12px; }
}
