/* =========================================================
   ZELO / SouZelo — layout.css
   Estrutura global de topbar e distribuição macro
========================================================= */

/*
  --topbar-h: altura real do topbar.
  Usada para posicionar sidebar e app-shell.
  Ajuste aqui se o topbar mudar de tamanho.
*/
:root{
  --topbar-h: 57px;
}

.gi-topbar{
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(2,6,23,0.06);
  padding: 10px 12px;
}

.gi-topbar-main{
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.gi-topbar-title{
  font-weight: 800;
  letter-spacing: -0.2px;
  font-size: 20px;
  line-height: 1.25;
}

.gi-topbar-actions{
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

.gi-topbar-btn{
  min-height: 44px;
  font-size: 16px;
  max-width: 100%;
}

.gi-notif-btn{ position: relative; }

.gi-notif-badge,
.gi-badge.gi-notif-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.gi-topbar-title{
  font-weight: 800;
  letter-spacing: -0.2px;
  font-size: 20px;
  line-height: 1.25;
}

.gi-topbar-title-text{
  min-width: 0;
}

@media (min-width: 992px){
  .gi-topbar-main{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    width:100%;
  }

  .gi-topbar-title{
    display:flex;
    align-items:center;
    justify-content:flex-start;
    gap:12px;
    min-width:0;
    flex:1 1 auto;
  }

  .gi-topbar-title-text{
    display:flex;
    align-items:center;
    gap:6px;
    min-width:0;
    text-align:left;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .gi-topbar-actions{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:10px;
    margin-left:auto;
    flex:0 0 auto;
  }

  .gi-topbar-menu-mobile{
    display:none !important;
  }
}

@media (max-width: 768px){
  .gi-topbar-title{
    display:grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items:center;
    gap:10px;
  }

  .gi-topbar-title::after{
    content:"";
    display:block;
    width:44px;
    height:44px;
  }

  .gi-topbar-menu-mobile{
    width:44px;
    min-width:44px;
    height:44px;
    padding:0;
    justify-self:start;
  }

  .gi-topbar-title-text{
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    min-width:0;
    font-weight:800;
    line-height:1.2;
  }
}

@media (max-width: 768px){
  .gi-topbar-actions{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .gi-topbar-actions .gi-user-menu{
    grid-column: 1 / -1;
  }

  .gi-topbar-actions .gi-user-menu > summary{
    width: 100%;
    justify-content: center;
  }

  .gi-topbar-actions > .gi-btn,
  .gi-topbar-actions > a.gi-btn{
    width: 100%;
  }

  .gi-user-dropdown{
    left: 0;
    right: 0;
    min-width: 0;
    max-width: none;
  }
}

@media (min-width: 900px){
  .gi-topbar{
    padding: 10px 16px;
  }

  .gi-topbar-main{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
  }

  .gi-topbar-title{
    font-size: 18px;
  }

  .gi-topbar-actions{
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
  }
}

.gi-topbar-menu-mobile{
  display:none;
}

.gi-app-shell{
  display:flex;
  align-items:stretch;
  height:calc(100dvh - var(--topbar-h));
  height:calc(100svh - var(--topbar-h));
  height:calc(100vh  - var(--topbar-h));
  overflow:hidden;
}

.gi-sidebar-backdrop{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(15, 23, 42, .42);
  z-index:79;
}

.gi-sidebar{
  width:286px;
  min-width:286px;
  max-width:286px;
  background:linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-right:1px solid rgba(15, 23, 42, .08);
  padding:14px;
  transition:transform .22s ease, width .22s ease, min-width .22s ease, max-width .22s ease;
  z-index:80;
  overflow-y:auto;
  overflow-x:hidden;
  scrollbar-width:thin;
  scrollbar-color:rgba(15,23,42,.15) transparent;
}

.gi-sidebar::-webkit-scrollbar{ width:4px; }
.gi-sidebar::-webkit-scrollbar-track{ background:transparent; }
.gi-sidebar::-webkit-scrollbar-thumb{ background:rgba(15,23,42,.15); border-radius:4px; }

.gi-sidebar-inner{
  position:static;
}

.gi-sidebar-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:14px;
  padding:10px 10px 12px;
  border-radius:16px;
  background:rgba(37, 99, 235, .05);
  border:1px solid rgba(37, 99, 235, .10);
}

.gi-sidebar-brand{
  display:block;
  text-decoration:none;
  color:inherit;
  min-width:0;
}

.gi-sidebar-brand strong{
  display:block;
  font-size:15px;
  line-height:1.2;
  color:#0f172a;
}

.gi-sidebar-brand span{
  display:block;
  font-size:12px;
  opacity:.72;
  margin-top:3px;
  color:#475569;
}

.gi-sidebar-toggle{
  width:40px;
  height:40px;
  min-width:40px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  border:1px solid rgba(15, 23, 42, .10);
  background:#fff;
  color:#0f172a;
  cursor:pointer;
  transition:background .18s ease, border-color .18s ease, transform .18s ease;
}

.gi-sidebar-toggle:hover{
  background:rgba(15, 23, 42, .04);
  border-color:rgba(15, 23, 42, .16);
  transform:translateY(-1px);
}

.gi-sidebar-toggle svg{
  width:18px;
  height:18px;
  display:block;
}

.gi-sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.gi-sidebar-link{
  display:flex;
  align-items:center;
  gap:12px;
  min-height:46px;
  padding:11px 12px;
  border-radius:14px;
  text-decoration:none;
  color:#0f172a;
  background:transparent;
  border:1px solid transparent;
  transition:background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.gi-sidebar-link:hover{
  background:rgba(15, 23, 42, .04);
  border-color:rgba(15, 23, 42, .06);
  transform:translateX(2px);
}

.gi-sidebar-link.is-active{
  background:rgba(37, 99, 235, .10);
  border-color:rgba(37, 99, 235, .18);
  color:#1d4ed8;
  box-shadow:0 6px 14px rgba(37, 99, 235, .08);
}

.gi-sidebar-icon{
  width:18px;
  height:18px;
  flex:0 0 18px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:currentColor;
  opacity:.82;
}

.gi-sidebar-link.is-active .gi-sidebar-icon{
  opacity:1;
}

.gi-sidebar-icon svg{
  width:18px;
  height:18px;
  display:block;
}

.gi-sidebar-label{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.gi-content-shell{
  flex:1 1 auto;
  min-width:0;
  overflow-y:auto;
  overflow-x:hidden;
}

/* Exceção: páginas com board horizontal precisam de overflow-x: auto */
.page-orcamentos-funil .gi-content-shell{
  overflow-x: auto;
}

body.gi-sidebar-collapsed .gi-sidebar{
  width:88px;
  min-width:88px;
  max-width:88px;
}

body.gi-sidebar-collapsed .gi-sidebar-brand span,
body.gi-sidebar-collapsed .gi-sidebar-label{
  display:none;
}

body.gi-sidebar-collapsed .gi-sidebar-head{
  justify-content:center;
  padding-left:8px;
  padding-right:8px;
}

body.gi-sidebar-collapsed .gi-sidebar-brand{
  display:none;
}

body.gi-sidebar-collapsed .gi-sidebar-link{
  justify-content:center;
  padding-left:10px;
  padding-right:10px;
}

@media (max-width: 980px){
  .gi-topbar-menu-mobile{
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }

  .gi-app-shell{
    display:block;
    height:auto;
    overflow:visible;
  }

  .gi-content-shell{
    overflow-y:visible;
    overflow-x:visible;
  }

  /* Exceção: funil precisa de scroll horizontal */
  .page-orcamentos-funil .gi-content-shell{
    overflow-x: auto;
  }

  .gi-sidebar-backdrop{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(15, 23, 42, .42);
    z-index:119;
  }

  .gi-sidebar-backdrop.is-open{
    display:block;
  }

  .gi-sidebar{
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    width:min(286px, 88vw);
    min-width:min(286px, 88vw);
    max-width:min(286px, 88vw);
    transform:translateX(-100%);
    box-shadow:0 18px 40px rgba(15, 23, 42, .18);
    border-right:none;
    overflow-y:auto;
    overflow-x:hidden;
    z-index:120;
  }

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

  body.gi-sidebar-open{
    overflow:hidden;
  }

  body.gi-sidebar-collapsed .gi-sidebar{
    width:min(286px, 88vw);
    min-width:min(286px, 88vw);
    max-width:min(286px, 88vw);
  }

  body.gi-sidebar-collapsed .gi-sidebar-brand{
    display:block;
  }

  body.gi-sidebar-collapsed .gi-sidebar-brand span,
  body.gi-sidebar-collapsed .gi-sidebar-label{
    display:block;
  }

  body.gi-sidebar-collapsed .gi-sidebar-link{
    justify-content:flex-start;
  }
}


/* =========================================================
   LAYOUTS COMPARTILHADOS (Refatoração 2024)
   Containers e Grids Responsivos Reutilizáveis
========================================================= */

/* ── Container Fluid (Full Width) ── */
.gi-container-fluid{
  max-width: 100% !important;
  width: 100%;
  padding: 24px 30px !important;
}

/* ── Grid 2 Colunas Responsivo ── */
.gi-grid-2{
  display: grid;
  gap: 14px;
}

@media (min-width: 900px){
  .gi-grid-2{
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ── Grid 4 Colunas Responsivo ── */
.gi-grid-4{
  display: grid;
  gap: 14px;
}

@media (min-width: 900px){
  .gi-grid-4{
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 899px){
  .gi-grid-4{
    grid-template-columns: 1fr;
  }
}
