/**
 * Royal Seguros — Design system enterprise (mobile-first).
 * Paleta: Royal #0A2A66, profundo #081F4D, gold #D4A017, surface #F5F7FA, texto #0F172A
 */
:root {
  --rs-royal: #0a2a66;
  --rs-royal-dark: #081f4d;
  --rs-gold: #d4a017;
  --rs-surface: #f5f7fa;
  --rs-ink: #0f172a;
  --rs-muted: #475569;
  --rs-body: #334155;
  --rs-border: #e2e8f0;
  --rs-danger: #b91c1c;
  --rs-success: #166534;
  --rs-warning: #92400e;
  --rs-radius: 12px;
  --rs-radius-lg: 16px;
  --rs-focus-ring: 0 0 0 3px rgba(212, 160, 23, 0.35);
  --rs-text-tight: 1.25;
  --rs-text-body: 1.6;
  --rs-space-xs: 0.5rem;
  --rs-space-sm: 0.75rem;
  --rs-space-md: 1rem;
  --rs-space-lg: 1.5rem;
  --rs-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --rs-shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.1);
}

/* Tipografia e foco global */
h1, h2, h3, h4 {
  line-height: var(--rs-text-tight);
  letter-spacing: -0.01em;
}
p, li {
  line-height: var(--rs-text-body);
}
a {
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--rs-focus-ring);
  border-color: var(--rs-gold) !important;
}

/* Botões */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border-radius: var(--rs-radius);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  font-family: inherit;
}
.ds-btn:active {
  transform: scale(0.98);
}
.ds-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--rs-shadow-lg);
}
.ds-btn--primary {
  background: var(--rs-gold);
  color: var(--rs-royal-dark) !important;
  box-shadow: var(--rs-shadow);
}
.ds-btn--primary:hover {
  filter: brightness(0.95);
}
.ds-btn--royal {
  background: var(--rs-royal);
  color: #fff !important;
}
.ds-btn--royal:hover {
  background: var(--rs-royal-dark);
}
.ds-btn--secondary {
  background: #fff;
  color: var(--rs-royal) !important;
  border: 2px solid var(--rs-royal);
}
.ds-btn--secondary:hover {
  background: var(--rs-surface);
}
.ds-btn--ghost {
  background: transparent;
  color: var(--rs-royal) !important;
  border: 1px solid var(--rs-border);
}
.ds-btn--ghost:hover {
  background: #f8fafc;
}
.ds-btn--block {
  width: 100%;
}

.btn-continue {
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  background: #d4a017;
  color: #081f4d !important;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(212, 160, 23, 0.25);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.btn-continue:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

/* Cards */
.ds-card {
  background: #fff;
  color: var(--rs-ink);
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-lg);
  box-shadow: var(--rs-shadow);
  padding: var(--rs-space-lg);
}
.ds-card--elevated {
  box-shadow: var(--rs-shadow-lg);
}

/* Badges */
.ds-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ds-badge--gold {
  background: rgba(212, 160, 23, 0.2);
  color: var(--rs-royal-dark);
}
.ds-badge--royal {
  background: rgba(10, 42, 102, 0.12);
  color: var(--rs-royal);
}
.ds-badge--ok {
  background: #dcfce7;
  color: var(--rs-success);
}
.ds-badge--warn {
  background: #fef3c7;
  color: var(--rs-warning);
}
.ds-badge--err {
  background: #fee2e2;
  color: var(--rs-danger);
}

/* Inputs (fallback quando não usar só Tailwind) */
.ds-input {
  width: 100%;
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--rs-ink);
  background: #fff;
  font-family: inherit;
}
.ds-input:focus {
  outline: none;
  border-color: var(--rs-royal);
  box-shadow: var(--rs-focus-ring);
}
.ds-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rs-muted);
  margin-bottom: 0.35rem;
}

/* Alertas */
.ds-alert {
  border-radius: var(--rs-radius);
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--rs-border);
}
.ds-alert--info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a5f;
}
.ds-alert--success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: var(--rs-success);
}
.ds-alert--warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: var(--rs-warning);
}
.ds-alert--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--rs-danger);
}

