/* ================================================================
   Command Center — Dark Terminal Dashboard
   ================================================================ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  --bg:            #0a0a0a;
  --bg-surface:    #111111;
  --bg-elevated:   #181818;
  --bg-hover:      #1c1c1c;
  --border:        #242424;
  --border-focus:  #3a3a3a;

  --text:          #e5e5e5;
  --text-muted:    #6b7280;
  --text-dim:      #374151;

  --accent:        #d4a843;
  --accent-dim:    #3a2e0e;
  --accent-mid:    #92731e;

  --danger:        #dc2626;
  --danger-dim:    #2d0a0a;
  --danger-mid:    #7f1d1d;

  --success:       #16a34a;
  --success-dim:   #052e16;

  --mono: ui-monospace, 'Cascadia Code', 'Source Code Pro',
          Menlo, Monaco, 'Courier New', monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI',
          Roboto, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body               { height: 100%; overflow: hidden; }

body {
  background:  var(--bg);
  color:       var(--text);
  font-family: var(--sans);
  font-size:   13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* ── App shell ─────────────────────────────────────────────────── */
#app {
  display:               grid;
  grid-template-rows:    48px 0px 1fr 52px;
  height:                100vh;
  overflow:              hidden;
  transition:            grid-template-rows 0.2s ease;
}
/* When audio bar is shown, grow its row to 28px */
#app.audio-active {
  grid-template-rows:    48px 28px 1fr 52px;
}

/* ── Top bar ───────────────────────────────────────────────────── */
#topbar {
  display:        flex;
  align-items:    center;
  padding:        0 16px;
  gap:            16px;
  background:     var(--bg-surface);
  border-bottom:  1px solid var(--border);
  flex-shrink:    0;
  overflow:       hidden;
}

.topbar-left  { display: flex; align-items: center; flex-shrink: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }

.title {
  font-family:     var(--mono);
  font-size:       14px;
  font-weight:     700;
  letter-spacing:  0.18em;
  color:           var(--accent);
}

.topbar-meta {
  font-family:  var(--mono);
  font-size:    11px;
  color:        var(--text-muted);
  white-space:  nowrap;
}

#next-event { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

.unread-badge {
  font-family:   var(--mono);
  font-size:     10px;
  font-weight:   700;
  background:    var(--danger);
  color:         #fff;
  padding:       1px 6px;
  min-width:     18px;
  text-align:    center;
}

.btn-topbar {
  font-family:     var(--mono);
  font-size:       10px;
  font-weight:     700;
  letter-spacing:  0.08em;
  background:      transparent;
  border:          1px solid var(--border);
  color:           var(--text-muted);
  padding:         4px 10px;
  transition:      border-color 0.15s, color 0.15s;
}
.btn-topbar:hover { border-color: var(--accent); color: var(--accent); }

/* Play button — accent-tinted variant */
.btn-topbar.btn-play { border-color: var(--accent-mid); color: var(--accent); }
.btn-topbar.btn-play:hover { border-color: var(--accent); background: var(--accent-dim); }
.btn-topbar.btn-play.playing {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.btn-topbar.btn-play.loading {
  opacity: 0.6;
  cursor: wait;
}

/* ── Audio waveform bar ─────────────────────────────────────────── */
#audio-bar {
  display:        flex;
  align-items:    center;
  gap:            8px;
  padding:        0 10px;
  background:     var(--accent-dim);
  border-bottom:  1px solid var(--accent-mid);
  flex-shrink:    0;
  overflow:       hidden;
  /* visibility controlled by grid row height, not display */
}

/* Five animated waveform bars */
.wave-bars {
  display:  flex;
  align-items: center;
  gap: 2px;
  height: 16px;
}
.wave-bar {
  width:            3px;
  background:       var(--accent);
  border-radius:    1px;
  animation:        wave-bounce 0.8s ease-in-out infinite;
  transform-origin: bottom;
}
.wave-bar:nth-child(1) { height: 6px;  animation-delay: 0s;    }
.wave-bar:nth-child(2) { height: 10px; animation-delay: 0.12s; }
.wave-bar:nth-child(3) { height: 14px; animation-delay: 0.24s; }
.wave-bar:nth-child(4) { height: 10px; animation-delay: 0.36s; }
.wave-bar:nth-child(5) { height: 6px;  animation-delay: 0.48s; }

