/* bro-deckhand — стили */

:root {
  --bg-primary: #1a1d29;
  --bg-secondary: #242837;
  --bg-card: #2d3142;
  --text-primary: #e4e6f0;
  --text-secondary: #8b8fa3;
  --accent: #4a9eff;
  --accent-hover: #6bb3ff;
  --border: #3a3f52;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --ideas: #9c27b0;
  --todo: #2196f3;
  --in-progress: #ff9800;
  --done: #4caf50;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Шапка */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 12px;
  margin-left: -12px;
  border-radius: 8px;
  transition: background 0.2s;
  user-select: none;
}

.header-left:hover {
  background: var(--bg-card);
}

.header-left:active {
  background: var(--border);
}

.logo {
  font-size: 24px;
}

.app-name {
  font-size: 18px;
  font-weight: 600;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: var(--bg-card);
}

/* Сайдбар */
.sidebar {
  position: fixed;
  top: 56px;
  left: -280px;
  width: 280px;
  height: calc(100vh - 56px);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  transition: left 0.3s ease;
  z-index: 99;
  overflow-y: auto;
}

.sidebar.open {
  left: 0;
}

.sidebar-nav {
  padding: 16px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.2s;
  font-size: 15px;
}

.nav-item:hover {
  background: var(--bg-card);
}

.nav-item.active {
  background: var(--accent);
  color: white;
}

.nav-icon {
  font-size: 18px;
}

.nav-submenu {
  margin-left: 30px;
  margin-top: 4px;
}

.nav-subitem {
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.nav-subitem:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* Затемнение */
.overlay {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Контент */
.content {
  margin-top: 56px;
  padding: 20px;
  min-height: calc(100vh - 56px);
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Dashboard — карточки */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
}

.widget:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.widget-icon {
  font-size: 20px;
}

.widget-title {
  font-size: 16px;
  font-weight: 600;
}

.widget-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.widget-content strong {
  color: var(--text-primary);
  font-weight: 500;
}

.widget-content .value {
  color: var(--text-primary);
  font-family: monospace;
}

.widget-content .ok {
  color: var(--success);
}

.widget-content .err {
  color: var(--danger);
}

/* Kanban */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
}

.kanban-column {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  min-height: 200px;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.kanban-column-title {
  font-size: 14px;
  font-weight: 600;
}

.kanban-column-count {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: border-color 0.2s;
}

.kanban-card:hover {
  border-color: var(--accent);
}

.kanban-card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.kanban-card-module {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

.kanban-card-id {
  font-family: monospace;
  opacity: 0.6;
}

.kanban-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Колонки Kanban — цветные акценты слева */
.kanban-column[data-col="ideas"] {
  border-left: 3px solid var(--ideas);
}

.kanban-column[data-col="todo"] {
  border-left: 3px solid var(--todo);
}

.kanban-column[data-col="in_progress"] {
  border-left: 3px solid var(--in-progress);
}

.kanban-column[data-col="done"] {
  border-left: 3px solid var(--done);
}

/* Detail cards (для раздела Stats) */
.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.detail-card.or-card {
  border-left: 3px solid var(--accent);
}

.detail-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-icon {
  font-size: 22px;
}

.detail-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.or-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-secondary);
}

.or-status.ok {
  background: var(--success);
  color: white;
}

.detail-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}

.detail-label {
  color: var(--text-secondary);
  min-width: 120px;
  max-width: 120px;
  margin-right: 12px;
  flex-shrink: 0;
}

.detail-row .value {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-primary);
}

.detail-row .ok {
  color: var(--success);
}

.detail-row .err {
  color: var(--danger);
}

.detail-row .or-remaining {
  color: var(--success);
  font-weight: 600;
  font-size: 16px;
}

/* Кнопка "Новая задача" */
.btn-kanban {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  margin-right: 8px;
  transition: background 0.2s;
}

.btn-kanban:hover {
  background: var(--accent-hover);
}

/* Форма новой задачи */
.task-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.task-form h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.task-form input,
.task-form textarea,
.task-form select {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
  font-family: inherit;
}

.task-form input:focus,
.task-form textarea:focus,
.task-form select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Кастомный select — убираем native Windows 95 look */
.task-form select,
.task-actions select,
.task-form-row select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3e%3cpath fill='%238b8fa3' d='M2 4l4 4 4-4z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px !important;
  cursor: pointer;
}

.task-form select::-ms-expand,
.task-actions select::-ms-expand {
  display: none;
}

.task-form textarea {
  resize: vertical;
  min-height: 60px;
}

.task-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.task-form-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--text-secondary);
}

.task-form-row select {
  margin-top: 4px;
  margin-bottom: 0;
}

.task-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.task-form-actions .btn,
.task-form-actions .btn-secondary {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.task-form-actions .btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.task-form-actions .btn-secondary:hover {
  background: var(--bg-card);
}

/* Модалка задачи */
.task-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.task-modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.task-modal-content h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.task-module {
  background: var(--bg-card);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.task-id {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-secondary);
}

.task-description {
  background: var(--bg-card);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
}

.task-field {
  margin-bottom: 14px;
}

.task-field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.task-field input,
.task-field textarea,
.task-field select,
.task-actions label {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 0;
}

.task-field input:focus,
.task-field textarea:focus,
.task-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.task-field select,
.task-actions select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3e%3cpath fill='%238b8fa3' d='M2 4l4 4 4-4z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
  cursor: pointer;
}

.task-actions label {
  margin-bottom: 12px;
}

.task-actions select {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}

.task-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-right: auto;
}

.btn-danger:hover {
  background: #d32f2f;
}

/* Кнопки */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border);
}

/* Спиннер */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Refresh button */
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.refresh-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.refresh-btn:hover {
  border-color: var(--accent);
}