/* ══════════════════════════════════════
   HAVEN — components.css
   Sections, Papers, Tables, Modals
   ══════════════════════════════════════ */

/* ── DETAIL SECTION ── */
.d-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.d-section:hover { box-shadow: var(--shadow); }
.d-section.drag-active { opacity: .5; box-shadow: var(--shadow-md); }

.d-section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.d-section-title {
  font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}

.d-section-add {
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; color: var(--accent);
  padding: 3px 10px; font-size: 12px; font-weight: 600;
  transition: all .12s;
}
.d-section-add:hover { background: var(--accent-bg); border-color: var(--accent); }

/* ── EMPTY STATE ── */
.d-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 60px 20px; text-align: center;
}
.d-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.d-empty-title { font-size: 15px; color: var(--muted); font-weight: 500; }

/* ── CODE BLOCK ── */
.code-block {
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.7;
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px; margin: 12px 16px;
  color: #3730a3; white-space: pre-wrap;
  word-break: break-word;
  transition: background .15s;
}
.code-block:hover { background: #f0f1f8; }

/* ── PAPER CARDS ── */
.paper-list { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.paper-empty {
  text-align: center; padding: 20px;
  color: var(--muted); font-size: 12.5px; font-style: italic;
}

.paper-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
  position: relative;
}
.paper-card:hover { box-shadow: var(--shadow); border-color: var(--border2); }
.paper-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 3px 0 0 3px;
}
.paper-card.priority-green::before { background: var(--green); }
.paper-card.priority-yellow::before { background: var(--yellow); }
.paper-card.priority-red::before { background: var(--red); }

.paper-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 14px 12px 16px; gap: 10px;
}

.paper-card-meta { flex: 1; min-width: 0; }

.paper-card-title {
  font-weight: 600; font-size: 13.5px;
  color: var(--text); line-height: 1.4;
}

.paper-card-notes {
  font-size: 12px; color: var(--muted);
  margin-top: 4px; line-height: 1.5;
  font-style: italic;
}

.paper-card-actions {
  display: flex; gap: 4px; flex-shrink: 0; padding-top: 2px;
  opacity: 0; transition: opacity .15s;
}
.paper-card:hover .paper-card-actions { opacity: 1; }

.paper-card-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 3px 8px; border-radius: 5px;
  border: 1px solid var(--accent-bg);
  background: var(--accent-bg);
  transition: all .12s;
}
.paper-card-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

.paper-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500;
  padding: 3px 8px; border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2); transition: all .12s;
}
.paper-tag:hover { background: var(--surface3); }

/* ── TABLE CARDS ── */
.table-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 10px 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.table-card-title {
  font-weight: 600; font-size: 13px; color: var(--text);
  outline: none; border-radius: 4px; padding: 2px 4px;
  transition: background .12s;
}
.table-card-title:focus { background: var(--surface3); }

.table-actions { display: flex; gap: 5px; }

.tbl-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 9px;
  font-size: 12px; font-weight: 600; color: var(--text2);
  transition: all .12s;
}
.tbl-btn:hover { background: var(--surface3); border-color: var(--border2); color: var(--text); }
.tbl-btn.danger { color: var(--red); }
.tbl-btn.danger:hover { background: var(--red-bg); border-color: var(--red); }

.table-body { overflow-x: auto; }

.edit-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.edit-table th {
  background: var(--surface2);
  padding: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  font-weight: 600;
}
.edit-table th:last-child { border-right: none; }
.edit-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.edit-table td:last-child { border-right: none; }
.edit-table tr:last-child td { border-bottom: none; }
.edit-table tr:hover td { background: var(--surface2); }

.th-input {
  width: 100%; background: transparent; border: none; outline: none;
  padding: 8px 10px; font-weight: 600; font-size: 12px;
  color: var(--text2); font-family: var(--font);
}
.th-input:focus { background: var(--accent-bg); color: var(--accent-text); }

.cell-input {
  width: 100%; background: transparent; border: none; outline: none;
  padding: 7px 10px; color: var(--text);
  font-family: var(--font); font-size: 12.5px;
}
.cell-input:focus { background: var(--accent-bg); }

.del-col-btn, .del-row-btn {
  background: transparent; border: none;
  color: var(--muted); font-size: 11px; cursor: pointer;
  width: 20px; height: 20px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s, background .12s;
}
.edit-table th:hover .del-col-btn,
.edit-table tr:hover .del-row-btn { opacity: 1; }
.del-col-btn:hover, .del-row-btn:hover {
  background: var(--red-bg); color: var(--red);
}

.table-footer {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* ── MEDIA GRID ── */
.d-media-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; padding: 12px 14px;
}
.d-media-item {
  position: relative; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  aspect-ratio: 16/9;
}
.d-media-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-media-video { width: 100%; height: 100%; display: block; }
.d-media-yt { width: 100%; height: 100%; border: none; display: block; }
.media-del-btn {
  position: absolute; top: 5px; right: 5px;
  background: rgba(0,0,0,.6); color: #fff;
  border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.d-media-item:hover .media-del-btn { opacity: 1; }

/* ── MODALS ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.visible { opacity: 1; pointer-events: all; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 520px; width: 94vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.modal-backdrop.visible .modal-box {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: 16px; font-weight: 700;
  color: var(--text); margin-bottom: 18px;
  letter-spacing: -.3px;
}

.modal-label {
  display: block; font-size: 11.5px;
  font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 5px; margin-top: 14px;
}
.modal-label:first-of-type { margin-top: 0; }

.modal-input {
  width: 100%; background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px; color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: var(--font); margin-bottom: 2px;
  resize: vertical;
}
.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  background: var(--surface);
}

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

.modal-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 16px;
  font-weight: 600; font-size: 13px; color: var(--text2);
  transition: all .15s;
}
.modal-btn:hover { background: var(--surface3); border-color: var(--border2); color: var(--text); }
.modal-btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.modal-btn.primary:hover { opacity: .9; }
