/* ==========================================================================
   PURIAN · Mi PURIAN (se carga después de app.css y reutiliza sus tokens)
   ========================================================================== */

@layer sections {
  .portal-body { background: var(--ivory); }

  /* ── Barra superior ── */
  .p-top { background: var(--navy-950); color: var(--ivory); position: sticky; top: 0; z-index: 30; }
  .p-top__row { display: flex; align-items: center; gap: 1.5rem; height: 68px; }
  .p-top .brand__name { font-size: 1.35rem; }
  .p-top__label { font-size: var(--fs-xs); letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-400); border-left: 1px solid var(--line-dark); padding-left: 1rem; }
  .p-user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; font-size: var(--fs-sm);
    & a { text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem; }
    & button { background: none; border: 1px solid var(--line-dark); color: inherit; border-radius: 999px; padding: 0.45rem 0.9rem; cursor: pointer; display: inline-flex; gap: 0.4rem; align-items: center; font-size: var(--fs-xs);
      &:hover { border-color: var(--gold-500); color: var(--gold-300); }
    }
  }
  .p-user__name { display: none; @media (min-width: 720px) { display: inline; } }
  .p-nav { border-top: 1px solid var(--line-dark); }
  .p-nav ul { list-style: none; padding: 0; display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
  .p-nav a {
    display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.85rem 0.9rem; white-space: nowrap; font-size: var(--fs-sm);
    text-decoration: none; color: rgb(247 244 238 / 0.65); border-bottom: 2px solid transparent;
    &:hover { color: #fff; }
    &[aria-current="page"] { color: var(--gold-300); border-bottom-color: var(--gold-500); }
  }

  .p-main { padding-block: clamp(1.75rem, 1rem + 3vw, 3rem) 5rem; }
  .p-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.75rem;
    & h1 { font-size: var(--fs-2xl); }
    & p { color: var(--ink-3); margin-top: 0.35rem; }
    & .back { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--fs-xs); color: var(--ink-3); text-decoration: none; margin-bottom: 0.6rem; letter-spacing: 0.04em; &:hover { color: var(--gold-600); } }
  }

  /* ── Tarjetas y bloques ── */
  .p-card { background: var(--white); border: 1px solid var(--line-light); border-radius: var(--radius-lg); padding: clamp(1.25rem, 1rem + 1vw, 1.75rem); min-width: 0;
    & > h2 { font-family: var(--font-sans); font-size: var(--fs-base); font-weight: 600; margin-bottom: 1rem; }
  }
  .p-card__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem;
    & h2 { font-family: var(--font-sans); font-size: var(--fs-base); font-weight: 600; }
    & a { font-size: var(--fs-sm); color: var(--gold-600); text-decoration: none; font-weight: 550; }
  }
  .p-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
  .p-grid--main { @media (min-width: 1000px) { grid-template-columns: 2fr 1fr; } }
  .p-stack { display: grid; gap: 1.25rem; align-content: start; }

  .p-welcome {
    position: relative; overflow: hidden; border-radius: var(--radius-lg); color: var(--ivory);
    background: radial-gradient(120% 140% at 90% 0%, var(--navy-700), var(--navy-950) 60%);
    padding: clamp(1.5rem, 1rem + 2vw, 2.5rem); margin-bottom: 1.25rem;
    & h1 { font-size: var(--fs-2xl); }
    & p { color: rgb(247 244 238 / 0.7); margin-top: 0.5rem; }
  }
  .p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-top: 1.75rem; position: relative; }
  .p-stat { display: grid; gap: 0.2rem; padding: 1rem 1.1rem; border-radius: var(--radius); background: rgb(255 255 255 / 0.05); border: 1px solid var(--line-dark); text-decoration: none;
    & b { font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; line-height: 1; color: var(--gold-400); }
    & span { font-size: var(--fs-xs); color: rgb(247 244 238 / 0.7); }
    &:hover { border-color: rgb(198 167 107 / 0.5); }
  }

  .quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
  .quick a {
    display: grid; gap: 0.6rem; padding: 1.1rem; border-radius: var(--radius); border: 1px solid var(--line-light); background: var(--white);
    text-decoration: none; font-size: var(--fs-sm); font-weight: 550; transition: border-color 0.2s, transform 0.2s;
    & .icon { width: 26px; height: 26px; color: var(--gold-600); stroke-width: 1.3; }
    &:hover { border-color: var(--gold-500); transform: translateY(-2px); }
  }

  /* ── Listas ── */
  .p-list { list-style: none; padding: 0; display: grid; }
  .p-list li { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line-light); &:last-child { border-bottom: 0; } }
  .p-list .p-list__icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--ivory); color: var(--gold-600); flex: none; }
  .p-list .p-list__body { display: grid; min-width: 0; flex: 1;
    & strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    & small { color: var(--ink-3); font-size: var(--fs-xs); }
  }
  .p-list .p-list__end { display: flex; align-items: center; gap: 0.5rem; flex: none; }
  a.p-row { text-decoration: none; display: flex; align-items: center; gap: 1rem; width: 100%; &:hover strong { color: var(--gold-600); } }

  .policy-card {
    display: grid; gap: 1rem; padding: 1.4rem; border-radius: var(--radius-lg); border: 1px solid var(--line-light); background: var(--white); text-decoration: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    &:hover { border-color: rgb(198 167 107 / 0.6); box-shadow: var(--shadow-soft); }
    & .policy-card__top { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
    & h3 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; }
    & .policy-card__meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem 1rem; font-size: var(--fs-sm);
      & dt { color: var(--ink-3); font-size: var(--fs-xs); }
    }
    & img { max-height: 26px; width: auto; }
  }

  .pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; background: var(--ivory-2); color: var(--ink-2); }
  .pill--vigente, .pill--pagado, .pill--liquidado, .pill--resuelta { background: #e3f5ec; color: #1f7a52; }
  .pill--en_emision, .pill--recibido, .pill--abierta { background: #fff4dc; color: #8a5a00; }
  .pill--en_gestion, .pill--en_compania, .pill--en_proceso { background: #e6efff; color: #2453a6; }
  .pill--pendiente { background: #fff4dc; color: #8a5a00; }
  .pill--vencido { background: #fbeeee; color: #9b2c22; }
  .pill--vencida, .pill--anulada, .pill--anulado, .pill--cerrado, .pill--cerrada, .pill--rechazado { background: #f1efea; color: #7a7266; }

  .dl { display: grid; grid-template-columns: minmax(120px, 35%) 1fr; gap: 0.6rem 1rem; font-size: var(--fs-sm);
    & dt { color: var(--ink-3); }
    & dd { min-width: 0; }
  }
  .empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3);
    & .icon { width: 36px; height: 36px; margin: 0 auto 0.75rem; color: var(--gold-500); stroke-width: 1.2; }
    & .btn { margin-top: 1.25rem; }
  }
  .flash { display: flex; gap: 0.6rem; align-items: center; padding: 0.9rem 1.1rem; border-radius: var(--radius-sm); background: #e3f5ec; color: #1f6b49; border: 1px solid #c3e7d4; margin-bottom: 1.25rem; font-size: var(--fs-sm); }

  /* ── Conversación ── */
  .thread { list-style: none; padding: 0; display: grid; gap: 1rem; }
  .msg { max-width: 85%; padding: 0.9rem 1.1rem; border-radius: 14px; background: var(--white); border: 1px solid var(--line-light); font-size: 0.95rem;
    & .msg__meta { font-size: var(--fs-xs); color: var(--ink-3); margin-bottom: 0.3rem; }
  }
  .msg--client { margin-left: auto; background: var(--navy-900); color: var(--ivory); border-color: var(--navy-900); & .msg__meta { color: rgb(247 244 238 / 0.6); } }
  .msg--system { max-width: none; background: transparent; border: 0; text-align: center; font-size: var(--fs-xs); color: var(--ink-3); padding: 0.25rem; }
  .msg--internal { background: #fff8e6; border-style: dashed; }

  .file-input { padding: 0.9rem; border: 1px dashed #cfc6b5; border-radius: var(--radius-sm); background: var(--ivory); width: 100%; font-size: var(--fs-sm); }

  /* ── Ingreso ── */
  .auth-screen { min-height: 100dvh; display: grid; grid-template-columns: 1fr; background: var(--ivory);
    @media (min-width: 960px) { grid-template-columns: 1fr 1fr; }
  }
  .auth-side { position: relative; overflow: hidden; display: none; color: var(--ivory); padding: 3rem;
    background: radial-gradient(120% 120% at 90% 0%, var(--navy-800), var(--navy-950) 65%);
    @media (min-width: 960px) { display: flex; flex-direction: column; justify-content: space-between; }
    & h2 { font-size: var(--fs-3xl); max-width: 14ch; position: relative; }
    & ul { position: relative; }
  }
  .auth-main { display: grid; place-items: center; padding: 2.5rem 1.25rem; }
  .auth-box { width: min(440px, 100%); display: grid; gap: 1.25rem;
    & h1 { font-size: var(--fs-2xl); }
    & .muted { color: var(--ink-3); }
    & .links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; font-size: var(--fs-sm);
      & a { color: var(--gold-600); text-decoration: none; font-weight: 550; }
    }
  }
  .auth-brand-mobile { color: var(--navy-900); @media (min-width: 960px) { display: none; } & .brand__tag { color: var(--gold-600); } }
  .notice-box { padding: 0.9rem 1.1rem; border-radius: var(--radius-sm); font-size: var(--fs-sm); background: #fdf3e1; color: #7a4d0b; border: 1px solid #f1dcb3; }
  .notice-box--ok { background: #e3f5ec; color: #1f6b49; border-color: #c3e7d4; }
  .secret { display: block; margin-top: 0.4rem; padding: 0.6rem 0.75rem; background: var(--ivory); border-radius: 6px; letter-spacing: 0.08em; word-break: break-all; user-select: all; font-size: var(--fs-sm); }
}

@layer utilities { .small { font-size: var(--fs-sm); } }

/* ── Progreso de siniestros / utilidades ── */
.mb { margin-bottom: 1rem; }
.progress-steps { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; counter-reset: none;
  & li { display: grid; justify-items: center; gap: 0.4rem; text-align: center; font-size: 0.78rem; color: var(--ink-3); position: relative;
    & span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line, #e4e0d6); background: #fff; font-weight: 600; position: relative; z-index: 1; }
    &:not(:first-child)::before { content: ""; position: absolute; top: 15px; right: 50%; width: 100%; height: 2px; background: var(--line, #e4e0d6); }
  }
  & li.is-done { color: var(--ink-2, inherit);
    & span { background: var(--navy-900, #0d1b33); border-color: var(--navy-900, #0d1b33); color: #fff; }
    &::before { background: var(--navy-900, #0d1b33); }
  }
  & li.is-current { color: var(--ink, inherit); font-weight: 600;
    & span { border-color: var(--gold-500, #c8a45a); background: var(--gold-500, #c8a45a); color: var(--navy-950, #08111f); }
    &::before { background: var(--navy-900, #0d1b33); }
  }
}

@layer sections {
  .share-link { display: flex; gap: 0.5rem; margin-top: 0.75rem;
    & .input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-sm); background: var(--ivory); }
  }
  .p-stats--light { margin-top: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    & .p-stat { background: var(--ivory); border-color: var(--line-light); }
    & .p-stat b { color: var(--navy-900); }
    & .p-stat span { color: var(--ink-2); }
  }
  .p-review { border-color: rgb(198 167 107 / 0.55); background: linear-gradient(180deg, #fbf8f1, var(--white)); }
}
