/* ============================================================
   mi-brokerage-modal.css
   Styling for the Brokerage Accounts modal (brk-*). Sibling
   of mi-account-modal.css. Visual language matches the existing
   acct-* modal so the two feel like one product surface.
   Iter 12DO (2026-05-18)
   ============================================================ */

.brk-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 10000;
  animation: brk-overlay-in 0.15s;
}
@keyframes brk-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.brk-modal {
  background: rgba(28, 28, 32, 0.97);
  border: 1px solid var(--border, #2c2f33);
  border-radius: var(--radius, 12px);
  width: 720px;
  max-width: 94vw;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: brk-modal-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  color: #e8e8ea;
}
@keyframes brk-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.brk-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border, #2c2f33);
  flex-shrink: 0;
}
.brk-modal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brk-modal-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brk-modal-brand-name {
  font-size: 17px;
  letter-spacing: 0.2px;
}
.brk-modal-brand-name-strong { font-weight: 700; color: #fff; }
.brk-modal-brand-name-light  { font-weight: 400; color: #b0b3b8; }

.brk-modal-close {
  background: transparent;
  border: none;
  color: #b0b3b8;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.brk-modal-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.brk-modal-body {
  overflow-y: auto;
  padding: 20px 24px 24px;
  flex: 1 1 auto;
}

/* ----- Intro -------------------------------------------------------- */
.brk-intro {
  margin-bottom: 18px;
}
.brk-intro-lead {
  margin: 0 0 6px;
  color: #d5d7da;
  line-height: 1.5;
}
.brk-intro-meta {
  font-size: 12.5px;
  color: #8a8d92;
}

/* ----- Section ------------------------------------------------------ */
.brk-section { margin-top: 18px; }
.brk-section-secondary { opacity: 0.85; }
.brk-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}
.brk-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ----- Connection cards -------------------------------------------- */
.brk-connections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brk-conn-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brk-conn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brk-conn-broker {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}
.brk-conn-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #9aa0a6;
  margin-top: 2px;
}
.brk-conn-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.brk-conn-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.brk-conn-status-active  { color: #4caf83; background: rgba(76, 175, 131, 0.12); }
.brk-conn-status-pending { color: #d9a341; background: rgba(217, 163, 65, 0.12); }
.brk-conn-status-error   { color: #d96a6a; background: rgba(217, 106, 106, 0.12); }

.brk-conn-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.brk-conn-accounts {
  list-style: none;
  margin: 4px 0 0;
  padding: 8px 0 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.07);
}
.brk-conn-accounts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13.5px;
}
.brk-conn-account-name {
  color: #d5d7da;
}
.brk-conn-account-num {
  color: #80858a;
  font-size: 12px;
  margin-left: 6px;
}
.brk-conn-account-bal {
  color: #fff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.brk-conn-account-ccy {
  color: #80858a;
  font-size: 12px;
  margin-left: 4px;
  font-weight: 400;
}

/* ----- Iter 12EP — alias edit ------------------------------------ */
.brk-conn-account-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brk-acct-alias-btn {
  background: transparent;
  border: none;
  color: #80858a;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
}
.brk-acct-alias-btn:hover {
  color: #d5d7da;
  background: rgba(255, 255, 255, 0.06);
}
.brk-conn-account-sub {
  color: #80858a;
  font-size: 11.5px;
  margin-top: 2px;
  letter-spacing: 0.01em;
}
.brk-alias-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.brk-alias-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #fff;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
}
.brk-alias-input:focus {
  outline: none;
  border-color: rgba(99, 138, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
}
.brk-alias-edit .brk-btn {
  font-size: 12px;
  padding: 4px 10px;
}

/* ----- Empty state ------------------------------------------------- */
.brk-empty {
  text-align: center;
  padding: 26px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.brk-empty-icon {
  font-size: 38px;
  line-height: 1;
  margin-bottom: 8px;
  filter: grayscale(0.2);
}
.brk-empty-text {
  font-weight: 600;
  color: #d5d7da;
  margin-bottom: 4px;
}
.brk-empty-hint {
  font-size: 13px;
  color: #8a8d92;
}

/* ----- Info list --------------------------------------------------- */
.brk-info-list {
  margin: 0;
  padding-left: 20px;
  color: #c2c5c9;
  font-size: 13.5px;
  line-height: 1.55;
}
.brk-info-list li { margin-bottom: 4px; }
.brk-info-list strong { color: #fff; }

/* ----- Buttons ----------------------------------------------------- */
.brk-btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
}
.brk-btn:active { transform: translateY(1px); }
.brk-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.brk-btn-primary {
  background: #4F98A3;
  color: #fff;
  border-color: #4F98A3;
}
.brk-btn-primary:hover:not(:disabled) { background: #5fa8b3; }
.brk-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #e8e8ea;
  border-color: rgba(255, 255, 255, 0.12);
}
.brk-btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.brk-btn-ghost {
  background: transparent;
  color: #b0b3b8;
  border-color: rgba(255, 255, 255, 0.12);
}
.brk-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.brk-btn-danger {
  background: transparent;
  color: #d96a6a;
  border-color: rgba(217, 106, 106, 0.4);
}
.brk-btn-danger:hover:not(:disabled) {
  background: rgba(217, 106, 106, 0.12);
  border-color: #d96a6a;
}

/* ----- Connection Portal iframe view ------------------------------ */
.brk-portal-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 18px;
}
.brk-portal-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brk-portal-title {
  font-size: 14px;
  color: #c2c5c9;
}
.brk-portal-frame-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 540px;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1114;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.brk-portal-frame-wrap iframe {
  width: 100%;
  height: 100%;
  min-height: 540px;
  border: 0;
  display: block;
}
.brk-portal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #b0b3b8;
  font-size: 13px;
  background: #0d1114;
  z-index: 2;
}
.brk-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #4F98A3;
  border-radius: 50%;
  animation: brk-spin 0.8s linear infinite;
}
@keyframes brk-spin { to { transform: rotate(360deg); } }

