/* ── Design Tokens ─────────────────────────────── */
:root {
  --bg:        #08090d;
  --surface:   rgba(255,255,255,0.02);
  --border:    rgba(255,255,255,0.06);
  --border-hv: rgba(255,255,255,0.10);
  --text:      #e4e4e7;
  --text-muted:#71717a;
  --text-dim:  #52525b;
  --amber:     #f59e0b;
  --green:     #22c55e;
  --indigo:    #6366f1;
  --red:       #ef4444;
  --radius-card: 16px;
  --radius-btn:  10px;
  --transition:  0.15s ease;
}

/* ── App Layout ────────────────────────────────── */
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); }

/* Sidebar width */
nexus-sidebar { width: 240px; flex-shrink: 0; }

/* Right panel width */
nexus-chat-panel { width: 360px; flex-shrink: 0; }

/* ── Card base ─────────────────────────────────── */
.nx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.nx-card:hover { border-color: var(--border-hv); transform: translateY(-1px); }

/* Accent bars (top border gradient) */
.nx-card-amber::before { background: linear-gradient(90deg, #f59e0b, #f97316); }
.nx-card-green::before  { background: linear-gradient(90deg, #22c55e, #10b981); }
.nx-card-indigo::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.nx-card-red::before    { background: linear-gradient(90deg, #ef4444, #f97316); }
.nx-card[class*="nx-card-"]::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

/* Ambient glow (bottom-right radial, color-matched) */
.nx-card-amber::after  { background: radial-gradient(circle, rgba(245,158,11,0.12) 0%, transparent 65%); }
.nx-card-green::after  { background: radial-gradient(circle, rgba(34,197,94,0.12)  0%, transparent 65%); }
.nx-card-indigo::after { background: radial-gradient(circle, rgba(99,102,241,0.14) 0%, transparent 65%); }
.nx-card-red::after    { background: radial-gradient(circle, rgba(239,68,68,0.12)  0%, transparent 65%); }
.nx-card[class*="nx-card-"]::after {
  content: ''; position: absolute; top: -24px; right: -20px;
  width: 120px; height: 120px; border-radius: 50%; pointer-events: none;
}

/* KPI card value — tinted to match accent */
.nx-card-amber  > div:nth-child(2) { color: #fde68a; }
.nx-card-green  > div:nth-child(2) { color: #86efac; }
.nx-card-indigo > div:nth-child(2) { color: #c7d2fe; }
.nx-card-red    > div:nth-child(2) { color: #fca5a5; }

/* ── Status dots ───────────────────────────────── */
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.status-dot.idle    { background: #eab308; box-shadow: 0 0 6px rgba(234,179,8,0.4); }
.status-dot.offline { background: #3f3f46; }

/* ── Pulse animation (notification dot) ───────── */
@keyframes nx-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.nx-pulse { animation: nx-pulse 2s infinite; }

/* ── News feed category left borders ───────────── */
.nx-news-item                           { border-left: 3px solid #3f3f46; }
.nx-news-item[data-cat="geopolitical"]  { border-left-color: #6366f1; }
.nx-news-item[data-cat="finance"]       { border-left-color: #22c55e; }
.nx-news-item[data-cat="crypto"]        { border-left-color: #f59e0b; }
.nx-news-item[data-cat="tech"]          { border-left-color: #3b82f6; }
.nx-news-item[data-cat="cyber"]         { border-left-color: #ef4444; }

/* ── Scrollbars ────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ── Task board ─────────────────────────────────── */

/* Input focus glow */
#new-task-form input:focus,
#new-task-form textarea:focus,
#new-task-form select:focus,
#edit-modal-overlay input:focus,
#edit-modal-overlay textarea:focus,
#edit-modal-overlay select:focus {
  border-color: rgba(99,102,241,0.5) !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}

/* Card hover */
[data-task-id]:hover {
  border-color: rgba(255,255,255,0.18) !important;
  background: rgba(255,255,255,0.07) !important;
}

/* Drag-over column highlight */
.nx-task-col.nx-drag-over {
  background: rgba(99,102,241,0.06) !important;
  border-color: rgba(99,102,241,0.2) !important;
}

/* Mobile column tabs: hidden on desktop */
.nx-col-tabs { display: none; }

/* Desktop: 4-column grid */
.nx-task-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.75rem; align-items: start; }

/* Row layout for priority/machine fields */
.nx-task-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

@media (max-width: 768px) {
  /* Show tab switcher, hide the grid entirely — show one col at a time */
  .nx-col-tabs {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 0.75rem;
    padding-bottom: 0.1rem;
  }
  .nx-col-tabs::-webkit-scrollbar { display: none; }

  .nx-col-tab {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    color: #52525b;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .nx-col-tab.active {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
    color: #e4e4e7;
  }
  .nx-col-tab-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--col-color, #52525b);
  }
  .nx-col-tab-count {
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 0 0.3rem;
    font-size: 0.6rem;
    color: #71717a;
    min-width: 16px;
    text-align: center;
  }

  /* 4-column grid → single column, hide inactive */
  .nx-task-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .nx-task-col { display: none; }
  .nx-task-col.nx-col-active { display: block; }

  /* Stack priority/machine fields vertically */
  .nx-task-form-row { grid-template-columns: 1fr; }

  /* Larger text inputs for touch */
  #nt-title, #edit-title, #nt-machine, #edit-machine,
  #nt-description, #edit-description,
  #nt-priority, #edit-priority, #edit-status {
    font-size: 16px !important; /* prevents iOS zoom on focus */
    padding: 0.6rem 0.75rem !important;
  }
}

/* ── Scroll lock (applied to body when mobile overlay is open) ── */
body.nx-scroll-lock { overflow: hidden; touch-action: none; }

/* ── Mobile Bottom Nav (hidden on desktop) ─────── */
#mobile-nav        { display: none; }
#mobile-more-drawer   { display: none; }
#mobile-more-backdrop { display: none; }
#chat-fab-close    { display: none; }

/* ── Mobile Responsive ─────────────────────────── */
@media (max-width: 768px) {
  /* Hide desktop sidebar */
  nexus-sidebar { display: none !important; }

  /* Hide topbar ticker and search to save space */
  .nx-ticker { display: none !important; }
  .nx-search { display: none !important; }

  /* Add bottom padding so content isn't behind nav bar */
  #main-content { padding-bottom: 72px !important; }

  /* Chat panel — full-screen slide-in overlay */
  nexus-chat-panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    z-index: 200;
    transform: translateX(105%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    font-size: 16px !important;
  }
  nexus-chat-panel.nx-open { transform: translateX(0); }

  /* Prevent iOS auto-zoom on chat inputs and text */
  nexus-chat-panel input,
  nexus-chat-panel textarea { font-size: 16px !important; }
  /* Give tab bar room for the close button */
  #chat-tab-bar { padding-right: 3.5rem !important; }

  /* Chat close button — large touch target, always top-right */
  #chat-fab-close {
    display: none;
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(12,13,18,0.9);
    border: 1px solid rgba(255,255,255,0.2);
    color: #e4e4e7;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 201;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  #chat-fab-close.nx-open { display: flex; }

  /* ── Bottom navigation bar ── */
  #mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: rgba(12,13,18,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 99;
    padding: 0 0.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .nx-mnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: #52525b;
    font-size: 0.6rem;
    font-weight: 500;
    padding: 0.35rem 0;
    border-radius: 10px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .nx-mnav-btn svg { width: 20px; height: 20px; }
  .nx-mnav-btn.active { color: #f59e0b; }
  .nx-mnav-chat.active svg { stroke: #f59e0b; }

  /* ── More drawer ── */
  #mobile-more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    backdrop-filter: blur(4px);
  }
  #mobile-more-backdrop.nx-open { display: block; }

  #mobile-more-drawer {
    display: block;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #0c0d12;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px 20px 0 0;
    z-index: 151;
    padding: 0.5rem 0 1rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
  }
  #mobile-more-drawer.nx-open { transform: translateY(0); }

  #mobile-more-handle {
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
    margin: 0 auto 0.75rem;
  }

  #mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    padding: 0 0.75rem;
  }
  .nx-more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 0.75rem 0.25rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #a1a1aa;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
  }
  .nx-more-item:active { background: rgba(245,158,11,0.1); color: #f59e0b; }
  .nx-more-item svg { width: 22px; height: 22px; }

  /* ── News feed mobile ── */
  #news-list .nx-news-item { border-left-width: 3px; }

  /* ── Finance dashboard mobile ── */
  .nx-finance-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nx-finance-scroll th.nx-col-hide,
  .nx-finance-scroll td.nx-col-hide { display: none; }
  .nx-finance-scroll th.nx-col-mob-hide,
  .nx-finance-scroll td.nx-col-mob-hide { display: none; }
  .nx-finance-scroll th.nx-col-ticker,
  .nx-finance-scroll td.nx-col-ticker {
    position: sticky; left: 0; z-index: 2;
    background: #08090d;
  }
  #add-bar { flex-wrap: wrap; }
  #add-bar input { flex: 1; min-width: 100px; }
}
