/* =====================================================
   PocketPaw Dashboard - Modern Apple Design
   Glassmorphism. SF Pro. Refined.

   Changes (2026-02-02):
   - Fixed chat scroll: Added min-height: 0 and overflow: hidden
     to .chat-container and .messages for proper flex scrolling
   ===================================================== */

:root {
  /* Apple-inspired Dark Palette */
  --bg-color: #000000;
  --glass-bg: rgba(28, 28, 30, 0.65);
  --glass-border: rgba(255, 255, 255, 0.12);
  --card-bg: rgba(44, 44, 46, 0.6);
  
  /* Text */
  --text-primary: #FFFFFF;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.3);

  /* Accents */
  --accent-color: #0A84FF; /* iOS Blue */
  --accent-hover: #0077ED;
  --success-color: #30D158;
  --danger-color: #FF453A;
  --warning-color: #FF9F0A;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Spacing & Radius */
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at 50% 0%, #1a1a1a 0%, #000000 70%); /* Subtle depth */
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   Sidebar (Glass)
   ===================================================== */
.sidebar {
  width: 280px;
  background-color: var(--glass-bg);
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  gap: 32px;
  z-index: 10;
}

.logo {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  padding-left: 8px;
}

.logo span { font-size: 24px; filter: drop-shadow(0 0 10px rgba(10, 132, 255, 0.3)); }

/* Navigation */
.nav-section { display: flex; flex-direction: column; gap: 6px; }

.nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 10px;
  padding-left: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.08); }
.nav-item:active { transform: scale(0.98); background: rgba(255, 255, 255, 0.12); }
.nav-item.danger { color: var(--danger-color); }

/* Status Widget - now using UnoCSS glass-dark shortcut + utilities */
/* Keeping only the custom backdrop-filter since UnoCSS runtime doesn't include it by default */

/* =====================================================
   Main Content
   ===================================================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at 50% 30%, #1c1c1e 0%, #000000 100%);
}

/* Top Bar (Floating Glass) */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  /* Glass header feels */
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, transparent 100%);
}

/* View Toggle (Segmented Control) */
.view-toggle {
  display: flex;
  background: rgba(118, 118, 128, 0.24);
  border-radius: 9px;
  padding: 2px;
}

.view-btn {
  padding: 6px 24px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn.active {
  background: rgba(99, 99, 102, 0.8); /* iOS Segmented Control Active */
  color: white;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 3px 1px rgba(0,0,0,0.04);
}

/* Switch (iOS Style) */
.agent-toggle { display: flex; align-items: center; gap: 12px; }
.agent-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.switch { position: relative; width: 51px; height: 31px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background-color: rgba(120, 120, 128, 0.32);
  border-radius: 31px;
  transition: .3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.slider:before {
  content: "";
  position: absolute;
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 3px 1px rgba(0,0,0,0.06);
  transition: .3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
input:checked + .slider { background-color: var(--success-color); }
input:checked + .slider:before { transform: translateX(20px); }

/* Agent Mode Badge */
.agent-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 8px;
  animation: badgeFadeIn 0.3s ease-out;
}

/* Removed: .agent-mode-badge.two-layer (2-layer mode simplified out) */

@keyframes badgeFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* =====================================================
   Chat View
   ===================================================== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 80px; /* Offset for absolute header */
  overflow: hidden; /* Contain flex children for proper scrolling */
  min-height: 0; /* Allow flex shrinking */
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 0; /* Critical: allows flex child to shrink below content size */
}

.message {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: messageSlide 0.3s ease-out;
}
@keyframes messageSlide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; }

.message-header { display: flex; gap: 8px; align-items: center; margin-top: 6px; padding: 0 4px; opacity: 0.8; }
.message.user .message-header { justify-content: flex-end; flex-direction: row-reverse; } .message.user .message-header .message-author { display: none; } /* Hide 'You' label usually */
.message-author { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.message-time { font-size: 11px; color: var(--text-tertiary); }

.message-content {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.message.user .message-content {
  background: var(--accent-color);
  color: white;
  border-bottom-right-radius: 4px; /* Message tail effect */
}

.message.assistant .message-content {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
}

/* Typing Indicator (iOS iMessage style) */
.typing-indicator { font-weight: bold; animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 0.3; } 50% { opacity: 1; } 100% { opacity: 0.3; } }

/* Code Blocks (Glass Terminal) */
.message-content pre {
  background: rgba(0, 0, 0, 0.5);
  padding: 16px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--glass-border);
  white-space: pre-wrap;
}

.message-content code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Input Area (Floating Island) */
.input-area {
  padding: 24px 32px 32px;
  background: transparent;
}

