/* ── Orgrimmar Task Dashboard ── */
/* Dark theme kanban board with Firebase real-time */

:root {
  --bg: #000000;
  --bg-elev-1: #0A0A0A;
  --bg-elev-2: #111111;
  --surface-hover: #171717;
  --border-subtle: #232323;
  --text-primary: #FFFFFF;
  --text-secondary: #B3B3B3;
  --text-tertiary: #7A7A7A;
  --accent: #2F6BFF;
  --accent-hover: #2457D6;
  --error: #EF4444;
  --success: #16A34A;
  --warning: #F59E0B;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 16px;
  --dur-fast: 140ms;
  --dur-base: 200ms;
  --ease-standard: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.hidden { display: none !important; }

h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 15px; font-weight: 700; }

.caption { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ── Login (preserved) ── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 22px;
}
.login-sub { margin-top: 6px; color: var(--text-secondary); }
.field { margin-top: 16px; display: grid; gap: 10px; }
input[type="password"] {
  width: 100%;
  min-height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev-2);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 16px;
}
input[type="password"]:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.error-msg { color: #FCA5A5; margin-top: 8px; font-size: 12px; min-height: 18px; }

/* ── Buttons ── */
.btn {
  min-height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev-2);
  color: var(--text-primary);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-standard),
              border-color var(--dur-base) var(--ease-standard);
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger-outline { border-color: #5C1F1F; color: #FCA5A5; background: transparent; }
.btn-danger-outline:hover { background: #241010; }

/* ── Dashboard Layout ── */
.dashboard-container {
  width: 100%;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 8px 0;
}
.header-left { display: flex; flex-direction: column; gap: 2px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Filters ── */
.filters-inline { display: flex; gap: 8px; }
.filter-select {
  background: var(--bg-elev-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
}
.filter-select:hover { border-color: #444; }
.filter-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Kanban Board ── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(280px, 1fr));
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  flex: 1;
  align-items: start;
}

.kanban-column {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 12px;
  min-height: 200px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Scrollbar styling */
.kanban-column::-webkit-scrollbar { width: 4px; }
.kanban-column::-webkit-scrollbar-track { background: transparent; }
.kanban-column::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
.kanban-column::-webkit-scrollbar-thumb:hover { background: #555; }

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.column-header h2 { flex: 1; }

/* Column accent colors */
[data-column="new"] .column-header { border-bottom-color: #1D4ED8; }
[data-column="progress"] .column-header { border-bottom-color: #16A34A; }
[data-column="pipeline"] .column-header { border-bottom-color: #7C3AED; }
[data-column="blocked"] .column-header { border-bottom-color: #EF4444; }
[data-column="review"] .column-header { border-bottom-color: #F59E0B; }
[data-column="done"] .column-header { border-bottom-color: #6B7280; }

.count {
  background: var(--bg-elev-2);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

/* Done column collapse */
.kanban-column.collapsed {
  min-height: auto;
  max-height: none;
}
.kanban-column.collapsed .task-list { display: none; }
.column-header-toggle { cursor: pointer; user-select: none; }
.collapse-chevron {
  color: var(--text-tertiary);
  transition: transform var(--dur-base) var(--ease-standard);
  flex-shrink: 0;
}
.kanban-column.collapsed .collapse-chevron { transform: rotate(-90deg); }
.collapsed-hint {
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

/* ── Task Cards ── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.task-list:empty::after {
  content: 'No tasks';
  display: block;
  text-align: center;
  color: var(--text-tertiary);
  padding: 16px 8px;
  font-size: 13px;
}

.task-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: background var(--dur-base) var(--ease-standard),
              border-color var(--dur-base) var(--ease-standard);
}
.task-card:hover { background: var(--surface-hover); }

.task-card-trigger {
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.task-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.task-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.task-assignee {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.task-time {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Priority dots */
.badge-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.badge-priority-dot.priority-critical { background: #EF4444; box-shadow: 0 0 6px #EF444488; }
.badge-priority-dot.priority-high { background: #F59E0B; }
.badge-priority-dot.priority-normal { background: #6B7280; }
.badge-priority-dot.priority-low { background: #374151; }

/* Priority inline badges */
.badge-priority-inline {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-priority-inline.priority-critical { background: #7F1D1D; color: #FCA5A5; }
.badge-priority-inline.priority-high { background: #78350F; color: #FCD34D; }
.badge-priority-inline.priority-normal { background: #1F2937; color: #9CA3AF; }
.badge-priority-inline.priority-low { background: #111827; color: #6B7280; }

/* ── Expanded card body ── */
.task-card-body {
  padding: 0 10px 10px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 2px;
}

.task-fields {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.task-fields td {
  padding: 3px 0;
  font-size: 12px;
  vertical-align: top;
}
.field-label {
  color: var(--text-tertiary);
  width: 80px;
  padding-right: 8px;
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0;
}
.task-tag {
  background: #1E293B;
  color: #94A3B8;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.task-description {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  max-height: 200px;
  overflow-y: auto;
}

/* ── Footer ── */
.dashboard-footer {
  margin-top: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
}
.refresh-label { color: var(--text-tertiary); }
.connection-status {
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}
.connection-status.connected { background: #052E16; color: #4ADE80; }
.connection-status.connecting { background: #1E293B; color: #94A3B8; }
.connection-status.disconnected { background: #450A0A; color: #FCA5A5; }

/* ── Responsive ── */

/* Compact cards for 6-column layout */
.task-card { padding: 10px; font-size: 13px; overflow: hidden; }
.task-card .task-title { font-size: 13px; word-break: break-word; }
.task-details td { font-size: 11px; word-break: break-all; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1400px) {
  .kanban-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .kanban-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.tab-bar { display: none; }

@media (max-width: 600px) {
  .dashboard-container { padding: 10px; }
  .kanban-board {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .kanban-column {
    max-height: none;
    display: none;
  }
  .kanban-column.active-tab {
    display: block;
  }
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .filters-inline {
    flex-direction: row;
    width: 100%;
    gap: 8px;
  }
  .filter-select {
    flex: 1;
    min-width: 0;
  }
  .dashboard-header {
    position: relative;
  }
  #exitBtn {
    position: absolute;
    top: 0;
    right: 0;
    padding: 6px 12px;
    font-size: 13px;
  }
  .header-actions {
    width: 100%;
  }
  /* Tab bar */
  .tab-bar {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0;
    padding: 0;
    margin: 12px 0 8px 0;
    border-bottom: 2px solid #333;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-base, #0d0d0d);
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    font-family: inherit;
  }
  .tab-btn.active {
    color: #fff;
    border-bottom-color: #6c5ce7;
  }
  .tab-btn .tab-count {
    font-size: 11px;
    color: #666;
    margin-left: 4px;
  }
  .tab-btn.active .tab-count {
    color: #a29bfe;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ── Task Brief (markdown in expanded card) ── */
.task-arrow {
  color: var(--muted, #999);
  margin: 0 4px;
  font-size: 0.9em;
}
.task-brief-indicator {
  margin-left: 6px;
  font-size: 0.85em;
  opacity: 0.7;
}
.task-brief {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  line-height: 1.5;
  color: #d0d0d0;
  max-height: 480px;
  overflow-y: auto;
}
.task-brief .md-h {
  color: #fff;
  margin: 12px 0 6px;
  font-weight: 600;
}
.task-brief h3.md-h { font-size: 15px; }
.task-brief h4.md-h { font-size: 14px; color: #e0e0e0; }
.task-brief h5.md-h { font-size: 13px; color: #c0c0c0; }
.task-brief .md-h:first-child { margin-top: 0; }
.task-brief .md-p { margin: 6px 0; }
.task-brief .md-list {
  margin: 4px 0 8px;
  padding-left: 20px;
}
.task-brief .md-list li { margin: 2px 0; }
.task-brief .md-list li.md-check {
  list-style: none;
  margin-left: -18px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.task-brief .md-box {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 1px solid #666;
  border-radius: 2px;
  margin-top: 3px;
  flex-shrink: 0;
  background: transparent;
}
.task-brief .md-box.on {
  background: #4a9;
  border-color: #4a9;
  position: relative;
}
.task-brief .md-box.on::after {
  content: '✓';
  position: absolute;
  top: -3px;
  left: 1px;
  color: #000;
  font-size: 12px;
  font-weight: 700;
}
.task-brief .md-inline-code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #9ec9ff;
}
.task-brief .md-code {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.4;
}
.task-brief .md-code code { color: #c0c0c0; }
.task-brief .md-link {
  color: #5b9aff;
  text-decoration: underline;
  word-break: break-all;
}
.task-brief strong { color: #fff; }
.task-brief em { color: #e0e0e0; }

/* ── Fix: dark scrollbar + prevent card overflow ── */
.task-brief {
  min-width: 0;              /* prevent flex item from expanding */
  overflow-x: hidden;         /* block long content from pushing width */
  scrollbar-width: thin;      /* Firefox */
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.task-brief::-webkit-scrollbar { width: 8px; height: 8px; }
.task-brief::-webkit-scrollbar-track { background: transparent; }
.task-brief::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.task-brief::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}
.task-brief .md-code {
  max-width: 100%;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.task-brief .md-code::-webkit-scrollbar { height: 6px; }
.task-brief .md-code::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
.task-brief .md-list,
.task-brief .md-p { word-wrap: break-word; overflow-wrap: break-word; }
.task-brief .md-inline-code { word-break: break-all; }

/* ensure expanded card body doesn't expand the column horizontally */
.task-card-body { min-width: 0; overflow-x: hidden; }