@keyframes wave-bounce {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50%       { transform: scaleY(1.0); opacity: 1.0; }
}

.audio-progress {
  flex:             1;
  height:           3px;
  background:       var(--border);
  position:         relative;
  border-radius:    2px;
  overflow:         hidden;
  cursor:           pointer;
}
.audio-progress-fill {
  height:           100%;
  background:       var(--accent);
  width:            0%;
  transition:       width 0.25s linear;
  border-radius:    2px;
}

.audio-time {
  font-family:  var(--mono);
  font-size:    10px;
  color:        var(--accent);
  white-space:  nowrap;
  min-width:    36px;
  text-align:   right;
}

.btn-audio-stop {
  font-family:   var(--mono);
  font-size:     10px;
  font-weight:   700;
  background:    transparent;
  border:        none;
  color:         var(--accent);
  padding:       0 4px;
  opacity:       0.7;
}
.btn-audio-stop:hover { opacity: 1; }

/* ── Column grid ───────────────────────────────────────────────── */
#columns {
  display:  grid;
  grid-template-columns: 1fr 1.45fr 1fr;
  overflow: hidden;
  height:   100%;
}

.column {
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
  border-right:   1px solid var(--border);
}
.column:last-child { border-right: none; }

/* ── Column header ─────────────────────────────────────────────── */
.col-header {
  display:        flex;
  align-items:    center;
  gap:            8px;
  padding:        0 12px;
  height:         36px;
  background:     var(--bg-surface);
  border-bottom:  1px solid var(--border);
  flex-shrink:    0;
}

.col-title {
  font-family:     var(--mono);
  font-size:       9px;
  font-weight:     700;
  letter-spacing:  0.14em;
  color:           var(--text-muted);
  flex:            1;
}

.col-count {
  font-family: var(--mono);
  font-size:   10px;
  color:       var(--text-muted);
}
.col-count.at-cap { color: var(--accent); }

/* At 5/5 capacity: pulse the column's header border */
@keyframes pulse-amber {
  0%, 100% { border-bottom-color: var(--accent); }
  50%       { border-bottom-color: transparent;  }
}
.at-capacity > .col-header {
  animation:             pulse-amber 2s ease-in-out infinite;
  border-bottom-color:   var(--accent);
}

/* Promises filter tabs */
.filter-tabs { display: flex; gap: 2px; }

.filter-tab {
  font-family:     var(--mono);
  font-size:       9px;
  font-weight:     700;
  letter-spacing:  0.06em;
  background:      transparent;
  border:          1px solid transparent;
  color:           var(--text-dim);
  padding:         2px 7px;
  transition:      all 0.15s;
}
.filter-tab:hover  { color: var(--text-muted); }
.filter-tab.active { border-color: var(--border); color: var(--accent); }

