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

/* === TMPED Design Language === */
:root {
  --navy:        #0d2233;
  --navy-mid:    #122b42;
  --blue:        #1e3d78;
  --teal:        #2ab4b4;
  --green:       #3ecf8e;
  --green-dim:   #2fa870;
  --amber:       #e8a020;
  --amber-dim:   #c4861a;
  --amber-bg:    #fff8ed;
  --teal-bg:     #edfafa;
  --white:       #ffffff;
  --off-white:   #f4f7fa;
  --text:        #1a2e40;
  --text-muted:  #5a7184;
  --border:      #d6e4ef;
  --shadow-sm:   0 2px 8px rgba(13,34,51,0.08);
  --shadow-md:   0 6px 24px rgba(13,34,51,0.13);
  --radius:      10px;
  --radius-sm:   6px;
  --transition:  0.2s ease;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', sans-serif;
  --error:       #e05c5c;

  --sidebar-w: 360px;
  --header-h: 64px;
  --footer-h: 40px;

  /* Status colors */
  --status-not-started: #5a7184;
  --status-in-progress: #2ab4b4;
  --status-complete:    #3ecf8e;
  --status-parking-lot: #e8a020;
  --status-canceled:    #e05c5c;
}

body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* === Header === */
#top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--navy);
  border-bottom: 3px solid var(--teal);
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--white);
}

/* === Footer === */
#bottom-footer {
  height: var(--footer-h);
  background: var(--navy);
  color: rgba(255,255,255,0.35);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

#bottom-footer .version {
  color: rgba(255,255,255,0.4);
}

/* === App Layout === */
#app {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--footer-h));
}

/* === Sidebar === */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

#search {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--off-white);
  outline: none;
  margin-bottom: 8px;
  transition: border-color var(--transition), background var(--transition);
}

#search:focus {
  border-color: var(--teal);
  background: var(--white);
}

#status-filter {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--off-white);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

#status-filter:focus {
  border-color: var(--teal);
}

/* === Pain Point List === */
#pain-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

#pain-list li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: background var(--transition);
}

#pain-list li:hover {
  background: var(--teal-bg);
}

#pain-list li.active {
  background: var(--teal-bg);
  border-left: 3px solid var(--teal);
  padding-left: 13px;
}

.list-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 32px;
  flex-shrink: 0;
}

.list-info {
  flex: 1;
  min-width: 0;
}

.list-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
  color: var(--white);
}

.status-not-started  { background: var(--status-not-started); }
.status-in-progress  { background: var(--status-in-progress); }
.status-complete     { background: var(--status-complete); }
.status-parking-lot  { background: var(--status-parking-lot); }
.status-canceled     { background: var(--status-canceled); }

/* === Detail Panel === */
main#detail {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

#empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 16px;
}

#detail-content.hidden { display: none; }

#detail-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 20px;
  line-height: 1.3;
  color: var(--navy);
}

.back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--teal);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 16px;
  font-family: var(--font-body);
}

/* === Info Grid (read-only fields) === */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 24px;
  margin-bottom: 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 4px solid var(--green);
  border-radius: var(--radius);
  padding: 16px 24px;
  box-shadow: var(--shadow-sm);
}

.info-item label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin-bottom: 0;
  line-height: 1.2;
}

.info-item span {
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
}

.info-item a {
  color: var(--teal);
  text-decoration: none;
}

.info-item a:hover {
  text-decoration: underline;
}

/* === Section Divider === */
.field-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0 24px;
}

.field-divider::before,
.field-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.field-divider span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* === Edit Form === */
.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 0;
}

.form-row .form-group { flex: 1; }

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group select,
.form-group input[type="date"] {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--off-white);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--off-white);
  resize: vertical;
  outline: none;
  line-height: 1.6;
  transition: border-color var(--transition), background var(--transition);
}

.form-group textarea:focus,
.form-group select:focus,
.form-group input:focus {
  border-color: var(--teal);
  background: var(--white);
}

/* Notes field — spacious and comfortable */
.notes-field {
  min-height: 240px;
  font-size: 15px;
  line-height: 1.7;
  padding: 16px 18px;
}

/* Extracted links below textareas */
.extracted-links {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.6;
}

.extracted-links a {
  color: var(--teal);
  text-decoration: none;
  word-break: break-all;
}

.extracted-links a:hover {
  text-decoration: underline;
}

.extracted-links a::before {
  content: '\2197\00a0';
  font-size: 10px;
}

/* === Form Actions === */
.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

#save-btn {
  padding: 10px 28px;
  background: var(--green);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--transition);
}

#save-btn:hover { background: var(--green-dim); }
#save-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

#save-status {
  font-size: 13px;
  color: var(--text-muted);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  z-index: 1000;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.toast.success { background: var(--green-dim); }
.toast.error { background: var(--error); }

/* === Loading / Empty / Spinner === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* === Animations === */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

#detail-content:not(.hidden) {
  animation: fadeSlideIn 0.4s ease;
}

/* === Mobile === */
@media (max-width: 768px) {
  #app { flex-direction: column; }

  #sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: calc(100vh - var(--header-h) - var(--footer-h));
  }

  #sidebar.sidebar-hidden { display: none; }

  main#detail { padding: 20px 16px; }
  main#detail.detail-hidden { display: none; }

  .back-btn { display: block; }

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

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
