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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a2332;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, #0d2137 0%, #1b4f7a 100%);
  color: white;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; }
.logo-text { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.logo-sub {
  font-size: 12px;
  opacity: .65;
  border-left: 1px solid rgba(255,255,255,.3);
  padding-left: 12px;
  margin-left: 4px;
}

/* ─── Tabs ───────────────────────────────────────────────────────────── */
.tab-nav {
  background: #fff;
  border-bottom: 2px solid #dde3ec;
  display: flex;
  gap: 0;
  padding: 0 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 16px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #5a6a7e;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-btn:hover { color: #1b4f7a; background: #f4f7fb; }
.tab-btn.active { color: #1b4f7a; border-bottom-color: #1b4f7a; font-weight: 600; }
.tab-icon { font-size: 16px; }

/* ─── Main content areas ─────────────────────────────────────────────── */
.tab-content { display: none; max-width: 1400px; margin: 0 auto; padding: 28px 24px; }
.tab-content.active { display: block; }

.page-intro { margin-bottom: 24px; }
.page-intro h2 { font-size: 20px; font-weight: 700; color: #0d2137; margin-bottom: 6px; }
.page-intro p { color: #5a6a7e; font-size: 14px; }

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 22px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #0d2137;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf0f5;
}
.card-hint { font-size: 13px; color: #7a8a9e; margin-bottom: 16px; }

/* ─── Specialty grid (templates tab) ─────────────────────────────────── */
.specialty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.specialty-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow: hidden;
  border: 1px solid #e4e9f0;
}
.specialty-header {
  background: linear-gradient(135deg, #1b4f7a, #2471a3);
  color: white;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.specialty-name { font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.file-count {
  background: rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #b8c8d8;
  border-radius: 8px;
  padding: 20px;
  margin: 12px 14px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #f8fafc;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: #1b4f7a;
  background: #eef4fb;
}
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.drop-text { font-size: 13px; color: #5a6a7e; }
.drop-text strong { color: #1b4f7a; }
.drop-ext { font-size: 11px; color: #98a8b8; margin-top: 4px; }

/* File list */
.file-list { padding: 0 14px 14px; }
.file-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  transition: background .15s;
  border-bottom: 1px solid #f0f2f5;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: #f4f7fb; }
.file-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 12px; font-weight: 600; color: #1a2332; word-break: break-all; }
.file-desc { font-size: 11px; color: #7a8a9e; margin-top: 2px; }
.file-tipo-badge {
  background: #e8f0fe;
  color: #1b4f7a;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: #c0cad5;
  font-size: 16px;
  padding: 2px;
  transition: color .15s;
  flex-shrink: 0;
}
.btn-delete:hover { color: #e74c3c; }
.file-list-empty { padding: 12px 14px; font-size: 12px; color: #aab8c8; text-align: center; }

/* ─── Project form layout ─────────────────────────────────────────────── */
.project-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .project-layout { grid-template-columns: 1fr; }
  .sticky-card { position: static !important; }
}
.sticky-card { position: sticky; top: 20px; }

/* Form elements */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: #3a4a5e; }
.form-group label small { font-weight: 400; color: #8a9ab0; }
.form-group input[type=text],
.form-group input[type=number] {
  border: 1.5px solid #d4dce8;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  transition: border .2s;
  outline: none;
  background: #fafbfd;
}
.form-group input:focus { border-color: #1b4f7a; background: #fff; }

/* Fase radio cards */
.fase-options { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  border: 2px solid #d4dce8;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  min-width: 80px;
  text-align: center;
}
.radio-card input { display: none; }
.radio-card span { font-size: 16px; font-weight: 700; color: #1a2332; }
.radio-card small { font-size: 10px; color: #8a9ab0; }
.radio-card:has(input:checked) {
  border-color: #1b4f7a;
  background: #eef4fb;
}
.radio-card:has(input:checked) span { color: #1b4f7a; }

/* Template selector */
.specialty-section { margin-bottom: 12px; border: 1px solid #e4e9f0; border-radius: 8px; overflow: hidden; }
.specialty-section-header {
  background: #f4f7fb;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #0d2137;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.specialty-section-header:hover { background: #edf2f9; }
.section-badge {
  background: #1b4f7a;
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}
.section-badge.zero { background: #c8d0da; color: #5a6a7e; }
.specialty-section-body { padding: 6px 12px 12px; display: none; }
.specialty-section-body.open { display: block; }

.tmpl-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid #f0f2f5;
}
.tmpl-row:last-child { border-bottom: none; }
.tmpl-checkbox { margin-top: 3px; accent-color: #1b4f7a; width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.tmpl-label { flex: 1; min-width: 0; }
.tmpl-name { font-size: 12px; font-weight: 600; color: #1a2332; }
.tmpl-original { font-size: 11px; color: #8a9ab0; word-break: break-all; }
.tmpl-fields {
  display: none;
  grid-template-columns: 80px 80px 1fr;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #dde3ec;
}
.tmpl-fields.visible { display: grid; }
.tmpl-fields label { font-size: 11px; color: #5a6a7e; font-weight: 600; display: block; margin-bottom: 3px; }
.tmpl-fields input {
  border: 1.5px solid #d4dce8;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  width: 100%;
  outline: none;
}
.tmpl-fields input:focus { border-color: #1b4f7a; }

/* Generate button */
.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, #1b7a3f, #27ae60);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 12px rgba(39,174,96,.3);
  letter-spacing: .3px;
}
.btn-generate:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(39,174,96,.4); }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { background: #c0cad5; box-shadow: none; transform: none; cursor: not-allowed; }

/* ─── Folder tree preview ─────────────────────────────────────────────── */
.tree { font-family: "Courier New", monospace; font-size: 12.5px; line-height: 1.8; color: #3a4a5e; }
.tree-empty { font-family: sans-serif; font-size: 13px; color: #aab8c8; text-align: center; padding: 20px 0; }
.tree-root { font-weight: 700; color: #0d2137; font-size: 13px; }
.tree-specialty { color: #1b4f7a; font-weight: 600; }
.tree-file { color: #4a6a8a; }
.tree-file.new { color: #27ae60; }

/* ─── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #1a2332;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  opacity: 0;
  transform: translateY(10px);
  transition: all .3s;
  z-index: 1000;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #1b7a3f; }
.toast.error { background: #c0392b; }

/* ─── Loading spinner ────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f0f2f5; }
::-webkit-scrollbar-thumb { background: #c0cad5; border-radius: 3px; }