.input-area input {
  width: 100%;
  padding: 16px 20px;
  padding-right: 60px; /* Space for button */
  border-radius: 24px;
  background: rgba(44, 44, 46, 0.8);
  border: 1px solid var(--glass-border);
  color: white;
  font-size: 15px;
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transition: all 0.2s;
}

.input-area input:focus {
  outline: none;
  background: rgba(54, 54, 56, 0.9);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.input-area { position: relative; } /* To position button inside */
.chat-input { width: 100%; } /* Handled by input-area input above */

.send-btn {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%) scale(1);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-color);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}
.send-btn:hover { background: var(--accent-hover); transform: translateY(-50%) scale(1.08); }
.send-btn:active { transform: translateY(-50%) scale(0.95); }
.send-btn:disabled { background: #444; cursor: default; box-shadow: none; }

/* =====================================================
   Terminal View
   ===================================================== */
.terminal-container {
  flex: 1;
  padding: 100px 32px 32px;
  background: #000;
  font-family: var(--font-mono);
}
.terminal-output { font-size: 13px; color: #BBB; line-height: 1.5; }
.term-line { margin-bottom: 4px; }
.term-time { color: #555; margin-right: 12px; font-size: 11px; }

/* =====================================================
   Modals
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.modal {
  position: relative;
  width: 500px;
  max-width: 90vw;
  background: rgba(30, 30, 32, 0.85);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: modalPop 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--glass-border); }
.modal-header h2 { font-size: 17px; font-weight: 600; }
.close-btn { font-size: 28px; color: var(--text-secondary); transition: color 0.2s; }
.close-btn:hover { color: white; }

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

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s;
}

.close-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* Lucide icons base styling */
[data-lucide] {
  stroke-width: 2;
}

.modal-body { padding: 24px; }

.modal-body hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 20px 0;
}

.modal-body h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

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

.form-group select,
.form-group input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: white;
  font-size: 14px;
  width: 100%;
  transition: all 0.2s;
}

.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0,0,0,0.4);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
}

.btn-sm {
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-sm:active {
  transform: scale(0.97);
}

/* File Browser Modal */
.modal-lg {
  width: 600px;
  max-height: 80vh;
}

/* Hybrid: Keep component-specific styles, layout via UnoCSS */
.file-path {
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  overflow-x: auto;
}

.file-path-home {
  color: var(--accent-color);
  cursor: pointer;
}

.file-path-home:hover {
  text-decoration: underline;
}

.file-list {
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}

/* file-item: structure via UnoCSS (flex items-center gap-3), skin here */
.file-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.15s;
}

.file-item:last-child {
  border-bottom: none;
}

.file-item:hover {
  background: rgba(255,255,255,0.05);
}

.file-item:active {
  background: rgba(255,255,255,0.08);
}

/* Screenshot Preview */
.screenshot-preview {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* =====================================================
   Toast Notifications
   ===================================================== */
.toast-container {
  position: fixed;
  top: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
}

.toast {
  background: rgba(35, 35, 35, 0.85);
  border: 1px solid var(--glass-border);
  border-radius: 14px; /* iOS notification style */
  padding: 14px 18px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  font-size: 14px;
  font-weight: 500;
}
.toast.success { border-left: none; color: var(--success-color); } /* Icon handles color */
.toast.error { border-left: none; color: var(--danger-color); }
.toast.info { border-left: none; color: var(--text-primary); }

.toast-icon { margin-right: 12px; font-size: 16px; }

/* =====================================================
   Reminders
   ===================================================== */
.reminder-input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: white;
  font-size: 14px;
  transition: all 0.2s;
}

.reminder-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0,0,0,0.4);
}

.reminder-list {
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}

.reminder-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.15s;
}

.reminder-item:last-child {
  border-bottom: none;
}

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

.icon-btn-sm {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn-sm:hover {
  background: rgba(255,255,255,0.08);
  color: var(--danger-color);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,0.25); }

/* =====================================================
   Intentions
   ===================================================== */
.intention-input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: white;
  font-size: 14px;
  transition: all 0.2s;
  width: 100%;
}

.intention-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0,0,0,0.4);
}

textarea.intention-input {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.intention-list {
  display: flex;
  flex-direction: column;
  max-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}

.intention-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  transition: all 0.2s;
}

.intention-item:last-child {
  border-bottom: none;
}

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

.intention-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.intention-toggle:hover {
  transform: scale(1.1);
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: #444;
  cursor: not-allowed;
  opacity: 0.6;
}

/* =====================================================
   Skills
   ===================================================== */
.skill-list {
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}

.skill-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.15s;
}

.skill-item:last-child {
  border-bottom: none;
}

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

.skill-item code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Utilities */
[x-cloak] { display: none !important; }
