/* ══════════════════════════════════════════════════════════════
   Roadmap Manager – Styles
   A calm, clear visual language for desktop and mobile.
   ══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0b1220;
  --bg-secondary: #111a2e;
  --bg-card: #182035;
  --bg-card-hover: #1e2845;
  --bg-input: #141d2f;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --text-primary: #e6ebf5;
  --text-secondary: #9aa7c7;
  --text-muted: #6b7a99;

  --border-color: #1e2d4a;
  --border-light: #263555;

  --sidebar-width: 260px;

  /* Stage colors */
  --stage-idea: #4dd0e1;
  --stage-planned: #64b5f6;
  --stage-in-development: #ffd54f;
  --stage-ready-for-production: #ffb74d;
  --stage-released: #81c784;

  /* Category colors */
  --cat-feature: #7c4dff;
  --cat-improvement: #00bfa5;
  --cat-bugfix: #ff5252;
  --cat-infrastructure: #ff6e40;
  --cat-research: #448aff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --transition: 0.2s ease;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
}

/* ── Layout Shell ─────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: transform var(--transition);
  z-index: 100;
}

.sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

#new-project-btn {
  width: 100%;
  padding: 9px 14px;
  background: rgba(100, 181, 246, 0.12);
  color: var(--stage-planned);
  border: 1px dashed rgba(100, 181, 246, 0.35);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
}
#new-project-btn:hover {
  background: rgba(100, 181, 246, 0.2);
  border-color: rgba(100, 181, 246, 0.5);
}

#project-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 2px;
  min-height: 44px;
}
.project-item:hover {
  background: var(--bg-card);
}
.project-item.active {
  background: var(--bg-card-hover);
}

.project-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

.project-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.project-item:hover .project-actions,
.project-item.active .project-actions {
  opacity: 1;
}
/* Always visible on touch */
@media (hover: none) {
  .project-actions { opacity: 1; }
  .project-action-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
}

.project-action-btn {
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.project-action-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* ── Mobile hamburger ─────────────────────────────────────────── */
#menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.3rem;
  align-items: center;
  justify-content: center;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 90;
}

/* ── Main Area ────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Empty State ──────────────────────────────────────────────── */
#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px 20px;
}
#empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.7;
}
#empty-state h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 8px;
}
#empty-state p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 360px;
}
#empty-state .empty-action {
  margin-top: 24px;
  padding: 10px 24px;
  background: var(--stage-planned);
  color: var(--bg-primary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: opacity var(--transition);
}
#empty-state .empty-action:hover {
  opacity: 0.85;
}

/* ── Board Header ─────────────────────────────────────────────── */
.board-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.board-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.board-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-header-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.board-stats {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.stat-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
}

/* ── Quick Idea Bar ───────────────────────────────────────────── */
.quick-add-bar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  gap: 8px;
}

.quick-add-bar input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.quick-add-bar input::placeholder {
  color: var(--text-muted);
}
.quick-add-bar input:focus {
  border-color: var(--stage-idea);
}

.quick-add-bar button {
  padding: 10px 18px;
  background: var(--stage-idea);
  color: var(--bg-primary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  white-space: nowrap;
  transition: opacity var(--transition);
}
.quick-add-bar button:hover {
  opacity: 0.85;
}

/* ── Board ────────────────────────────────────────────────────── */
#board {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.board-column {
  min-width: 250px;
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-height: 100%;
  overflow: hidden;
}

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

.column-indicator {
  width: 4px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
}

.column-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  flex: 1;
}

.column-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 7px;
  border-radius: 10px;
}

.column-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Drop zone highlight */
.column-body.drag-over {
  background: rgba(100, 181, 246, 0.06);
  outline: 2px dashed rgba(100, 181, 246, 0.3);
  outline-offset: -4px;
  border-radius: var(--radius-sm);
}

/* ── Item Card ────────────────────────────────────────────────── */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
  min-height: 44px;
}
.item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}
.item-card:active {
  transform: scale(0.98);
}
.item-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.item-category-stripe {
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
}

.item-title {
  font-size: 0.88rem;
  font-weight: 500;
  margin-left: 6px;
  line-height: 1.4;
  word-break: break-word;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  margin-left: 6px;
}

.item-category-tag {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  color: var(--bg-primary);
}

.item-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Item card move buttons (for touch / accessibility) */
.item-move-actions {
  display: none;
  gap: 3px;
  margin-top: 8px;
  margin-left: 6px;
  flex-wrap: wrap;
}
.item-card.show-actions .item-move-actions {
  display: flex;
}

.item-move-btn {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  min-height: 28px;
  transition: background var(--transition), color var(--transition);
}
.item-move-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ── Modals ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--stage-planned);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239aa7c7' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.color-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.color-option:hover {
  transform: scale(1.1);
}
.color-option.selected {
  border-color: var(--text-primary);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-primary {
  padding: 9px 20px;
  background: var(--stage-planned);
  color: var(--bg-primary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  transition: opacity var(--transition);
}
.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  padding: 9px 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  transition: background var(--transition);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  padding: 9px 20px;
  background: rgba(255, 82, 82, 0.15);
  color: #ff5252;
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 500;
  transition: background var(--transition);
}
.btn-danger:hover {
  background: rgba(255, 82, 82, 0.25);
}

/* ── Confirm Dialog ───────────────────────────────────────────── */
.confirm-body {
  text-align: center;
  padding: 30px 20px;
}
.confirm-body p {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 0.92rem;
}
.confirm-body .confirm-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ── Mobile Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  html { font-size: 14px; }

  #menu-toggle {
    display: flex;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-overlay.visible {
    display: block;
  }

  #main {
    width: 100vw;
  }

  .board-header {
    padding: 56px 16px 12px;
  }

  .quick-add-bar {
    padding: 10px 16px;
  }

  #board {
    padding: 10px;
    gap: 10px;
  }

  .board-column {
    min-width: 230px;
    width: 230px;
  }

  /* Always show move actions on mobile */
  .item-card .item-move-actions {
    display: flex;
  }

  /* Bump move button touch target to 44px on mobile */
  .item-move-btn {
    min-height: 44px;
    padding: 10px 12px;
  }

  .modal {
    max-width: 100%;
    margin: 10px;
    border-radius: var(--radius-md);
  }

  .modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }
}

@media (max-width: 480px) {
  .board-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .board-stats {
    flex-wrap: wrap;
  }

  .board-column {
    min-width: 200px;
    width: 200px;
  }
}

/* ── Print (hide for print) ───────────────────────────────────── */
@media print {
  #sidebar, #menu-toggle, .quick-add-bar, .modal-overlay {
    display: none !important;
  }
  #main { width: 100% !important; }
  body { overflow: visible; height: auto; }
  #board { overflow: visible; flex-wrap: wrap; }
}

/* ── Access Gate ──────────────────────────────────────────────── */

/* Visually hide content while keeping it accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gate-overlay.gate-hidden {
  display: none;
}

.gate-box {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.gate-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.gate-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.gate-input::placeholder {
  color: var(--text-muted);
}

.gate-input:focus {
  border-color: var(--stage-planned);
}

.gate-btn {
  width: 100%;
  padding: 11px;
  background: var(--stage-planned);
  color: var(--bg-primary);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition);
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

.gate-btn:hover {
  opacity: 0.85;
}

.gate-error {
  font-size: 0.85rem;
  color: #ff5252;
  text-align: center;
  min-height: 1.2em;
}

.gate-error.hidden {
  visibility: hidden;
}

@media (max-width: 480px) {
  .gate-box {
    gap: 16px;
  }

  .gate-title {
    font-size: 1.1rem;
  }
}
