/* ══════════════════════════════════════════════════════
   Blue Cascade — Estilos globales
   ══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #1A56DB;
  --blue-dark:  #1142A8;
  --blue-light: #EBF2FF;
  --green:      #057A55;
  --green-bg:   #DEF7EC;
  --red:        #C81E1E;
  --red-bg:     #FDE8E8;
  --yellow-bg:  #FEF3C7;
  --yellow:     #92400E;
  --text:       #111928;
  --muted:      #6B7280;
  --border:     #D1D5DB;
  --bg:         #F3F4F6;
  --white:      #FFFFFF;
  --shadow:     0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav ──────────────────────────────────────────────── */
.topnav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.brand         { display: flex; align-items: center; gap: 10px; }
.brand-icon    { width: 34px; height: 34px; background: linear-gradient(135deg, #1A56DB, #3B82F6); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 800; font-size: .9rem; }
.brand-name    { font-weight: 700; font-size: .95rem; letter-spacing: .04em; color: var(--blue); text-transform: uppercase; }
.nav-right     { display: flex; align-items: center; gap: 10px; }
.btn-logout    { color: var(--muted); font-size: .85rem; text-decoration: none; padding: 7px 14px; border-radius: 6px; transition: background .15s; }
.btn-logout:hover { background: var(--bg); }

/* ── Botones ──────────────────────────────────────────── */
.btn-submit {
  background: var(--blue); color: white;
  border: none; border-radius: 8px;
  padding: 12px 28px; font-size: .93rem; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; transition: background .15s;
  text-decoration: none;
}
.btn-submit:hover { background: var(--blue-dark); }

.btn-outline {
  display: inline-block; border: 2px solid var(--blue);
  color: var(--blue); border-radius: 8px;
  padding: 10px 26px; font-size: .9rem; font-weight: 700;
  text-decoration: none; transition: background .15s, color .15s;
}
.btn-outline:hover { background: var(--blue); color: white; }

.btn-primary {
  background: var(--blue); color: white;
  border: none; border-radius: 7px;
  padding: 9px 20px; font-size: .85rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .15s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--blue-dark); }

.btn-green {
  background: var(--green); color: white;
  border: none; border-radius: 7px;
  padding: 9px 20px; font-size: .85rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .15s;
  text-decoration: none;
}
.btn-green:hover { background: #046348; }

.btn-edit {
  background: var(--blue-light); color: var(--blue);
  border: none; border-radius: 5px;
  padding: 5px 12px; font-size: .78rem; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn-edit:hover { background: #C3DAFE; }

.btn-del {
  background: var(--red-bg); color: var(--red);
  border: none; border-radius: 5px;
  padding: 5px 10px; font-size: .78rem; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn-del:hover { background: #FCA5A5; }

/* ── Campos ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block; font-size: .875rem; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}

.field-req label::after { content: ' *'; color: var(--red); }

.field input, .field select, .field textarea,
.mfield input, .mfield select, .mfield textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .93rem; color: var(--text); background: var(--white);
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.field textarea { resize: vertical; min-height: 90px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .row-2 { grid-template-columns: 1fr; } }

/* ── Alertas ──────────────────────────────────────────── */
.alert-error {
  background: var(--red-bg); border: 1px solid #F8B4B4;
  color: var(--red); border-radius: 8px;
  padding: 13px 16px; margin-bottom: 20px; font-size: .875rem;
}
.alert-error ul { margin: 5px 0 0 16px; }

.alert-ok {
  background: var(--green-bg); border: 1px solid #84E1BC;
  color: var(--green); border-radius: 8px;
  padding: 12px 16px; font-size: .875rem;
}

/* ══════════════════════════════════════════════════════
   FORMULARIO PÚBLICO
   ══════════════════════════════════════════════════════ */
.main { flex: 1; padding: 40px 16px 60px; }

.form-wrap { max-width: 640px; margin: 0 auto; }

.form-header { text-align: center; margin-bottom: 28px; }
.form-title  { font-size: 1.75rem; font-weight: 800; margin-bottom: 6px; }
.form-sub    { color: var(--muted); font-size: .92rem; }

.card {
  background: var(--white); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}

.card-section {
  padding: 24px 32px;
  border-bottom: 1px solid #F3F4F6;
}

.card-section:last-of-type { border-bottom: none; }

.section-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--blue);
  margin-bottom: 16px; padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-light);
}

.card-footer {
  padding: 18px 32px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
}

.req-note  { font-size: .78rem; color: var(--muted); }
.req-mark  { color: var(--red); }

@media (max-width: 500px) {
  .card-section { padding: 20px 18px; }
  .card-footer  { padding: 16px 18px; flex-direction: column; gap: 12px; }
  .btn-submit   { width: 100%; justify-content: center; }
}

/* ── Confirmación ─────────────────────────────────────── */
.confirm-wrap {
  max-width: 500px; margin: 60px auto;
  text-align: center;
}

.confirm-icon {
  width: 70px; height: 70px; border-radius: 50%;
  background: var(--green-bg); color: var(--green);
  font-size: 2rem; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 20px;
  animation: pop .35s cubic-bezier(.34,1.56,.64,1);
}

@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.confirm-title { font-size: 1.7rem; font-weight: 800; margin-bottom: 8px; }
.confirm-sub   { color: var(--muted); font-size: .92rem; margin-bottom: 28px; }

.folio-box {
  background: var(--blue-light); border: 2px solid var(--blue);
  border-radius: 12px; padding: 20px 48px;
  display: inline-block; margin-bottom: 24px;
}

.folio-label {
  display: block; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--blue); margin-bottom: 6px;
}

.folio-number { display: block; font-size: 2.4rem; font-weight: 900; color: var(--blue-dark); }

.confirm-note { color: var(--muted); font-size: .875rem; margin-bottom: 28px; }

/* ══════════════════════════════════════════════════════
   ADMIN
   ══════════════════════════════════════════════════════ */
.admin-main  { flex: 1; padding: 32px 24px 60px; max-width: 1100px; margin: 0 auto; width: 100%; }

.admin-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}

.admin-title { font-size: 1.4rem; font-weight: 800; }
.admin-sub   { color: var(--muted); font-size: .85rem; margin-top: 2px; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 22px;
}

.stat-card {
  background: var(--white); border-radius: 10px;
  border: 1px solid var(--border); padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.stat-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-value.blue  { color: var(--blue); }
.stat-value.green { color: var(--green); }

/* Tabla */
.table-wrap {
  background: var(--white); border-radius: 12px;
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
}

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

.table-title { font-weight: 700; font-size: .93rem; }
.table-count { font-size: .82rem; color: var(--muted); }
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

thead th {
  background: #F9FAFB; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 11px 16px;
  border-bottom: 1px solid var(--border); text-align: left;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid #F3F4F6; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAFA; }

td { padding: 12px 16px; vertical-align: middle; }

.td-folio   { font-weight: 700; color: var(--blue); white-space: nowrap; }
.td-proyecto { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-dates   { white-space: nowrap; font-size: .82rem; color: var(--muted); }
.td-actions { white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.badge-nuevo     { background: #E1EFFE; color: #1A56DB; }
.badge-proceso   { background: var(--yellow-bg); color: var(--yellow); }
.badge-revision  { background: #E0F2FE; color: #075985; }
.badge-cumplido  { background: var(--green-bg); color: var(--green); }
.badge-cancelado { background: var(--red-bg); color: var(--red); }

/* Barra de progreso */
.progress-wrap { display: inline-block; width: 70px; height: 6px; background: #E5E7EB; border-radius: 99px; margin-right: 6px; vertical-align: middle; }
.progress-bar  { height: 6px; border-radius: 99px; background: var(--blue); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon  { font-size: 2.5rem; margin-bottom: 12px; }

/* ── Edición ──────────────────────────────────────────── */
.edit-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 800px) { .edit-grid { grid-template-columns: 1fr; } }

.card-panel {
  background: var(--white); border-radius: 12px;
  border: 1px solid var(--border); padding: 22px 24px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--blue);
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-light);
}

.readonly-list dt {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-top: 10px;
}

.readonly-list dt:first-child { margin-top: 0; }
.readonly-list dd { color: var(--text); margin: 2px 0 0; font-size: .88rem; line-height: 1.4; }

/* ══════════════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════════════ */
.login-body { background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }

.login-wrap  { width: 100%; max-width: 400px; }

.login-card  {
  background: var(--white); border-radius: 14px;
  box-shadow: var(--shadow); padding: 36px 32px;
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-title  { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.login-sub    { color: var(--muted); font-size: .88rem; }

/* ══════════════════════════════════════════════════════
   Footer
   ══════════════════════════════════════════════════════ */
.page-footer {
  text-align: center; padding: 20px 16px;
  font-size: .8rem; color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--white); margin-top: auto;
}

.page-footer a { color: var(--blue); text-decoration: none; }
.page-footer p + p { margin-top: 4px; }
