/* ============================================================
   Koro Design System — Layout (Sidebar + Shell)
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width, 240px) 1fr;
  min-height: 100vh;
  background: var(--muted);
}

/* Sidebar ----------------------------------------------------- */
.sidebar {
  background: var(--background);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--foreground);
  min-height: 64px;
}
.sidebar-brand:hover { color: var(--foreground); text-decoration: none; }
.sidebar-brand img { max-height: 32px; max-width: 120px; object-fit: contain; }
.sidebar-brand-name { font-size: 0.95rem; font-weight: 500; line-height: 1.2; }

.sidebar-nav {
  flex: 1 1 auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-nav-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius);
  color: var(--foreground);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 400;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-nav-link:hover {
  background: var(--muted);
  color: var(--foreground);
  text-decoration: none;
}
.sidebar-nav-link.active {
  background: var(--foreground);
  color: var(--background);
}
.sidebar-nav-link.active:hover {
  background: var(--foreground);
  color: var(--background);
}
.sidebar-nav-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: var(--space-3);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
}
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--foreground);
  color: var(--background);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}
.sidebar-user-info { flex: 1 1 auto; min-width: 0; }
.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-meta {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main -------------------------------------------------------- */
.app-main {
  min-width: 0;
  background: var(--background);
  display: flex;
  flex-direction: column;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
}
.app-topbar-title { font-size: var(--text-base); font-weight: 500; margin: 0; }
.app-topbar-actions { display: flex; gap: var(--space-2); align-items: center; }

.app-content {
  padding: var(--space-6);
  flex: 1 1 auto;
}
.app-content-narrow { max-width: 1100px; margin: 0 auto; width: 100%; }
.app-content-wide   { max-width: 1440px; margin: 0 auto; width: 100%; }

/* Breadcrumb (no topbar) ------------------------------------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  list-style: none;
  padding: 0;
  margin: 0;
}
.breadcrumbs li + li::before {
  content: "/";
  margin: 0 var(--space-2);
  color: var(--border-strong);
}
.breadcrumbs a { color: var(--muted-foreground); text-decoration: none; }
.breadcrumbs a:hover { color: var(--foreground); }
.breadcrumbs li:last-child { color: var(--foreground); }

/* Mobile ------------------------------------------------------ */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: 2px 0 10px rgba(0,0,0,0.08);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 15;
    display: none;
  }
  .sidebar-backdrop.is-visible { display: block; }
  .app-topbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
  }
}
@media (min-width: 769px) {
  .app-topbar-toggle { display: none; }
  .sidebar-backdrop { display: none !important; }
}

/* Auth layout (sem sidebar) ----------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--background);
}
@media (min-width: 900px) {
  .auth-shell.has-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}
.auth-brand { margin-bottom: var(--space-8); display: flex; align-items: center; gap: var(--space-3); }
.auth-brand img { max-height: 40px; }
.auth-title { font-size: 1.75rem; font-weight: 300; letter-spacing: -0.02em; margin-bottom: var(--space-2); }
.auth-subtitle { color: var(--muted-foreground); font-size: var(--text-sm); margin-bottom: var(--space-8); }
.auth-background {
  display: none;
  background: var(--muted) center / cover no-repeat;
  border-left: 1px solid var(--border);
}
@media (min-width: 900px) {
  .auth-shell.has-split .auth-background { display: block; }
}