/* Tabela */
.ds-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-lg);
  background: #fff;
}
.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.ds-table th,
.ds-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rs-surface);
}
.ds-table th {
  background: var(--rs-surface);
  color: var(--rs-muted);
  font-weight: 600;
}
.ds-table tr:last-child td {
  border-bottom: none;
}

/* Modal overlay (estrutura; abrir com JS/Alpine) */
.ds-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}
@media (min-width: 640px) {
  .ds-modal-overlay {
    align-items: center;
  }
}
.ds-modal {
  background: #fff;
  border-radius: var(--rs-radius-lg);
  max-width: 28rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--rs-shadow-lg);
  padding: 1.5rem;
}

/* Skeleton loading */
.ds-skeleton {
  animation: ds-pulse 1.2s ease-in-out infinite;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  border-radius: 8px;
}
@keyframes ds-pulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.ds-skeleton-line {
  height: 0.875rem;
  margin-bottom: 0.5rem;
}
.ds-skeleton-line--short {
  width: 40%;
}

/* Estado vazio */
.ds-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--rs-muted);
  border: 1px dashed var(--rs-border);
  border-radius: var(--rs-radius-lg);
  background: #fff;
}
.ds-empty__title {
  font-weight: 700;
  color: var(--rs-ink);
  margin-bottom: 0.35rem;
}

.text-body {
  color: var(--rs-body);
}

/* Navbar enterprise */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow 0.25s ease, background 0.25s ease;
}
.portal-header.is-scrolled {
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

.portal-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  border-radius: 9999px;
  background: var(--rs-surface);
  border: 1px solid var(--rs-border);
  max-width: 12rem;
}
.portal-user-pill__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--rs-royal), var(--rs-royal-dark));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-user-pill__name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rs-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toasts / flashes */
@keyframes portalToastIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.portal-flash {
  animation: portalToastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  box-shadow: var(--rs-shadow-lg);
}

/* Drawer mobile */
.portal-drawer-overlay {
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}
.portal-drawer-panel {
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
}

/* Form feedback */
.portal-form-busy [type="submit"]:disabled {
  opacity: 0.75;
  cursor: wait;
}

/* Consistência para inputs com classes Tailwind usadas no portal */
input.rounded-xl,
select.rounded-xl,
textarea.rounded-xl {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
input.rounded-xl:hover,
select.rounded-xl:hover,
textarea.rounded-xl:hover {
  border-color: #cbd5e1;
}

/* QA mobile por breakpoints */
@media (max-width: 768px) {
  .ds-card {
    padding: 1.1rem;
  }
  .ds-table th,
  .ds-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 430px) {
  html,
  body {
    overflow-x: clip;
  }
  .back-btn {
    width: 100%;
    justify-content: center;
  }
  .ds-btn {
    min-height: 48px;
  }
  .portal-drawer-panel {
    width: min(100%, 18.5rem);
  }
}

@media (max-width: 390px) {
  .ds-badge {
    font-size: 0.64rem;
    letter-spacing: 0.03em;
  }
  .portal-user-pill {
    max-width: 10.5rem;
  }
}

@media (max-width: 360px) {
  .ds-card {
    border-radius: 14px;
    padding: 1rem;
  }
  .portal-user-pill {
    max-width: 9.75rem;
  }
  .portal-user-pill__name {
    font-size: 0.7rem;
  }
}

/* Blocos estratégicos da home */
.rs-strategic-card {
  display: block;
  border-radius: 18px;
  padding: 1.4rem;
  border: 1px solid #e2e8f0;
  background: linear-gradient(160deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.rs-strategic-card:hover {
  transform: translateY(-4px);
  border-color: rgba(10, 42, 102, 0.35);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(212, 160, 23, 0.16);
}

.rs-strategic-card__icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
  color: #081f4d;
  background: radial-gradient(circle at 30% 30%, #f6e2a7 0%, #d4a017 70%);
  box-shadow: 0 6px 18px rgba(212, 160, 23, 0.28);
}

/* Ecossistema home — flash subtil ao clicar (complementa active:scale) */
[data-eco-card="true"].eco-card--flash {
  animation: eco-card-flash 280ms ease-out;
}
@keyframes eco-card-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(10, 42, 102, 0.2);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(10, 42, 102, 0);
  }
}
