/* =========================================================
   Visual polish 02 - refinamiento integral de interfaz
   Se carga después del CSS de la aplicación para no alterar lógica.
   ========================================================= */

:root {
  --sbd-brand-blue: #1f5fbf;
  --sbd-brand-green: #66c52d;
  --sbd-deep: #11233d;
  --sbd-deep-2: #1b3658;
  --sbd-text: #1b2a3d;
  --sbd-muted-2: #6f7f93;
  --sbd-soft-line: #dde5ee;
  --sbd-soft-bg: #f3f6fa;
  --sbd-card-shadow: 0 10px 30px rgba(17, 35, 61, 0.07);
  --sbd-card-shadow-hover: 0 18px 42px rgba(17, 35, 61, 0.13);
}

html {
  background: var(--sbd-soft-bg);
}

body {
  color: var(--sbd-text);
  background: var(--sbd-soft-bg);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(31, 95, 191, 0.24);
  outline-offset: 2px;
}

/* ---------- Identidad / header ---------- */
.topbar {
  min-height: 122px;
  padding-top: 22px;
  padding-bottom: 22px;
}

.topbar > div:first-child {
  position: relative;
  min-height: 76px;
  padding-left: 220px !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.topbar > div:first-child::before {
  content: '' !important;
  position: absolute !important;
  left: 0 !important;
  top: 50% !important;
  bottom: auto !important;
  width: 194px !important;
  height: 72px !important;
  transform: translateY(-50%);
  border-radius: 0 !important;
  background: url('/branding/logo-sbd.png') center / contain no-repeat !important;
}

.topbar .eyebrow {
  display: none;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: clamp(26px, 2vw, 34px);
}

.topbar .subtitle {
  color: #728198;
  font-size: 13px;
}

.user-area {
  padding: 8px 10px;
  border-radius: 14px;
}

.user-area > div {
  min-width: 170px;
}

.user-area span {
  font-size: 11px;
  letter-spacing: 0.2px;
}

.user-area strong {
  font-size: 13px;
}

.secondary-button {
  border: 1px solid #d8e0e9;
  background: #f7f9fc;
  box-shadow: 0 3px 10px rgba(17, 35, 61, 0.035);
}

.secondary-button:hover {
  border-color: #c8d3df;
  background: #eef3f8;
}

/* ---------- Login ---------- */
.auth-page {
  background:
    radial-gradient(circle at 18% 12%, rgba(102, 197, 45, 0.10), transparent 28%),
    radial-gradient(circle at 84% 16%, rgba(31, 95, 191, 0.10), transparent 28%),
    linear-gradient(180deg, #f9fbfd 0%, #f2f6fa 100%);
}

.auth-card {
  width: min(540px, 100%);
  padding: 44px 44px 42px;
  border-radius: 22px;
  border-color: #dfe7ef;
  box-shadow: 0 24px 70px rgba(17, 35, 61, 0.12);
}

.logo-mark {
  width: min(290px, 82%);
  height: 92px;
  margin: 0 auto 20px;
  border-radius: 0;
  background: url('/branding/logo-sbd.png') center / contain no-repeat !important;
  color: transparent;
  font-size: 0;
}

.auth-card h1 {
  color: var(--sbd-deep);
  letter-spacing: -0.5px;
}

.google-button {
  min-height: 46px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--sbd-deep) 0%, var(--sbd-deep-2) 100%);
  box-shadow: 0 8px 20px rgba(17, 35, 61, 0.16);
}

.google-button:hover {
  background: linear-gradient(135deg, #183252 0%, #24476f 100%);
  transform: translateY(-1px);
}

/* ---------- Dashboard ---------- */
.dashboard {
  padding-bottom: 38px;
}

.dashboard-toolbar {
  align-items: flex-end;
}

.refresh-status strong {
  letter-spacing: -0.1px;
}

.refresh-status span {
  font-variant-numeric: tabular-nums;
}

.origin-stats-grid .stat-card {
  background: rgba(255, 255, 255, 0.96);
}

.origin-stats-grid .stat-card strong {
  font-variant-numeric: tabular-nums;
}

.origin-filters-panel {
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.94);
}

