/* ============================================
   Brain UI - Mobile-First Styles
   ============================================ */

:root {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-tertiary: #242938;
  --bg-hover: #2a3142;
  --bg-active: #3a4152;
  
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #5f6368;
  
  --accent: #5a7fff;
  --accent-hover: #4a6fef;
  --accent-subtle: rgba(90, 127, 255, 0.15);
  
  --border: #2a2f3e;
  --border-light: #363c4a;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  
  --transition: 0.2s ease;
  --transition-fast: 0.15s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ============================================
   Login Screen
   ============================================ */

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  background: var(--bg-primary);
}

.login-box {
  background: var(--bg-secondary);
  padding: 40px 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
}

.login-box h1 {
  text-align: center;
  font-size: 48px;
  margin-bottom: 8px;
}

.login-box p {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-size: 15px;
}

.login-box input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 16px;
  transition: border-color var(--transition);
}

.login-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-box button {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.login-box button:hover {
  background: var(--accent-hover);
}

/* ============================================
   Header / Breadcrumbs
   ============================================ */

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}

.breadcrumbs::-webkit-scrollbar {
  display: none;
}

.breadcrumb {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 15px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.breadcrumb:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.breadcrumb.current {
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
}

.breadcrumb.current:hover {
  background: none;
}

.breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ============================================
   Search Bar
   ============================================ */

.search-container {
  padding: 12px 16px;
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: all var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 18px;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-hover);
  border: none;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.search-box.has-value .search-clear {
  display: flex;
}

/* ============================================
   Content Area
   ============================================ */

.content-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   Section Headers
   ============================================ */

.section-header {
  padding: 16px 16px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   Item List (Folders & Files)
   ============================================ */

.sort-buttons {
  display: flex;
  gap: 8px;
  padding: 12px 12px 8px;
  margin-bottom: 8px;
}

.sort-btn {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sort-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sort-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.item-list {
  padding: 0 12px 20px;
}

.item {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.item:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.item:active {
  background: var(--bg-active);
  transform: scale(0.98);
}

.item-icon {
  font-size: 24px;
  margin-right: 14px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 13px;
  color: var(--text-tertiary);
}

.item-preview {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.item-chevron {
  color: var(--text-tertiary);
  font-size: 18px;
  margin-left: 8px;
  flex-shrink: 0;
  align-self: center;
}

/* Folder specific */
.item.folder {
  background: var(--bg-secondary);
}

.item.folder .item-icon {
  color: #ffca28;
}

/* File specific */
.item.file .item-icon {
  color: var(--accent);
}

/* ============================================
   Recent Section (Home)
   ============================================ */

.recent-list {
  display: flex;
  gap: 10px;
  padding: 0 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.recent-list::-webkit-scrollbar {
  display: none;
}

.recent-item {
  flex-shrink: 0;
  width: 140px;
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.recent-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.recent-item:active {
  transform: scale(0.96);
}

.recent-item-icon {
  font-size: 20px;
  margin-bottom: 8px;
}

.recent-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.recent-item-path {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   Reader View
   ============================================ */

.reader {
  padding: 20px;
  padding-bottom: 60px;
}

.reader-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
}

.reader-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.copy-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 12px;
}

.copy-button:hover {
  background: var(--accent-hover);
}

.copy-button:active {
  background: var(--accent-hover);
  transform: scale(0.98);
}

.reader-content {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-primary);
}

.reader-content h1 {
  font-size: 26px;
  margin-top: 32px;
  margin-bottom: 16px;
  font-weight: 700;
}

.reader-content h2 {
  font-size: 22px;
  margin-top: 28px;
  margin-bottom: 14px;
  font-weight: 600;
}

.reader-content h3 {
  font-size: 18px;
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
}

.reader-content p {
  margin-bottom: 16px;
}

.reader-content ul,
.reader-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.reader-content li {
  margin-bottom: 8px;
}

.reader-content a {
  color: var(--accent);
  text-decoration: none;
}

.reader-content a:hover {
  text-decoration: underline;
}

.reader-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 0.9em;
}

.reader-content pre {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.reader-content pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
}

.reader-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.reader-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.reader-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ============================================
   Search Results
   ============================================ */

.search-results {
  padding: 0 12px 20px;
}

.search-result {
  display: block;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-result:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.search-result-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.search-result-path {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.search-result-snippet {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.search-result-snippet mark {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 1px 2px;
  border-radius: 2px;
}

/* ============================================
   Empty States
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 16px;
}

/* ============================================
   Loading State
   ============================================ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-tertiary);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Animations
   ============================================ */

.fade-in {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-in {
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { 
    opacity: 0;
    transform: translateX(20px);
  }
  to { 
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   Tabs Navigation
   ============================================ */

.tabs {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0;
  flex-shrink: 0;
}

.tabs > div:first-child {
  display: flex;
}

.agent-selector {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.agent-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.agent-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.agent-pill.active {
  background: rgba(99, 179, 237, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 14px 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================
   Cron Jobs View
   ============================================ */

.cron-list {
  padding: 12px;
}

.cron-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.cron-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.cron-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  margin-right: 12px;
}

.cron-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.cron-status.ok {
  background: rgba(52, 199, 89, 0.2);
  color: #34c759;
}

.cron-status.idle {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}

.cron-status.error {
  background: rgba(255, 69, 58, 0.2);
  color: #ff453a;
}

.cron-schedule {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cron-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.cron-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'SF Mono', 'Monaco', monospace;
  opacity: 0.7;
}

/* ============================================
   Desktop Adjustments
   ============================================ */

@media (min-width: 768px) {
  .content-area {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
  }
  
  .header {
    padding: 16px 20px;
  }
  
  .search-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 20px;
  }
  
  .item-list {
    padding: 0 8px 20px;
  }
  
  .reader {
    padding: 30px 0;
    padding-bottom: 80px;
  }
  
  .reader-title {
    font-size: 36px;
  }
  
  .reader-content {
    font-size: 18px;
  }
}
