* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0a0f;
  --bg-secondary: #12121a;
  --surface: #1a1a24;
  --surface-hover: #22222e;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --primary: #fbbf24;
  --primary-dim: #92711d;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

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

.app {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Avatar */
.avatar-section {
  text-align: center;
  padding: 20px 0;
}

.avatar {
  width: 100px;
  height: 100px;
  margin: 0 auto 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-icon {
  font-size: 48px;
  z-index: 2;
  position: relative;
}

.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--border);
  transition: all 0.3s ease;
}

.avatar-pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

/* Avatar States */
.avatar.idle .avatar-ring {
  border-color: var(--text-muted);
}

.avatar.working .avatar-ring {
  border-color: var(--success);
  box-shadow: 0 0 20px var(--success), inset 0 0 20px rgba(34, 197, 94, 0.1);
}

.avatar.working .avatar-pulse {
  border-color: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.avatar.problem .avatar-ring {
  border-color: var(--danger);
  box-shadow: 0 0 20px var(--danger), inset 0 0 20px rgba(239, 68, 68, 0.1);
  animation: shake 0.5s ease-in-out;
}

.avatar.problem .avatar-pulse {
  border-color: var(--danger);
  animation: pulse-danger 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0; }
}

@keyframes pulse-danger {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.avatar-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
}

.status-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.status-text.working { color: var(--success); }
.status-text.problem { color: var(--danger); }

.current-task {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* Stats */
.stats {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Integration Status */
.integration-status {
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
}

.integration {
  display: flex;
  align-items: center;
  gap: 8px;
}

.integration-icon { font-size: 1.2rem; }
.integration-label { flex: 1; font-size: 0.9rem; }
.integration-state { font-size: 0.6rem; }
.integration-state.connected { color: var(--success); }
.integration-state.disconnected { color: var(--danger); }

/* Main Content */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat Section */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.welcome-avatar {
  font-size: 48px;
  margin-bottom: 16px;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.chat-message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.message-avatar.chief {
  background: linear-gradient(135deg, var(--primary-dim), var(--primary));
}

.message-content {
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 16px;
  border-top-left-radius: 4px;
}

.chat-message.user .message-content {
  background: var(--primary);
  color: #000;
  border-radius: 16px;
  border-top-right-radius: 4px;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.chat-message.user .message-time {
  color: rgba(0,0,0,0.5);
  text-align: right;
}

.chat-input-area {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

#chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 20px;
  color: var(--text);
  font-size: 1rem;
}

#chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Tasks Section */
.tasks-section {
  padding: 24px;
  max-height: 300px;
  overflow-y: auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  border-left: 3px solid var(--border);
}

.task-item.priority-high { border-left-color: var(--warning); }
.task-item.priority-urgent { border-left-color: var(--danger); }
.task-item.completed { opacity: 0.5; }

.task-content { flex: 1; }
.task-title { font-weight: 500; }
.task-meta { font-size: 0.8rem; color: var(--text-muted); }

.task-actions {
  display: flex;
  gap: 4px;
}

.task-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0.5;
  transition: all 0.2s;
}

.task-actions button:hover {
  opacity: 1;
  background: var(--surface-hover);
}

/* Right Panel */
.right-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.activity-section, .calendar-section {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.activity-section h3, .calendar-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.activity-log, .calendar-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  padding: 8px;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.85rem;
}

.activity-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.calendar-event {
  padding: 10px;
  background: var(--surface);
  border-radius: 6px;
}

.calendar-event-title { font-weight: 500; font-size: 0.9rem; }
.calendar-event-time { font-size: 0.8rem; color: var(--text-muted); }

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

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

.btn-primary:hover { background: #fcd34d; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover { background: var(--surface-hover); }

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  padding: 24px;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
}

.modal-content h3 {
  margin-bottom: 16px;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
  width: 100%;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 1rem;
}

.modal-content textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * { flex: 1; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Utilities */
.empty-state {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.hidden { display: none !important; }

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

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
