/* ==========================================================================
   MHENT WORKSPACE - 3-COLUMN & DRAWER LAYOUT (V1.0)
   ========================================================================== */

#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

/* ==========================================
   1. NAVIGATION RAIL (LEFT - 68px)
   ========================================== */
#nav-rail {
  width: 68px;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  z-index: 100;
  flex-shrink: 0;
}

.rail-top, .rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.rail-brand {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
  transition: var(--transition-bounce);
  margin-bottom: 6px;
}
.rail-brand:hover {
  transform: scale(1.08) rotate(4deg);
}

.rail-divider {
  width: 32px;
  height: 1px;
  background: var(--border-medium);
  margin: 4px 0;
}

.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}
.rail-btn svg {
  width: 22px;
  height: 22px;
  transition: transform var(--transition-fast);
}
.rail-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-high);
}
.rail-btn:hover svg {
  transform: scale(1.1);
}
.rail-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}
.rail-btn.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 10px var(--primary);
}

/* Sub-App Active Colors */
.rail-btn[data-app="chat"].active { color: var(--app-chat); background: rgba(6, 182, 212, 0.15); }
.rail-btn[data-app="chat"].active::before { background: var(--app-chat); box-shadow: 0 0 10px var(--app-chat); }

.rail-btn[data-app="mail"].active { color: var(--app-mail); background: rgba(244, 63, 94, 0.15); }
.rail-btn[data-app="mail"].active::before { background: var(--app-mail); box-shadow: 0 0 10px var(--app-mail); }

.rail-btn[data-app="meet"].active { color: var(--app-meet); background: rgba(139, 92, 246, 0.15); }
.rail-btn[data-app="meet"].active::before { background: var(--app-meet); box-shadow: 0 0 10px var(--app-meet); }

.rail-btn[data-app="todo"].active { color: var(--app-todo); background: rgba(245, 158, 11, 0.15); }
.rail-btn[data-app="todo"].active::before { background: var(--app-todo); box-shadow: 0 0 10px var(--app-todo); }

.rail-btn[data-app="drive"].active { color: var(--app-drive); background: rgba(16, 185, 129, 0.15); }
.rail-btn[data-app="drive"].active::before { background: var(--app-drive); box-shadow: 0 0 10px var(--app-drive); }

.rail-btn[data-app="calendar"].active { color: var(--app-calendar); background: rgba(14, 165, 233, 0.15); }
.rail-btn[data-app="calendar"].active::before { background: var(--app-calendar); box-shadow: 0 0 10px var(--app-calendar); }

.rail-btn[data-app="tools"].active { color: var(--app-tools); background: rgba(236, 72, 153, 0.15); }
.rail-btn[data-app="tools"].active::before { background: var(--app-tools); box-shadow: 0 0 10px var(--app-tools); }

.rail-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--app-mail);
  color: white;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
}

.rail-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: white;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: var(--transition-fast);
}
.rail-avatar:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}
.rail-avatar-status {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--status-online);
  border: 2px solid var(--bg-surface);
}

/* ==========================================
   2. CONTEXT SIDEBAR (MIDDLE - 260px)
   ========================================== */
#context-sidebar {
  width: 260px;
  height: 100%;
  background: var(--bg-surface-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 90;
  transition: width var(--transition-normal);
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.workspace-badge:hover {
  background: var(--bg-surface-hover);
}
.workspace-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-high);
}
.workspace-code {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sidebar-section-title .add-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}
.sidebar-section-title .add-btn:hover {
  color: var(--text-high);
  background: var(--bg-surface-hover);
}

.sidebar-nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  list-style: none;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-medium);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.sidebar-nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-high);
}
.sidebar-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}
.sidebar-nav-item .item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-nav-item .item-icon {
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
}
.sidebar-nav-item .item-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-muted);
}
.sidebar-nav-item.active .item-badge {
  background: var(--primary);
  color: white;
}

/* ==========================================
   3. MAIN WORKSPACE STAGE (FLEX-1)
   ========================================== */
#main-stage {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.stage-topbar {
  height: 56px;
  padding: 0 20px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stage-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-high);
}
.stage-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-search-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.quick-search-btn:hover {
  border-color: var(--border-medium);
  color: var(--text-high);
}
.quick-search-btn kbd {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.aisa-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(244, 114, 182, 0.4);
  color: #f472b6;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition-normal);
}
.aisa-toggle-btn:hover {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.35), rgba(168, 85, 247, 0.35));
  box-shadow: 0 0 16px rgba(244, 114, 182, 0.4);
  transform: translateY(-1px);
}
.aisa-toggle-btn.active {
  background: linear-gradient(135deg, #ec4899, #a855f7);
  color: white;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.5);
}

#app-content-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

/* ==========================================
   4. AISA COPILOT DRAWER (RIGHT - 340px)
   ========================================== */
#aisa-drawer {
  width: 340px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 95;
  transition: margin-right var(--transition-smooth);
  margin-right: 0;
  flex-shrink: 0;
}

#aisa-drawer.collapsed {
  margin-right: -340px;
}

.aisa-drawer-header {
  padding: 14px 18px;
  background: var(--bg-glass-strong);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aisa-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.aisa-logo-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f472b6, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}
.aisa-title-text {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-high);
}
.aisa-subtitle-text {
  font-size: 11px;
  color: var(--text-muted);
}

.persona-switch {
  display: flex;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  margin: 10px 14px;
}
.persona-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: var(--transition-fast);
}
.persona-btn.active.harmony {
  background: var(--aisa-harmony);
  color: #000;
  font-weight: 800;
}
.persona-btn.active.echo {
  background: var(--aisa-echo);
  color: white;
  font-weight: 800;
}
.persona-btn.active.both {
  background: linear-gradient(135deg, #f472b6, #a855f7);
  color: white;
  font-weight: 800;
}

.aisa-messages-box {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aisa-quick-chips {
  padding: 6px 14px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.quick-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-fast);
}
.quick-chip:hover {
  border-color: var(--aisa-harmony);
  color: var(--text-high);
}

.aisa-input-wrapper {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}
.aisa-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  transition: var(--transition-fast);
}
.aisa-input-box:focus-within {
  border-color: var(--aisa-harmony);
  box-shadow: 0 0 10px rgba(244, 114, 182, 0.25);
}
.aisa-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-high);
}
.aisa-send-btn {
  background: linear-gradient(135deg, #f472b6, #a855f7);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}
.aisa-send-btn:hover {
  transform: scale(1.06);
}

/* ==========================================
   5. RESPONSIVE / MOBILE
   ========================================== */
#mobile-nav-bar {
  display: none;
}

@media (max-width: 900px) {
  #aisa-drawer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  }
}

@media (max-width: 768px) {
  #nav-rail {
    display: none;
  }
  #context-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 56px;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  #context-sidebar.open {
    transform: translateX(0);
  }
  #mobile-nav-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    z-index: 200;
    align-items: center;
    justify-content: space-around;
  }
  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
  }
  .mobile-nav-btn.active {
    color: var(--primary);
  }
}
