/* Brian-OS Global Styles - Mobile-First Design */

/* ==================== BASE RESET ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --text-primary: #fff;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --success: #10b981;
  --warning: #fbbf24;
  --error: #ef4444;
  --info: #60a5fa;
  --card-bg: rgba(255,255,255,0.05);
  --card-border: rgba(255,255,255,0.1);
  --touch-min: 44px; /* iOS minimum touch target */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent horizontal scroll on mobile */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
}

/* ==================== NAVIGATION ==================== */
.nav {
  background: rgba(0,0,0,0.4);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@supports (padding: max(0px)) {
  .nav {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  color: var(--text-primary);
}

.nav-brand-icon { font-size: 24px; }

/* Desktop nav links */
.nav-links {
  display: flex !important;
  gap: 4px;
  visibility: visible !important;
}

.nav-link {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.nav-link.active { background: rgba(99, 102, 241, 0.3); color: var(--text-primary); }

/* Nav Dropdowns */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger { background: none; border: none; cursor: pointer; font-family: inherit; display: flex; align-items: center; gap: 4px; }
.nav-dropdown-trigger .caret { font-size: 10px; transition: transform 0.2s; }
.nav-dropdown.open .caret { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: rgba(15,15,26,0.98);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 1001;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.dropdown-item {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  white-space: nowrap;
}
.dropdown-item:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.dropdown-item.active { background: rgba(99, 102, 241, 0.3); color: var(--text-primary); }

/* Mobile group headers */
.nav-mobile-group {
  padding: 12px 20px 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Hamburger Menu */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s;
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Menu Overlay */
.nav-mobile {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.95);
  z-index: 999;
  padding: 80px 20px 40px;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.nav-mobile.active {
  display: flex;
}

.nav-mobile .nav-link {
  padding: 16px 20px;
  font-size: 18px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
}

/* Desktop: show nav links, hide hamburger */
@media (min-width: 769px) {
  .nav-links {
    display: flex;
  }
  .nav-toggle {
    display: none;
  }
}

/* Mobile: hide nav links, show hamburger */
@media (max-width: 768px) {
  .nav-links {
    display: none !important;
  }
  .nav-toggle {
    display: flex !important;
  }
}

/* ==================== CONTAINER ==================== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 768px) {
  .container {
    padding: 24px 20px;
  }
}

/* ==================== ROBOT SECTION ==================== */
.robot-section {
  text-align: center;
  padding: 16px 0 24px;
}

@media (min-width: 768px) {
  .robot-section {
    padding: 20px 0 30px;
  }
}

.robot {
  font-size: 64px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 15px 30px rgba(99, 102, 241, 0.4));
}

@media (min-width: 768px) {
  .robot { font-size: 80px; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.robot.working { 
  animation: float 2s ease-in-out infinite; 
  filter: drop-shadow(0 15px 30px rgba(16, 185, 129, 0.5)); 
}

.status-text {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 10px;
  color: var(--success);
}

@media (min-width: 768px) {
  .status-text {
    font-size: 12px;
    letter-spacing: 3px;
    margin-top: 12px;
  }
}

.status-text.idle { color: var(--accent); }

.current-task-text {
  font-size: 16px;
  font-weight: 500;
  margin-top: 6px;
  color: var(--text-secondary);
  padding: 0 10px;
}

@media (min-width: 768px) {
  .current-task-text {
    font-size: 18px;
    margin-top: 8px;
  }
}

/* ==================== STATS ROW ==================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}

@media (min-width: 480px) {
  .stats-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 20px 0;
  }
}

.stat-card {
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}

@media (min-width: 768px) {
  .stat-card { padding: 16px; }
}

.stat-value { 
  font-size: 24px; 
  font-weight: 700; 
  color: var(--info); 
}

@media (min-width: 768px) {
  .stat-value { font-size: 28px; }
}

.stat-label { 
  font-size: 10px; 
  color: var(--text-dim); 
  text-transform: uppercase; 
  letter-spacing: 1px; 
  margin-top: 4px; 
}

@media (min-width: 768px) {
  .stat-label { font-size: 11px; }
}

/* ==================== SECTION TITLES ==================== */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

@media (min-width: 768px) {
  .section-title { font-size: 12px; }
}

/* ==================== ACTIONS GRID ==================== */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

@media (min-width: 480px) {
  .actions-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }
}

.action-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 14px 10px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: var(--touch-min);
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  .action-btn {
    padding: 14px;
    font-size: 13px;
  }
}

.action-btn:hover, .action-btn:active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.5), rgba(99, 102, 241, 0.2));
}

@media (hover: hover) {
  .action-btn:hover {
    transform: translateY(-2px);
  }
}

.action-btn .icon { font-size: 20px; }

@media (min-width: 768px) {
  .action-btn .icon { font-size: 22px; }
}

/* ==================== INFO GRID ==================== */
.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 600px) {
  .info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.info-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px;
}

