/* ============================================
   WESTMARK RATES - Embed & Widget Styles
   ============================================ */

/* Rate table base styling */
.rates table {
  width: 100% !important;
  table-layout: auto;
}

.rates th,
.rates td {
  width: auto !important;
  height: auto !important;
  white-space: normal;
}

.rates table [style*="width"] {
  width: auto !important;
}

.rates table [style*="height"] {
  height: auto !important;
}

/* Table styling */
.rates .table {
  color: var(--wm-midnight, #0D3B71) !important;
  width: 100%;
  border-spacing: 0;
  margin-bottom: 0;
}

.rates .table thead th {
  padding: .75rem 1rem;
  font-size: .85rem;
  text-transform: uppercase;
  vertical-align: middle;
  letter-spacing: .5px;
  background-color: var(--wm-midnight, #0D3B71) !important;
  color: #fff !important;
  font-weight: 600;
  border-bottom-width: 1px;
}

.rates .table td,
.rates .table th {
  font-size: 1rem;
  padding: .75rem 1rem;
}

.rates .table tr {
  border-bottom: 1px solid #f0f0f0;
}

.rates .table thead tr {
  border-bottom: 2px solid #f0f0f0;
}

.rates .table td a {
  color: var(--wm-midnight, #0D3B71) !important;
  text-decoration: underline;
}

.rates .table td a:hover {
  color: var(--wm-mountain-green, #7FA895) !important;
}

.rates .table th {
  text-align: left;
}

/* Header styling only on thead */
.rates .table thead,
.rates .table thead th,
.rates .table thead td {
  background: var(--wm-midnight, #0D3B71) !important;
  color: #fff !important;
  border-color: rgba(0, 0, 0, .1) !important;
}

/* ============================================
   RATE CARD - Container Styling
   ============================================ */
.rate-card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .08);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(0, 0, 0, .05);
  transition: box-shadow .3s ease, transform .3s ease;
}

.rate-card:hover {
  box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .12);
  transform: translateY(-2px);
}

.rate-card-alt {
  background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
}

.rate-card h3 {
  color: var(--wm-midnight, #0D3B71);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: .25rem;
}

.rate-card h3 a {
  color: var(--wm-midnight, #0D3B71);
  text-decoration: none;
  transition: color .2s ease;
}

.rate-card h3 a:hover {
  color: var(--wm-mountain-green, #7FA895);
}

.rate-card .disclosure {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, .05);
  font-size: .85rem;
  color: #666;
  line-height: 1.6;
}

.rate-card .disclosure a {
  color: var(--wm-midnight, #0D3B71);
  text-decoration: underline;
}

.rate-card .disclosure a:hover {
  color: var(--wm-mountain-green, #7FA895);
}

/* ============================================
   RATES EFFECTIVE DATE BADGE
   ============================================ */
.rates-effective {
  display: inline-block;
  font-size: .75rem;
  font-weight: 500;
  color: #64748b;
  background: #f1f5f9;
  padding: .2rem .6rem;
  border-radius: 2rem;
  margin-bottom: .75rem;
}

/* ============================================
   RATES HEADER - Compact Layout
   ============================================ */
.rates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: .75rem;
}

.rates-header.cms-editable {
  z-index: 3;
}

.rates-header-main {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.rates-header-main h1,
.rates-header-main h2 {
  font-size: 2rem;
  font-weight: 300;
  color: var(--wm-midnight, #0D3B71);
  margin: 0;
  line-height: 1.2;
}

.rates-header-meta {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.rates-header-meta a:not(.btn) {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--wm-midnight, #0D3B71);
  text-decoration: none;
  padding: .35rem .75rem;
  border-radius: .35rem;
  background: #e8f4fc;
  transition: all .2s ease;
}

.rates-header-meta a:not(.btn):hover {
  background: var(--wm-midnight, #0D3B71);
  color: #fff;
}

.rates-apr-note {
  font-size: .85rem;
  color: #64748b;
  margin: 0 0 .5rem 0;
  padding-bottom: .75rem;
  border-bottom: 1px solid #e2e8f0;
}

/* ============================================
   RATES QUICK NAV
   ============================================ */
.rates-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.rates-nav-section {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid rgba(13, 59, 113, .08);
  box-shadow: 0 4px 15px rgba(13, 59, 113, .05);
}

.rates-nav-label {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--wm-midnight, #0D3B71);
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid rgba(13, 59, 113, .12);
}

.rates-nav-label i {
  font-size: 1.1rem;
  color: var(--wm-mountain-green, #7FA895);
}

.rates-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.rates-nav-links a {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--wm-midnight, #0D3B71);
  background: #fff;
  border-radius: .5rem;
  text-decoration: none;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
  border: 1px solid rgba(13, 59, 113, .15);
  box-shadow: 0 2px 6px rgba(13, 59, 113, .06);
}

.rates-nav-links a i {
  font-size: .8rem;
  color: var(--wm-mountain-green, #7FA895);
  transition: all .25s ease;
}

.rates-nav-links a:hover {
  background: var(--wm-midnight, #0D3B71);
  color: #fff;
  border-color: var(--wm-midnight, #0D3B71);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(13, 59, 113, .25);
}

.rates-nav-links a:hover i {
  color: var(--wm-mountain-green, #7FA895);
  transform: scale(1.1);
}

/* Special link styling */
.rates-nav-links a.rates-special {
  background: linear-gradient(135deg, var(--wm-mountain-green, #7FA895) 0%, #5d8a70 100%);
  color: #fff;
  border-color: var(--wm-mountain-green, #7FA895);
  font-weight: 600;
}

.rates-nav-links a.rates-special i {
  color: #fff;
}

.rates-nav-links a.rates-special:hover {
  background: linear-gradient(135deg, #5d8a70 0%, #4a7359 100%);
  box-shadow: 0 8px 30px rgba(127, 168, 149, .4);
}

/* ============================================
   MOBILE RESPONSIVE - Stacked Cards
   ============================================ */
@media (max-width: 576px) {
  .rates .table thead {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }

  .rates .table tbody tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid rgba(0, 0, 0, .125);
    border-radius: .5rem;
    background: #fff;
  }

  .rates .table tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .75rem;
    border-top: 0;
    /* Reset any inherited opacity or filters */
    opacity: 1 !important;
    filter: none !important;
  }

  .rates .table tbody tr td + td {
    border-top: 1px solid rgba(0, 0, 0, .075);
  }

  .rates .table td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 1rem;
  }

  /* Mobile card-style header cell - MUST have white text on dark blue bg */
  /* Bootstrap 5 uses CSS variables + inset box-shadow for striped rows - must override ALL */
  .rates .table tbody tr td:first-child,
  .rates .rate-card .table tbody tr td:first-child,
  #pagecontent.rates .table tbody tr td:first-child,
  .rate-card .table tbody tr td:first-child,
  .rates .table-striped tbody tr:nth-of-type(odd) td:first-child,
  .rates .table-striped tbody tr:nth-of-type(even) td:first-child {
    --bs-table-color-type: #ffffff !important;
    --bs-table-bg-type: #0D3B71 !important;
    --bs-table-striped-color: #ffffff !important;
    --bs-table-striped-bg: #0D3B71 !important;
    background: #0D3B71 !important;
    background-color: #0D3B71 !important;
    color: #ffffff !important;
    border-top-left-radius: .5rem;
    border-top-right-radius: .5rem;
    font-weight: 600;
    opacity: 1 !important;
    -webkit-text-fill-color: #ffffff !important;
    box-shadow: none !important; /* Override Bootstrap's 9999px inset box-shadow */
  }

  /* Ensure ALL text and descendants in the first cell are white */
  .rates .table tbody tr td:first-child *,
  .rate-card .table tbody tr td:first-child * {
    --bs-table-color-type: #ffffff !important;
    --bs-table-striped-color: #ffffff !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    opacity: 1 !important;
  }

  .rates .table tbody tr td:first-child::before {
    content: none;
  }

  .rates .table tbody tr td:first-child a,
  .rate-card .table tbody tr td:first-child a {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    text-decoration: underline;
  }

  /* Balance tier tables - show label on first cell */
  .rates .table.balance-tiers tbody tr td:first-child::before {
    content: attr(data-label);
    color: #fff;
    margin-right: .5rem;
  }

  .rates-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .rates-header-main h1,
  .rates-header-main h2 {
    font-size: 1.5rem;
  }

  .rates-header-meta {
    width: 100%;
  }

  .rates-header-meta a {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  .rates-header-meta a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
  }

  .rates-nav {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .rates-nav-section {
    padding: 1.25rem;
  }

  .rates-nav-links a {
    padding: .5rem .875rem;
    font-size: .8rem;
  }

  .rate-card {
    padding: 1rem;
  }

  .rate-card h3 {
    font-size: 1.25rem;
  }
}

/* Tablet restore normal tables */
@media (min-width: 577px) {
  .rates .table thead {
    display: table-header-group !important;
    position: static !important;
    clip: auto !important;
    height: auto !important;
    margin: 0 !important;
    width: auto !important;
    overflow: visible !important;
    visibility: visible !important;
  }

  .rates .table tbody {
    display: table-row-group !important;
  }

  .rates .table thead tr,
  .rates .table tbody tr {
    display: table-row !important;
  }

  .rates .table thead th,
  .rates .table thead td,
  .rates .table tbody th,
  .rates .table tbody td {
    display: table-cell !important;
    vertical-align: middle !important;
  }

  .rates .table td::before {
    content: none !important;
  }

  .rates .table tbody tr {
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }

  .rates .table tbody tr td:first-child {
    background: transparent !important;
    color: inherit !important;
  }
}

/* ============================================
   RATES EMBED PLACEHOLDER (CMS)
   ============================================ */
.rates-embed {
  min-height: 100px;
}

.cms-rates-placeholder {
  border: 1px dashed #adb5bd;
  border-radius: .5rem;
  padding: .75rem;
  background: #f8f9fa;
  color: #495057;
  font-size: .9375rem;
  line-height: 1.4;
}

.cms-rates-placeholder code {
  background: #eef1f4;
  padding: .1rem .25rem;
  border-radius: .25rem;
}

.cms-rates-placeholder a {
  text-decoration: underline;
}

/* Anchor offset for sticky header */
.anchor-offset::before {
  content: "";
  display: block;
  height: 120px;
  margin-top: -120px;
  visibility: hidden;
  pointer-events: none;
}

/* ============================================
   DISCLOSURE TOGGLE ARROW
   ============================================ */
.disclosure-arrow {
  transition: transform 0.25s ease;
}

/* Collapsed state (default) - arrow points down */
.collapsed .disclosure-arrow {
  transform: rotate(0deg);
}

/* Expanded state - arrow points up */
[data-bs-toggle="collapse"]:not(.collapsed) .disclosure-arrow {
  transform: rotate(-180deg);
}

[data-bs-toggle="collapse"]:hover {
  text-decoration: underline !important;
}

/* CMS Editable Region Isolation */
.cms-editable {
  position: relative;
  z-index: 1;
}

[id$="-widget"].cms-editable {
  padding-bottom: 1rem;
  margin-bottom: 0;
}
