/* =====================================================================
   ÍRIS — layout.css : shell, sidebar, topbar, grades de página
   ===================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ============================ SIDEBAR ============================ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--c-ink) 0%, var(--c-ink-2) 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  color: var(--brand-silver-2);
  z-index: 40;
}
.sidebar::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% -12%, rgba(11, 114, 227, .28), transparent 58%);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  position: relative;
  z-index: 1;
}
/* Marca oficial da Ótica Redentora — mesma composição da loja:
   ícone quadrado arredondado + "Ótica Redentora" com o sobrenome em
   degradê azul. */
.brand__logo {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}
.brand__logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.brand__meta { display: flex; flex-direction: column; justify-content: center; min-width: 0; }

.brand__nome {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.15;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__nome b {
  font-weight: 700;
  background: linear-gradient(135deg, #2F6BFF 0%, #4F8BFF 45%, #38D0E6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 14px;
  position: relative;
  z-index: 1;
}
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); background-clip: content-box; }

.nav__group + .nav__group { margin-top: 11px; }
.nav__group-label {
  font-family: var(--font-cond);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(201, 207, 214,.42);
  padding: 0 10px 4px;
}

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6.5px 10px;
  border-radius: var(--r-sm);
  color: var(--brand-silver);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav__item:hover { background: rgba(255, 255, 255, .06); color: #FFFFFF; text-decoration: none; }
.nav__item .icon { opacity: .8; }

.nav__item.is-active {
  background: linear-gradient(90deg, rgba(20, 162, 168, .22), rgba(20, 162, 168, .04));
  color: #FFFFFF;
  font-weight: 500;
}
.nav__item.is-active .icon { opacity: 1; color: var(--c-accent-2); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--c-accent-2);
}

.nav__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav__count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, .09);
  color: var(--brand-silver-2);
}
.nav__soon {
  font-family: var(--font-cond);
  font-size: 8.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: var(--r-xs);
  border: 1px dashed rgba(255, 255, 255, .2);
  color: rgba(201, 207, 214,.5);
}

.sidebar__foot {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 12px 14px;
  position: relative;
  z-index: 1;
}
.sidebar__user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: linear-gradient(140deg, var(--c-accent-2), var(--c-accent-3));
  color: #fff;
  font-family: var(--font-cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
}
.sidebar__user-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar__user-info strong { font-size: 12.5px; color: #FFFFFF; font-weight: 500; }
.sidebar__user-info em { font-style: normal; font-size: 10.5px; color: rgba(201, 207, 214,.5); }
.sidebar__version {
  display: block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(201, 207, 214,.38);
}

/* ============================= TOPBAR ============================= */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 22px;
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-line);
}

.topbar__burger { display: none; }

.topbar__title { min-width: 0; flex: none; max-width: 34%; }
.topbar__title h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__title p {
  font-size: 11.5px;
  color: var(--c-text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.global-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}
.global-search__icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-3);
  pointer-events: none;
}
.global-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.global-search input::placeholder { color: var(--c-text-3); }
.global-search input:focus {
  outline: none;
  background: var(--c-surface);
  border-color: var(--c-accent);
  box-shadow: var(--ring);
}
.global-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.global-search__results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  padding: 6px;
  z-index: 50;
}
.gs__group + .gs__group { margin-top: 4px; border-top: 1px solid var(--c-line-soft); padding-top: 4px; }
.gs__group-label { padding: 6px 10px 4px; }
.gs__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  text-align: left;
}
.gs__item:hover, .gs__item:focus-visible { background: var(--c-surface-3); text-decoration: none; }
.gs__item strong { font-weight: 500; font-size: 13px; }
.gs__item span { margin-left: auto; }
.gs__empty { padding: 14px; text-align: center; color: var(--c-text-3); font-size: 12.5px; }

.topbar__actions { display: flex; align-items: center; gap: 6px; flex: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--c-surface-3); color: var(--c-text); border-color: var(--c-line); }

#btn-theme .icon-moon { display: none; }
[data-theme="dark"] #btn-theme .icon-sun { display: none; }
[data-theme="dark"] #btn-theme .icon-moon { display: block; }

/* ============================ CONTEÚDO ============================ */
.content {
  flex: 1;
  padding: 22px;
  min-width: 0;
  animation: view-in 260ms cubic-bezier(.16, .8, .3, 1);
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head__text h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.page-head__text p { color: var(--c-text-2); font-size: 13px; margin-top: 2px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* grades */
.grid { display: grid; gap: var(--gap); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }

/* 6 indicadores: 6 em linha só em telas largas; 3×2 no notebook (evita o órfão) */
.grid--kpi6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1560px) { .grid--kpi6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid--kpi6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid--kpi6 { grid-template-columns: 1fr; } }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid--dash { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: var(--gap); }

/* ========================= RESPONSIVIDADE ========================= */
@media (max-width: 1180px) {
  .grid--dash { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform var(--t-med);
    box-shadow: var(--sh-4);
  }
  .app.nav-open .sidebar { transform: none; }
  .topbar__burger { display: grid; }
  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(6, 12, 18, .5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 35;
    animation: fade-in var(--t-med);
  }
  .topbar__title { max-width: none; flex: 1; }
  .global-search { max-width: 260px; }
}

@media (max-width: 720px) {
  :root { --topbar-h: 56px; --gap: 14px; }
  .content { padding: 15px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar__title p { display: none; }
  .global-search { max-width: 40px; transition: max-width var(--t-med); }
  .global-search:focus-within {
    position: absolute;
    left: 12px; right: 12px;
    top: 10px;
    max-width: none;
    z-index: 60;
  }
  .global-search input { background: var(--c-surface); }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
