/* App shell: topbar + sidebar + scrolling content pane. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    'topbar topbar'
    'sidebar content';
  height: 100vh;
  height: 100dvh;
}

/* --- Topbar --- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: calc(var(--sidebar-w) - var(--sp-4) * 2);
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

/* Search */
.search {
  position: relative;
  flex: 1;
  max-width: 620px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  font-size: 13px;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 38px 0 38px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.search input::placeholder {
  color: var(--text-dim);
}

.search input:focus {
  background: var(--surface-3);
  border-color: var(--accent-border);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.search-clear:hover {
  background: var(--surface-1);
  color: var(--text);
}

.search.has-value .search-clear {
  display: grid;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 6px 6px 12px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.user-chip:hover {
  background: var(--surface-2);
  color: var(--text);
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

/* --- Sidebar --- */
.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.storage-card {
  margin-top: auto;
  padding: var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-lg);
}

.storage-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: var(--sp-2);
}

.storage-bar {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: var(--sp-2);
}

.storage-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), #7c5cff);
  transition: width 0.4s var(--ease);
}

.storage-value {
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Content --- */
.content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.content-header {
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  overflow: hidden;
}

.crumb {
  padding: 3px 8px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.crumb:hover {
  background: var(--surface-2);
  color: var(--text);
}

.crumb.current {
  color: var(--text);
  pointer-events: none;
}

.crumb-sep {
  color: var(--text-dim);
  font-size: 13px;
  flex-shrink: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  flex-wrap: wrap;
}

.filter-chips {
  display: flex;
  gap: var(--sp-2);
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.file-pane {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5) var(--sp-7);
  position: relative;
}

.section-label {
  margin: var(--sp-4) 0 var(--sp-3);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-label:first-child {
  margin-top: 0;
}

/* --- Responsive --- */
.sidebar-backdrop {
  display: none;
}

.menu-toggle {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      'topbar'
      'content';
  }

  .menu-toggle {
    display: grid;
  }

  .brand {
    min-width: 0;
  }

  .brand-text {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: var(--z-modal);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
  }

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

  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) - 1);
  }

  .content-header {
    padding: var(--sp-3) var(--sp-4);
  }

  .file-pane {
    padding: var(--sp-3) var(--sp-4) var(--sp-7);
  }

  .breadcrumb {
    font-size: 17px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: var(--sp-2);
    padding: 0 var(--sp-3);
  }

  .search input {
    height: 36px;
  }
}