/* ── Item list (scrollable) ────────────────────────────────────── */
.item-list {
  flex:       1;
  overflow-y: auto;
  padding:    3px 0;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.item-list::-webkit-scrollbar       { width: 3px; }
.item-list::-webkit-scrollbar-track { background: transparent; }
.item-list::-webkit-scrollbar-thumb { background: var(--border-focus); }

/* ── Shared item chrome ────────────────────────────────────────── */
.item {
  display:          flex;
  align-items:      flex-start;
  gap:              8px;
  padding:          8px 10px 8px 12px;
  border-bottom:    1px solid transparent;
  border-left:      3px solid transparent;
  transition:       background 0.1s;
  min-height:       42px;
}
.item:hover { background: var(--bg-hover); }

.item-body {
  flex:      1;
  min-width: 0;
  display:   flex;
  flex-direction: column;
  gap:       2px;
}

.item-text {
  font-family:  var(--mono);
  font-size:    12px;
  color:        var(--text);
  line-height:  1.45;
  word-break:   break-word;
}

.item-notes {
  font-size:       11px;
  color:           var(--text-muted);
  white-space:     nowrap;
  overflow:        hidden;
  text-overflow:   ellipsis;
  font-style:      italic;
}

/* Item actions: hidden until hover */
.item-actions {
  display:    flex;
  gap:        3px;
  align-items: center;
  opacity:    0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  padding-top: 1px;
}
.item:hover .item-actions { opacity: 1; }

/* ── Active priority items ─────────────────────────────────────── */
.rank {
  font-family:  var(--mono);
  font-size:    20px;
  font-weight:  700;
  color:        var(--accent);
  width:        22px;
  flex-shrink:  0;
  line-height:  1.15;
  margin-top:   1px;
}
.rank.dim { color: var(--text-dim); font-size: 15px; margin-top: 3px; }

.age {
  font-family:  var(--mono);
  font-size:    10px;
  color:        var(--text-dim);
  flex-shrink:  0;
  padding-top:  3px;
  min-width:    24px;
  text-align:   right;
}

/* Drag states */
.active-item          { cursor: grab; }
.active-item.dragging { opacity: 0.35; cursor: grabbing; }
.active-item.drag-over { border-top: 2px solid var(--accent); }

/* Empty slot rows */
.empty-slot {
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     9px 10px 9px 12px;
  min-height:  42px;
}
.slot-text {
  font-family:  var(--mono);
  font-size:    12px;
  color:        var(--text-dim);
  font-style:   italic;
}

/* ── Promise items ─────────────────────────────────────────────── */
.promise-item.overdue  { border-left-color: var(--danger); }
.promise-item.due-soon { border-left-color: var(--accent); }

.promised-to {
  font-size:       11px;
  font-weight:     600;
  color:           var(--text-muted);
  white-space:     nowrap;
  overflow:        hidden;
  text-overflow:   ellipsis;
}

.due-date {
  font-family:  var(--mono);
  font-size:    10px;
  color:        var(--text-muted);
}
.due-date.overdue  { color: var(--danger); }
.due-date.due-soon { color: var(--accent); }

/* Inline badges */
.badge {
  font-family:     var(--mono);
  font-size:       9px;
  font-weight:     700;
  letter-spacing:  0.06em;
  padding:         1px 5px;
  align-self:      flex-start;
  flex-shrink:     0;
}
.badge-overdue { background: var(--danger);     color: #fff; }
.badge-soon    { background: var(--accent-dim); color: var(--accent); }
.badge-done    { background: var(--success-dim); color: var(--success); }

/* ── Waiting items ─────────────────────────────────────────────── */
.category-tag {
  font-family:     var(--mono);
  font-size:       9px;
  font-weight:     700;
  letter-spacing:  0.06em;
  color:           var(--text-muted);
  border:          1px solid var(--border-focus);
  padding:         1px 5px;
  align-self:      flex-start;
  flex-shrink:     0;
  text-transform:  uppercase;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn-icon {
  font-family:  var(--mono);
  font-size:    14px;
  background:   transparent;
  border:       1px solid transparent;
  color:        var(--text-muted);
  width:        22px;
  height:       22px;
  display:      flex;
  align-items:  center;
  justify-content: center;
  padding:      0;
  flex-shrink:  0;
  transition:   all 0.1s;
  line-height:  1;
}
.btn-icon:hover             { border-color: var(--border-focus); color: var(--text); }
.btn-icon.btn-danger:hover  { border-color: var(--danger); color: var(--danger); }

.btn-fulfill {
  font-family: var(--mono);
  font-size:   14px;
  background:  transparent;
  border:      1px solid transparent;
  color:       var(--success);
  width:       22px;
  height:      22px;
  display:     flex;
  align-items: center;
  justify-content: center;
  padding:     0;
  flex-shrink: 0;
  transition:  all 0.1s;
}
.btn-fulfill:hover { border-color: var(--success); background: var(--success-dim); }

.btn-promote {
  font-family:     var(--mono);
  font-size:       9px;
  font-weight:     700;
  letter-spacing:  0.04em;
  background:      transparent;
  border:          1px solid var(--border);
  color:           var(--text-muted);
  padding:         2px 7px;
  white-space:     nowrap;
  flex-shrink:     0;
  transition:      all 0.1s;
}
.btn-promote:hover { border-color: var(--accent); color: var(--accent); }

/* ── Input bar ─────────────────────────────────────────────────── */
#input-bar {
  display:        flex;
  align-items:    center;
  gap:            10px;
  padding:        0 16px;
  background:     var(--bg-surface);
  border-top:     1px solid var(--border);
  flex-shrink:    0;
}

.prompt {
  font-family:  var(--mono);
  font-size:    20px;
  color:        var(--accent);
  line-height:  1;
  flex-shrink:  0;
  user-select:  none;
}

#nl-input {
  flex:         1;
  background:   transparent;
  border:       none;
  outline:      none;
  color:        var(--text);
  font-family:  var(--mono);
  font-size:    13px;
  padding:      0;
  caret-color:  var(--accent);
}
#nl-input::placeholder { color: var(--text-dim); }
#nl-input:disabled     { opacity: 0.5; }

.input-status {
  font-family:  var(--mono);
  font-size:    13px;
  color:        var(--accent);
  flex-shrink:  0;
  min-width:    20px;
  text-align:   center;
  animation:    blink 1s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Toast notification ────────────────────────────────────────── */
.toast {
  position:       fixed;
  bottom:         64px;
  left:           50%;
  transform:      translateX(-50%) translateY(10px);
  opacity:        0;
  pointer-events: none;
  transition:     opacity 0.2s ease, transform 0.2s ease;
  background:     var(--bg-elevated);
  border:         1px solid var(--border-focus);
  border-left:    3px solid var(--border-focus);
  color:          var(--text);
  padding:        10px 16px;
  font-family:    var(--mono);
  font-size:      12px;
  z-index:        1000;
  max-width:      min(640px, 90vw);
  white-space:    pre-wrap;
  word-break:     break-word;
  line-height:    1.5;
}
.toast.show           { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success  { border-left-color: var(--success); }
.toast.toast-error    { border-left-color: var(--danger);  }
.toast.toast-warn     { border-left-color: var(--accent);  }

/* ── Briefing modal ────────────────────────────────────────────── */
.modal-overlay {
  position:        fixed;
  inset:           0;
  background:      rgba(0, 0, 0, 0.78);
  display:         flex;
  align-items:     center;
  justify-content: center;
  z-index:         2000;
}
.modal-overlay.hidden { display: none; }

.modal {
  background:   var(--bg-surface);
  border:       1px solid var(--border-focus);
  width:        min(700px, 92vw);
  max-height:   80vh;
  display:      flex;
  flex-direction: column;
}

.modal-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         12px 16px;
  border-bottom:   1px solid var(--border);
  flex-shrink:     0;
}

.modal-title {
  font-family:     var(--mono);
  font-size:       10px;
  font-weight:     700;
  letter-spacing:  0.14em;
  color:           var(--accent);
}

.modal-close-btn {
  font-size:   18px;
  color:       var(--text-muted);
  line-height: 1;
  width:       24px;
  height:      24px;
}
.modal-close-btn:hover { color: var(--text); border-color: var(--border-focus); }

.modal-body {
  padding:     24px;
  overflow-y:  auto;
  font-family: var(--mono);
  font-size:   13px;
  line-height: 1.9;
  color:       var(--text);
  white-space: pre-wrap;
  word-break:  break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Empty state ───────────────────────────────────────────────── */
.empty-msg {
  padding:     16px 12px;
  font-family: var(--mono);
  font-size:   11px;
  color:       var(--text-dim);
  font-style:  italic;
}

/* ── Utility ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive (mobile) ───────────────────────────────────────── */
@media (max-width: 768px) {
  #app {
    grid-template-rows: auto 1fr 52px;
    height: 100svh;
  }

  #topbar {
    flex-wrap:  wrap;
    height:     auto;
    padding:    8px 12px;
    gap:        8px;
    min-height: 44px;
  }
  .topbar-right { gap: 8px; }
  .title        { font-size: 12px; letter-spacing: 0.12em; }
  #next-event   { display: none; }

  #columns {
    grid-template-columns: 1fr;
    grid-template-rows:    repeat(3, auto);
    overflow-y:            auto;
    height:                100%;
    scrollbar-width:       thin;
    scrollbar-color:       var(--border) transparent;
  }

  .column {
    border-right:  none;
    border-bottom: 1px solid var(--border);
  }
  .column:last-child { border-bottom: none; }

  .item-list { max-height: 320px; }
}
