/* CSS variables for consistent premium coloring */
:root {
  --bg-app: #0b0f19;
  --bg-sidebar: #0f172a;
  --bg-panel: rgba(15, 23, 42, 0.6);
  --border-panel: rgba(255, 255, 255, 0.08);
  
  --accent-primary: #8b5cf6; /* neon-purple */
  --accent-primary-hover: #7c3aed;
  --accent-success: #10b981; /* neon-emerald */
  --accent-success-hover: #059669;
  --accent-danger: #ef4444; /* vivid-red */
  --accent-danger-hover: #dc2626;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

/* Global Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

/* App Container Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling */
.sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-panel);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-panel);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo i {
  color: var(--accent-primary);
  width: 28px;
  height: 28px;
}

.logo span {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.project-list {
  list-style: none;
}

.project-item {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-item i {
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.project-item .project-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.project-item .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.project-item .path {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  margin-top: 2px;
}

.project-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.project-item.active {
  background-color: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.2);
}

.project-item.active i {
  color: var(--accent-primary);
}

.project-item.active .name {
  color: #fff;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-panel);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-success);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Workspace Panels */
.workspace {
  flex: 1;
  background-color: var(--bg-app);
  padding: 40px;
  overflow-y: auto;
  position: relative;
}

.welcome-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-content i {
  width: 80px;
  height: 80px;
  color: var(--accent-primary);
  margin-bottom: 24px;
  opacity: 0.8;
}

.welcome-content h1 {
  font-size: 32px;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.welcome-content p {
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  font-size: 15px;
}

/* Project View Layout */
.project-view {
  display: flex;
  flex-direction: column;
  gap: 32px;
  height: 100%;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-panel);
  padding-bottom: 24px;
}

#view-project-name {
  font-size: 28px;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.project-path {
  font-size: 13px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Context Banner Card */
.context-banner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-premium);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon i {
  color: var(--accent-primary);
  width: 24px;
  height: 24px;
}

.card-body .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-weight: 500;
}

.card-body h3 {
  font-size: 18px;
  margin-top: 4px;
  color: #fff;
}

.card-body .updated-time {
  font-size: 12px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

/* Workspace Grid Layout */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 32px;
  flex: 1;
  min-height: 400px;
  overflow: hidden;
}

/* Panel Design */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-premium);
  overflow: hidden;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.panel-header h2 i {
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Tab Headers */
.tab-header {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-panel);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background-color: var(--accent-primary);
  color: #fff;
}

/* Memories Panel Content */
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.memory-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: var(--transition-smooth);
}

.memory-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.memory-details {
  flex: 1;
  overflow-x: auto;
}

.memory-details .key {
  font-family: monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
  margin-bottom: 8px;
  display: block;
}

.memory-details .value {
  font-size: 14px;
  color: var(--text-main);
  white-space: pre-wrap;
}

.memory-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: var(--transition-smooth);
}

.memory-item:hover .memory-actions {
  opacity: 1;
}

/* Logs Container */
.logs-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.log-entry {
  display: flex;
  gap: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
  flex-shrink: 0;
}

.log-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  height: fit-content;
  flex-shrink: 0;
  margin-top: 2px;
}

.badge-user {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.badge-assistant {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.15);
}

.badge-system {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.log-message {
  color: var(--text-main);
  flex-grow: 1;
  word-break: break-word;
}

/* Session History Panel Content */
.sessions-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(139, 92, 246, 0.2);
}

.session-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-meta .title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.session-meta .date {
  font-size: 11px;
  color: var(--text-dim);
}

.session-status {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-status.active {
  color: var(--accent-success);
}

.session-status.archived {
  color: var(--text-dim);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-family: inherit;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-panel);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-smooth);
  color: var(--text-muted);
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.btn-icon.danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--accent-danger);
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.help-text {
  font-size: 11px;
  color: var(--text-dim);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: var(--transition-smooth);
}

.modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-panel);
  width: 90%;
  max-width: 520px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg {
  max-width: 800px;
}

@keyframes modalIn {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 18px;
  color: #fff;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

form {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border-panel);
  padding-top: 16px;
  margin-top: 16px;
}

/* History view modal messages layout */
.history-messages-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Helper Utilities */
.hidden {
  display: none !important;
}

.loading, .empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 32px 0;
  width: 100%;
}
