/* sidebar.css — AI-Do v4.0 left sidebar panel */

/* ===== Sidebar Base ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width var(--transition-normal);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: var(--radius-full);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--glass-border-light);
}

/* ===== Sidebar Header ===== */
.sidebar-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-xs);
  gap: var(--space-sm);
  flex-shrink: 0;
  margin-bottom: var(--space-md);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.sidebar-brand-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sidebar-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition-normal);
}

.sidebar-toggle {
  flex-shrink: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-normal);
}

.sidebar-toggle:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

/* ===== Sidebar Content ===== */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ===== Persona Card ===== */
.persona-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-sm);
  position: relative;
  transition:
    background var(--transition-normal),
    border-color var(--transition-normal);
}

.persona-card:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-light);
}

.persona-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glass-border);
  flex-shrink: 0;
  transition: border-color var(--transition-normal);
}

.persona-card-avatar.status-running { border-color: var(--success); }
.persona-card-avatar.status-paused { border-color: var(--warning); }
.persona-card-avatar.status-idle { border-color: var(--info); }
.persona-card-avatar.status-busy { border-color: var(--accent-secondary); }
.persona-card-avatar.status-unknown { border-color: var(--glass-border); }

.persona-card-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.persona-card-greeting {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  line-height: var(--line-height-normal);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.persona-card-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  background: var(--glass-bg-active);
  border: 1px solid var(--glass-border);
}

.persona-card-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.persona-card-status.status-running .status-dot { background: var(--success); }
.persona-card-status.status-paused .status-dot { background: var(--warning); }
.persona-card-status.status-idle .status-dot { background: var(--info); }
.persona-card-status.status-busy .status-dot { background: var(--accent-secondary); }
.persona-card-status.status-unknown .status-dot { background: var(--text-disabled); }

.persona-card-status.status-running { color: var(--success); }
.persona-card-status.status-paused { color: var(--warning); }
.persona-card-status.status-idle { color: var(--info); }
.persona-card-status.status-busy { color: var(--accent-secondary); }
.persona-card-status.status-unknown { color: var(--text-disabled); }

.persona-card-edit {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition:
    opacity var(--transition-fast),
    background var(--transition-fast),
    color var(--transition-fast);
}

.persona-card:hover .persona-card-edit {
  opacity: 1;
}

.persona-card-edit:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.persona-card-edit svg {
  width: 14px;
  height: 14px;
}

/* ===== Sidebar Navigation ===== */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-nav-item:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: var(--glass-bg-active);
  color: var(--accent-primary-light);
  border-left-color: var(--accent-primary);
}

.sidebar-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav-item .nav-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition-normal);
}

/* ===== Recent Files Section ===== */
.sidebar-files {
  border-top: 1px solid var(--glass-border);
  padding-top: var(--space-md);
}

.sidebar-files-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 var(--space-md);
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-files-header svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sidebar-files-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-files-empty {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--text-disabled);
  font-style: italic;
}

.sidebar-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

.sidebar-file-item:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

.sidebar-file-name {
  font-size: var(--font-size-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.sidebar-file-time {
  font-size: 10px;
  color: var(--text-disabled);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== Agent Status Indicator (bottom) ===== */
.sidebar-agent-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--glass-border);
  padding-top: var(--space-md);
}

.sidebar-agent-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: statusBlink 2s ease-in-out infinite;
}

.sidebar-agent-status.status-running .status-dot { background: var(--success); }
.sidebar-agent-status.status-paused .status-dot { background: var(--warning); }
.sidebar-agent-status.status-idle .status-dot { background: var(--info); }
.sidebar-agent-status.status-busy .status-dot { background: var(--accent-secondary); }
.sidebar-agent-status.status-unknown .status-dot { background: var(--text-disabled); }

.sidebar-agent-status .status-text {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition-normal);
}

/* ===== Collapsed State ===== */
#app.sidebar-collapsed .sidebar {
  padding: var(--space-sm);
}

#app.sidebar-collapsed .sidebar-title {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

#app.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

#app.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

#app.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  right: var(--space-xs);
  top: var(--space-sm);
}

#app.sidebar-collapsed .sidebar-toggle svg use {
  href: '/assets/icons.svg#chevron-right';
}

#app.sidebar-collapsed .persona-card {
  padding: var(--space-sm);
}

#app.sidebar-collapsed .persona-card-greeting {
  display: none;
}

#app.sidebar-collapsed .persona-card-name {
  display: none;
}

#app.sidebar-collapsed .persona-card-status {
  display: none;
}

#app.sidebar-collapsed .persona-card-edit {
  display: none;
}

#app.sidebar-collapsed .persona-card-avatar {
  width: 40px;
  height: 40px;
}

#app.sidebar-collapsed .sidebar-nav-item {
  justify-content: center;
  padding: var(--space-sm);
  border-left-width: 0;
}

#app.sidebar-collapsed .sidebar-nav-item.active {
  background: var(--glass-bg-active);
  border-left-width: 0;
  border-bottom: 2px solid var(--accent-primary);
}

#app.sidebar-collapsed .nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  position: absolute;
}

#app.sidebar-collapsed .sidebar-files {
  display: none;
}

#app.sidebar-collapsed .sidebar-agent-status .status-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

#app.sidebar-collapsed .sidebar-agent-status {
  justify-content: center;
}

#app.sidebar-collapsed .sidebar-content {
  padding: 0;
  align-items: center;
}

/* ===== Persona Editor Modal Additions ===== */
.persona-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.persona-editor .field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.persona-editor .field-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.persona-editor .avatar-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.persona-editor .avatar-option {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  background: var(--glass-bg);
}

.persona-editor .avatar-option:hover {
  border-color: var(--glass-border-light);
  transform: scale(1.1);
}

.persona-editor .avatar-option.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.persona-editor .avatar-option.style-default {
  background: var(--accent-gradient);
  color: #fff;
}

.persona-editor .avatar-option.style-robot {
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  color: #fff;
}

.persona-editor .avatar-option.style-cat {
  background: linear-gradient(135deg, #f472b6, #a78bfa);
  color: #fff;
}

.persona-editor .avatar-option.style-abstract {
  background: linear-gradient(135deg, #fbbf24, #f87171);
  color: #fff;
}

.persona-editor .trait-slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.persona-editor .trait-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.persona-editor .trait-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.persona-editor .trait-value {
  font-size: var(--font-size-xs);
  color: var(--accent-primary-light);
  font-weight: 600;
}

.persona-editor .trait-labels {
  display: flex;
  justify-content: space-between;
}

.persona-editor .trait-label-text {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

.persona-editor .trait-label-text.active {
  color: var(--accent-primary-light);
  font-weight: 600;
}

/* ===== Mobile ===== */
@media (max-width: 1200px) {
  .sidebar.open {
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100% !important;
  }
}