/* ----- Result view ------------------------------------------------ */
.brk-result {
  text-align: center;
  padding: 36px 16px 24px;
}
.brk-result-icon {
  font-size: 44px;
  margin-bottom: 10px;
}
.brk-result-icon.brk-result-icon-error { color: #d96a6a; }
.brk-result-title {
  margin: 0 0 6px;
  font-size: 18px;
  color: #fff;
}
.brk-result-detail {
  color: #b0b3b8;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.brk-result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ----- Small screens ---------------------------------------------- */
@media (max-width: 600px) {
  .brk-modal { width: 96vw; max-height: 96vh; }
  .brk-modal-body { padding: 16px 14px 18px; }
  .brk-section-head { flex-direction: column; align-items: stretch; }
  .brk-conn-actions { width: 100%; justify-content: flex-end; }
  .brk-portal-frame-wrap, .brk-portal-frame-wrap iframe { min-height: 60vh; }
}

/* === GDPR delete-all footer (Iter 12DQ) ===================================
   SnapTrade compliance: a visible "Disconnect all & delete data" CTA at the
   bottom of the connection list, separated by a hairline so it doesn't compete
   with per-connection actions. Layout mirrors .brk-conn-card so the footer
   reads as a meta row, not a primary action. */
.brk-gdpr-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 16px 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 2px solid rgba(255, 80, 80, 0.16);
  border-radius: 10px;
  background: rgba(255, 80, 80, 0.04);
}
.brk-gdpr-text {
  flex: 1 1 auto;
  min-width: 0;
  color: #cfd2d6;
  font-size: 13.5px;
}
.brk-gdpr-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #f5f5f7;
  margin-bottom: 4px;
}
.brk-gdpr-hint {
  color: #9aa0a6;
  font-size: 12.5px;
  line-height: 1.5;
}
.brk-gdpr-footer .brk-btn-danger {
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 540px) {
  .brk-gdpr-footer { flex-direction: column; align-items: stretch; }
  .brk-gdpr-footer .brk-btn-danger { width: 100%; }
}

/* Iter 15k — Broker logo at the top-left of each connection card. Sits in
   .brk-conn-head-left next to the broker name + status meta. 36px square,
   rounded corners, contains either an <img> (Clearbit) or a coloured
   initials badge fallback. */
.brk-conn-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}
.brk-broker-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}
.brk-broker-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.brk-broker-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
