/*
 * App shell layout — account bar, sidebar, content area.
 * Three-pane on desktop, stacked on mobile.
 */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Account bar — narrow vertical strip on the left */
.account-bar {
  width: var(--account-bar-width);
  min-width: var(--account-bar-width);
  background: var(--bg-account-bar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0.5rem;
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}

.account-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}
.account-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.account-icon.active {
  border-color: var(--accent);
  color: var(--text-primary);
}
.account-initial {
  pointer-events: none;
}

.add-account {
  margin-top: auto;
}
.account-add-icon {
  font-size: var(--text-lg);
  font-weight: var(--weight-normal);
  color: var(--text-tertiary);
}

/* Main area — sidebar + content */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.125rem 1rem 0.75rem;
}
.sidebar-email {
  font-size: 0.8125rem;
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  letter-spacing: 0.01em;
  padding: 0 0.5rem;
  margin-bottom: 0.125rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0 0.5rem;
}

.nav-compose-btn {
  display: block;
  text-align: center;
  padding: 0.5rem 1rem;
  margin: 0 0.5rem 0.75rem;
  background: var(--bg-btn-primary);
  color: var(--text-btn-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: opacity var(--transition-fast);
  text-decoration: none;
}
.nav-compose-btn:hover {
  opacity: 0.9;
  text-decoration: none;
}

.nav-group {
  margin-bottom: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  font-family: var(--font-sans);
  text-align: left;
}
.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--bg-surface-active);
  color: var(--text-primary);
}

.nav-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-icon-sm svg {
  width: 14px;
  height: 14px;
}
.nav-label {
  flex: 1;
}
.nav-badge {
  background: var(--accent);
  color: var(--text-btn-primary);
  font-size: var(--text-xs);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-weight: var(--weight-semibold);
}

.sidebar-footer {
  padding: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}
.nav-logout {
  color: var(--text-tertiary);
}

/* Content area */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-surface);
  padding: 1.5rem;
}

/* Auth layout (login) */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
}
.login-header {
  margin-bottom: 2rem;
  text-align: center;
}
.login-logo {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}
.login-title {
  font-size: var(--text-2xl);
  margin-bottom: 0.25rem;
}
.login-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.login-form {
  display: flex;
  flex-direction: column;
}

.toggle-advanced {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0.25rem 0;
  margin-bottom: 0.75rem;
  text-align: left;
  font-family: var(--font-sans);
}
.toggle-advanced:hover {
  color: var(--text-secondary);
}

.advanced-fields {
  margin-bottom: 0.5rem;
}

/* Folders section */
.folders-toggle {
  position: relative;
}
.folders-chevron {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}
.folders-chevron svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chevron-open {
  transform: rotate(90deg);
}
.nav-badge-muted {
  background: var(--gray-8);
  color: var(--gray-4);
}

.folders-list {
  padding-left: 0.5rem;
}

.folder-item {
  position: relative;
  display: flex;
  align-items: center;
}
.folder-item .nav-item {
  flex: 1;
  min-width: 0;
}
.nav-item-sm {
  padding: 0.25rem 0.75rem;
  font-size: var(--text-xs);
}

.folder-menu-btn {
  position: absolute;
  right: 0.375rem;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
}
.folder-menu-btn svg {
  stroke: currentColor;
  fill: currentColor;
  stroke-width: 0;
}
.folder-item:hover .folder-menu-btn {
  opacity: 1;
}
.folder-menu-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.folder-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  z-index: 20;
  min-width: 100px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.folder-menu-action {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.375rem 0.625rem;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.folder-menu-action:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.folder-menu-danger:hover {
  color: var(--color-error);
}

.folder-create-row {
  padding-left: 0.5rem;
}
.folder-add-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  width: 100%;
  background: none;
  border: none;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-md);
}
.folder-add-btn svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.folder-add-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-surface-hover);
}
.folder-create-form {
  padding: 0.125rem 0.75rem 0.25rem;
}
.folder-create-input {
  font-size: var(--text-xs) !important;
  padding: 0.25rem 0.5rem !important;
}

/* Responsive */
@media (max-width: 768px) {
  .account-bar {
    display: none;
  }
  .sidebar {
    display: none;
  }
  .content {
    padding: 1rem;
  }
}