.search-box input::placeholder {
  color: #9aa6b5;
}

/* ---------- Secciones ---------- */
.section-title {
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 22px;
}

.section-description {
  font-size: 13px;
}

.proposal-section + .proposal-section {
  padding: 22px;
  border: 1px solid #eadfc8;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.72), rgba(255, 255, 255, 0.45));
}

.proposal-section + .proposal-section .proposal-card {
  border-color: #eadfc8;
}

/* ---------- Tarjetas uniformes ---------- */
.proposal-grid {
  align-items: stretch;
}

.proposal-card {
  display: flex;
  flex-direction: column;
  min-height: 332px;
  height: 100%;
  background: rgba(255, 255, 255, 0.98);
}

.proposal-card-top {
  align-items: flex-start;
}

.proposal-badges {
  gap: 6px;
}

.status-badge,
.origin-badge,
.category-badge {
  min-height: 25px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(17, 35, 61, 0.025);
}

.status-active {
  background: #e8f7ee;
  color: #14733e;
  border-color: #d4ecdd;
}

.status-review {
  background: #fff3dc;
  color: #97600d;
  border-color: #f0dfba;
}

.origin-federal {
  background: #e9f2fd;
  color: #285b98;
  border-color: #d7e6f7;
}

.origin-estatal {
  background: #f2ebfb;
  color: #69438c;
  border-color: #e6daf5;
}

.origin-wioa {
  background: #e7f6f1;
  color: #17695d;
  border-color: #d2ebe3;
}

.origin-municipal {
  background: #fff2df;
  color: #94580f;
  border-color: #f1dfc3;
}

.category-badge {
  background: #f1f5f9;
  color: #556a81;
  border-color: #e5ebf1;
  text-transform: capitalize;
}

.proposal-card h3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  min-height: calc(1.38em * 2);
  max-height: calc(1.38em * 3);
}

.proposal-meta {
  grid-template-columns: minmax(0, 1.35fr) minmax(130px, 0.65fr);
  gap: 18px;
}

.proposal-meta p:last-child {
  padding-left: 14px;
  border-left: 3px solid #d9e2ec;
}

