/* =====================
   CSS CUSTOM PROPERTIES
   ===================== */
:root {
  /* Surface scale */
  --bg-base:        #111213;
  --bg-surface:     #18191b;
  --bg-elevated:    #1f2022;
  --bg-hover:       #26282b;
  --bg-active:      #2d3035;

  /* Border */
  --border-subtle:  #25272a;
  --border-default: #2e3035;
  --border-strong:  #3c3f45;

  /* Text */
  --text-primary:   #d8dade;
  --text-secondary: #8a8f99;
  --text-muted:     #555a63;
  --text-inverted:  #111213;

  /* Accent */
  --accent:         #4a9eff;
  --accent-dim:     #1a3a5c;

  /* Status colors */
  --status-idea:        #6c7a8f;
  --status-idea-bg:     #1a1e24;
  --status-researching: #8b7ccc;
  --status-researching-bg: #1e1a2e;
  --status-building:    #4a9eff;
  --status-building-bg: #0f1e30;
  --status-paused:      #b8922a;
  --status-paused-bg:   #251e0f;
  --status-archived:    #4a4e55;
  --status-archived-bg: #161718;

  /* Priority colors */
  --priority-critical: #e05252;
  --priority-high:     #e07c30;
  --priority-medium:   #c8b440;
  --priority-low:      #5a9a6a;

  /* Complexity */
  --complexity-low:    #5a9a6a;
  --complexity-medium: #c8b440;
  --complexity-high:   #e07c30;

  /* Spacing scale (8px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans:  'DM Sans', 'Helvetica Neue', Arial, sans-serif;

  /* Radius */
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  10px;

  /* Topbar height */
  --topbar-h:   56px;

  /* Sidebar width */
  --sidebar-w:  220px;

  /* Transition */
  --transition: 120ms ease;
}

/* =====================
   RESET & BASE
   ===================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

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

input, select, textarea {
  font-family: inherit;
}

/* =====================
   TOPBAR
   ===================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  z-index: 100;
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  user-select: none;
}

.topbar__wordmark {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-primary);
}

.topbar__slash {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.topbar__subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.topbar__controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Search */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--sp-3);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 34px;
  color: var(--text-primary);
  font-size: 13px;
  width: 240px;
  outline: none;
  transition: border-color var(--transition);
}

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

.search-input:focus {
  border-color: var(--accent);
}

/* Add button */
.btn-add {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background-color: var(--accent);
  color: var(--text-inverted);
  font-size: 13px;
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  transition: opacity var(--transition);
  white-space: nowrap;
}

.btn-add:hover {
  opacity: 0.88;
}

.btn-add svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* =====================
   LAYOUT SHELL
   ===================== */
.layout {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

/* =====================
   SIDEBAR
   ===================== */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: var(--sp-5) 0 var(--sp-10);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-active) transparent;
}

.sidebar__section {
  padding: var(--sp-3) var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar__section:last-child {
  border-bottom: none;
}

.sidebar__heading {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.filter-btn {
  text-align: left;
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition), color var(--transition);
  line-height: 1.6;
}

.filter-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background-color: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}

/* =====================
   MAIN CONTENT
   ===================== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: var(--sp-6) var(--sp-8);
  min-width: 0;
}

/* Results bar */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.results-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.clear-filters-btn {
  font-size: 11px;
  color: var(--text-muted);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
}

.clear-filters-btn:hover {
  color: var(--text-secondary);
  background-color: var(--bg-hover);
}

/* =====================
   PROJECT GRID
   ===================== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}

/* =====================
   PROJECT CARD
   ===================== */
.project-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  transition: border-color var(--transition), background-color var(--transition);
  cursor: default;
}

.project-card:hover {
  background-color: var(--bg-elevated);
  border-color: var(--border-default);
}

/* Card header */
.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}

.card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Card description */
.card__description {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.65;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 1;
}

/* Card badges row */
.card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  align-items: center;
}

/* Generic badge */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Domain badge */
.badge--domain {
  background-color: var(--bg-active);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Status badges */
.badge--status-idea          { background-color: var(--status-idea-bg);        color: var(--status-idea);        border: 1px solid transparent; }
.badge--status-researching   { background-color: var(--status-researching-bg); color: var(--status-researching); border: 1px solid transparent; }
.badge--status-building      { background-color: var(--status-building-bg);    color: var(--status-building);    border: 1px solid transparent; }
.badge--status-paused        { background-color: var(--status-paused-bg);      color: var(--status-paused);      border: 1px solid transparent; }
.badge--status-archived      { background-color: var(--status-archived-bg);    color: var(--status-archived);    border: 1px solid transparent; }

/* Priority dot + label */
.priority-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

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

.priority-dot--critical { background-color: var(--priority-critical); }
.priority-dot--high     { background-color: var(--priority-high); }
.priority-dot--medium   { background-color: var(--priority-medium); }
.priority-dot--low      { background-color: var(--priority-low); }

/* Complexity badge */
.badge--complexity-low    { background-color: transparent; color: var(--complexity-low);    font-family: var(--font-mono); font-size: 10px; padding: 0; }
.badge--complexity-medium { background-color: transparent; color: var(--complexity-medium); font-family: var(--font-mono); font-size: 10px; padding: 0; }
.badge--complexity-high   { background-color: transparent; color: var(--complexity-high);   font-family: var(--font-mono); font-size: 10px; padding: 0; }

/* Card footer */
.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
  gap: var(--sp-3);
}

.card__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 1;
  min-width: 0;
}

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

.card__actions {
  display: flex;
  gap: var(--sp-1);
}

.card__action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background-color var(--transition), color var(--transition);
}

.card__action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-secondary);
}

.card__action-btn svg {
  width: 13px;
  height: 13px;
}

/* =====================
   EMPTY STATE
   ===================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
  gap: var(--sp-3);
}

.empty-state__icon {
  font-size: 40px;
  color: var(--text-muted);
  line-height: 1;
  margin-bottom: var(--sp-2);
}

.empty-state__heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state__body {
  font-size: 13px;
  color: var(--text-muted);
}

/* =====================
   MODAL
   ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 11, 12, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--sp-4);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}

.modal__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background-color var(--transition), color var(--transition);
}

.modal__close:hover {
  background-color: var(--bg-hover);
  color: var(--text-secondary);
}

.modal__close svg {
  width: 13px;
  height: 13px;
}

.modal__body {
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
}

/* Form fields */
.field-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.field-input {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

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

.field-input:focus {
  border-color: var(--accent);
}

.field-textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
}

.field-select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23555a63' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 30px;
}

.field-select option {
  background-color: var(--bg-elevated);
}

/* Modal buttons */
.btn-ghost {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  transition: background-color var(--transition), color var(--transition);
}

.btn-ghost:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-primary {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-inverted);
  background-color: var(--accent);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--radius-md);
  transition: opacity var(--transition);
}

.btn-primary:hover {
  opacity: 0.88;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 180px;
  }

  .main {
    padding: var(--sp-4) var(--sp-5);
  }

  .project-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (max-width: 680px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--sp-3) 0;
    max-height: 240px;
    display: flex;
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar__section {
    flex-shrink: 0;
    border-bottom: none;
    border-right: 1px solid var(--border-subtle);
  }

  .filter-group {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  .main {
    margin-left: 0;
    padding: var(--sp-4);
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .search-input {
    width: 160px;
  }
}