@media (min-width: 768px) {
  .info-card { padding: 16px; }
}

.info-card h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

@media (min-width: 768px) {
  .info-card h3 { 
    font-size: 11px; 
    margin-bottom: 12px;
  }
}

.activity-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}

.activity-item:last-child { border-bottom: none; }
.activity-time { color: var(--info); min-width: 50px; font-size: 11px; }
.activity-action { color: var(--text-secondary); }

.health-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.health-dot.off { background: var(--error); }

/* ==================== KANBAN PREVIEW ==================== */
.kanban-preview {
  margin-top: 20px;
}

@media (min-width: 768px) {
  .kanban-preview { margin-top: 24px; }
}

.kanban-link {
  display: block;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
  border: 1px solid rgba(99, 102, 241, 0.2);
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  .kanban-link { padding: 20px; }
}

.kanban-link:hover, .kanban-link:active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.4);
}

@media (hover: hover) {
  .kanban-link:hover { transform: translateY(-2px); }
}

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

@media (min-width: 768px) {
  .kanban-header { margin-bottom: 16px; }
}

.kanban-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (min-width: 768px) {
  .kanban-header h3 { font-size: 16px; }
}

.kanban-header span { font-size: 12px; color: var(--text-muted); }

@media (min-width: 768px) {
  .kanban-header span { font-size: 13px; }
}

.kanban-columns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .kanban-columns { gap: 12px; }
}

.kanban-col {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
}

@media (min-width: 768px) {
  .kanban-col { padding: 12px; }
}

.kanban-col-count { font-size: 20px; font-weight: 700; }

@media (min-width: 768px) {
  .kanban-col-count { font-size: 24px; }
}

.kanban-col-label { 
  font-size: 8px; 
  color: var(--text-dim); 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
  margin-top: 2px; 
}

@media (min-width: 480px) {
  .kanban-col-label { 
    font-size: 9px;
    letter-spacing: 1px; 
    margin-top: 4px;
  }
}

@media (min-width: 768px) {
  .kanban-col-label { font-size: 10px; }
}

.col-backlog .kanban-col-count { color: var(--text-muted); }
.col-inprogress .kanban-col-count { color: var(--info); }
.col-review .kanban-col-count { color: var(--warning); }
.col-done .kanban-col-count { color: var(--success); }

/* ==================== ORG CHART ==================== */
.org-chart {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}

@media (min-width: 768px) {
  .org-chart { padding: 24px; }
}

.org-level {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .org-level { gap: 12px; }
}

.org-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  transition: all 0.2s;
  cursor: default;
}

@media (min-width: 768px) {
  .org-node { padding: 12px 16px; }
}

.org-node:hover {
  background: rgba(99, 102, 241, 0.2);
}

@media (hover: hover) {
  .org-node:hover { transform: translateY(-2px); }
}

.org-icon { font-size: 24px; margin-bottom: 4px; }

@media (min-width: 768px) {
  .org-icon { font-size: 28px; }
}

.org-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

@media (min-width: 768px) {
  .org-name { font-size: 13px; }
}

.org-role { 
  font-size: 9px; 
  color: var(--text-dim); 
  text-transform: uppercase; 
  letter-spacing: 1px; 
  margin-top: 2px; 
}