.proposal-meta p:last-child span {
  color: var(--sbd-deep);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.proposal-card .proposal-description {
  -webkit-line-clamp: 3;
  line-clamp: 3;
  margin-top: 0;
  margin-bottom: 0;
  min-height: 0;
}

.proposal-actions {
  margin-top: auto !important;
  padding-top: 18px;
  border-top: 1px solid #eef2f6;
}

.details-button,
.source-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.proposal-link {
  text-underline-offset: 3px;
}

/* ---------- Mensajes ---------- */
.search-run-message,
.message-card,
.empty-state {
  border-radius: 14px;
}

.search-run-success {
  border-left: 4px solid #2e9b67;
}

.search-run-error,
.error-card {
  border-left: 4px solid #c94d4d;
}

/* ---------- Modal de detalle ---------- */
.modal-backdrop {
  background: rgba(12, 24, 42, 0.68);
  backdrop-filter: blur(7px);
  padding: 32px 18px;
}

.proposal-modal {
  width: min(1040px, 100%);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 0 !important;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 36px 100px rgba(7, 18, 33, 0.36);
}

.modal-close {
  position: sticky;
  float: right;
  top: 16px;
  right: 18px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 1px solid #dce4ed;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 15px rgba(17, 35, 61, 0.10);
  color: #52647a;
  display: grid;
  place-items: center;
  line-height: 1;
}

.modal-close:hover {
  background: #f2f6fa;
  color: var(--sbd-deep);
}

.modal-header {
  padding: 32px 34px 25px;
  background:
    radial-gradient(circle at 92% 8%, rgba(31, 95, 191, 0.08), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid #e5ebf1;
}

.modal-header h2 {
  max-width: 900px;
  margin-top: 17px;
  color: var(--sbd-deep);
  font-size: clamp(23px, 2.1vw, 30px);
  line-height: 1.25;
  letter-spacing: -0.45px;
}

.modal-header p {
  max-width: 900px;
  margin-bottom: 0;
}

.modal-meta {
  padding: 0 34px;
  margin: 24px 0 30px;
}

.modal-meta > div {
  min-height: 74px;
  justify-content: center;
  border-radius: 12px;
}

.modal-meta > div:last-child {
  border-left: 4px solid #d9e2ec;
}

.modal-meta > div:last-child span {
  color: var(--sbd-deep);
  font-weight: 800;
}

.detail-section {
  margin-left: 34px;
  margin-right: 34px;
  padding-top: 26px;
}

.detail-section h3 {
  color: var(--sbd-deep);
  letter-spacing: -0.25px;
}

.document-card {
  border-color: #dde5ee;
  background: #fbfcfe;
  box-shadow: 0 4px 14px rgba(17, 35, 61, 0.035);
}

.modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 30px;
  padding: 18px 34px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid #e2e8ef;
  box-shadow: 0 -8px 24px rgba(17, 35, 61, 0.05);
}

.source-button {
  border-radius: 10px;
  background: linear-gradient(135deg, var(--sbd-deep) 0%, var(--sbd-deep-2) 100%);
  box-shadow: 0 7px 18px rgba(17, 35, 61, 0.14);
}

/* ---------- Footer sin tocar lógica React ---------- */
.app-shell::after {
  content: 'Solutions By Design · Buscador de Propuestas · Uso interno';
  display: block;
  width: min(1440px, 91%);
  margin: 0 auto;
  padding: 20px 0 24px;
  border-top: 1px solid #dde5ee;
  color: #8290a1;
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.25px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .topbar > div:first-child {
    padding-left: 184px !important;
  }

  .topbar > div:first-child::before {
    width: 160px !important;
    height: 64px !important;
  }

  .proposal-card {
    min-height: 320px;
  }
}

@media (max-width: 850px) {
  .topbar {
    align-items: stretch;
  }

  .topbar > div:first-child {
    width: 100%;
    min-height: 70px;
  }

  .user-area {
    width: 100%;
    border-top: 1px solid #edf1f5;
    padding-top: 14px;
  }

  .proposal-card {
    min-height: 0;
  }

  .proposal-section + .proposal-section {
    padding: 16px;
  }

  .modal-meta,
  .detail-section {
    margin-left: 22px;
    margin-right: 22px;
  }

  .modal-meta {
    padding: 0;
  }

  .modal-header {
    padding: 28px 22px 22px;
  }

  .modal-footer {
    padding: 16px 22px;
  }
}

@media (max-width: 620px) {
  .topbar > div:first-child {
    padding-left: 0 !important;
    padding-top: 78px;
  }

  .topbar > div:first-child::before {
    top: 0 !important;
    transform: none;
    width: 190px !important;
    height: 64px !important;
  }

  .topbar h1 {
    font-size: 25px;
  }

  .user-area {
    gap: 10px;
  }

  .user-area > div {
    min-width: 0;
    width: 100%;
    border-right: 0;
    padding-right: 0;
  }

  .proposal-meta {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .proposal-meta p:last-child {
    padding: 10px 0 0;
    border-left: 0;
    border-top: 2px solid #e0e7ef;
  }

  .proposal-actions {
    align-items: stretch;
  }

  .proposal-actions .details-button,
  .proposal-actions .proposal-link {
    width: 100%;
  }

  .proposal-link {
    justify-content: center;
    min-height: 40px;
  }

  .auth-card {
    padding: 34px 22px 30px;
  }

  .logo-mark {
    width: 250px;
    height: 78px;
  }

  .proposal-modal {
    max-height: calc(100vh - 28px);
    border-radius: 16px;
  }

  .modal-backdrop {
    padding: 14px 8px;
  }

  .app-shell::after {
    width: 90%;
    line-height: 1.5;
  }
}