@media (min-width: 768px) {
  .org-role { font-size: 10px; }
}

.org-brian { border: 2px solid rgba(99, 102, 241, 0.5); }
.org-clawd { border: 2px solid rgba(16, 185, 129, 0.5); min-width: 90px; }

@media (min-width: 768px) {
  .org-clawd { min-width: 100px; }
}

.org-connector {
  width: 2px;
  height: 16px;
  background: linear-gradient(to bottom, rgba(99, 102, 241, 0.5), rgba(16, 185, 129, 0.5));
  margin: 0 auto;
}

@media (min-width: 768px) {
  .org-connector { height: 20px; }
}

.org-connector-split {
  position: relative;
  height: 24px;
  margin: 0 auto;
  width: 85%;
}

@media (min-width: 768px) {
  .org-connector-split {
    height: 30px;
    width: 80%;
  }
}

.org-connector-split::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 12px;
  background: rgba(16, 185, 129, 0.5);
  transform: translateX(-50%);
}

@media (min-width: 768px) {
  .org-connector-split::before { height: 15px; }
}

.org-connector-split::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 3%;
  right: 3%;
  height: 2px;
  background: linear-gradient(to right, rgba(255,255,255,0.1), rgba(16, 185, 129, 0.3), rgba(16, 185, 129, 0.3), rgba(255,255,255,0.1));
}

@media (min-width: 768px) {
  .org-connector-split::after {
    top: 15px;
    left: 5%;
    right: 5%;
  }
}

.org-agents {
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
}

@media (min-width: 768px) {
  .org-agents {
    gap: 10px;
    padding-top: 15px;
  }
}

.org-agent {
  min-width: 55px;
  padding: 8px 10px;
}

@media (min-width: 480px) {
  .org-agent {
    min-width: 65px;
    padding: 10px 12px;
  }
}

@media (min-width: 768px) {
  .org-agent { min-width: 70px; }
}

.org-agent .org-icon { font-size: 18px; }

@media (min-width: 768px) {
  .org-agent .org-icon { font-size: 22px; }
}

.org-agent .org-name { font-size: 10px; }

@media (min-width: 768px) {
  .org-agent .org-name { font-size: 11px; }
}

/* ==================== FOOTER ==================== */
.footer {
  text-align: center;
  padding: 20px 16px;
  color: #475569;
  font-size: 11px;
}

@media (min-width: 768px) {
  .footer {
    padding: 24px;
    font-size: 12px;
  }
}

@supports (padding: max(0px)) {
  .footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--success);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  transition: transform 0.3s;
  z-index: 1100;
}

@supports (padding: max(0px)) {
  .toast {
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
  }
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ==================== PWA / WIDGET STYLES ==================== */
/* Standalone mode (when added to home screen) */
@media (display-mode: standalone) {
  .nav {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

/* Widget-specific view */
.widget-view {
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.widget-view .robot-section {
  padding: 10px 0 16px;
}

.widget-view .robot {
  font-size: 48px;
}

.widget-view .stats-row {
  margin: 0;
}

.widget-view .stat-card {
  padding: 10px;
}

.widget-view .stat-value {
  font-size: 20px;
}

.widget-view .stat-label {
  font-size: 9px;
}

/* ==================== KANBAN PAGE MOBILE ==================== */
.kanban-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  min-height: auto;
}

@media (min-width: 768px) {
  .kanban-board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .kanban-board {
    grid-template-columns: repeat(4, minmax(280px, 1fr));
    min-height: calc(100vh - 180px);
  }
}

/* Horizontal scrolling on mobile for full board view */
.kanban-board.horizontal {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
  gap: 12px;
}

.kanban-board.horizontal .kanban-column {
  min-width: 280px;
  scroll-snap-align: start;
  flex-shrink: 0;
}

/* ==================== UTILITY CLASSES ==================== */
.hide-mobile {
  display: none !important;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: initial !important;
  }
}

.show-mobile {
  display: initial !important;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none !important;
  }
}
