/* ==========================================================================
   AUTOGRADING - BENTO SUBSCRIPTION & TERMS MODAL STYLING
   Bento Grid & Neo-Minimalism for AI Quotas, VietQR, Privacy & SLA
   Strictly <= 300 LOC, High Performance & Fully Responsive
   ========================================================================== */

/* Main Modal Header & Segmented Pill Navigation Bar */
#modal-teacher-subscription .sub-modal-header {
  flex-shrink: 0 !important;
}

#modal-teacher-subscription .sub-modal-tab-nav,
.sub-modal-tab-nav {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  min-height: 48px !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 4px !important;
  gap: 6px !important;
  overflow: visible !important;
  margin-bottom: 1rem !important;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

.sub-modal-tab-nav::-webkit-scrollbar {
  display: none;
}

#modal-teacher-subscription .sub-tab-btn,
.sub-tab-btn {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  min-height: 38px !important;
  height: 38px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 9px !important;
  padding: 0 0.75rem !important;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  color: #475569 !important;
  box-shadow: none !important;
  transform: none !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.4rem !important;
  white-space: nowrap !important;
  transition: all 0.18s ease !important;
}

#modal-teacher-subscription .sub-tab-btn:hover:not(.active),
.sub-tab-btn:hover:not(.active) {
  color: #0f172a !important;
  background: rgba(255, 255, 255, 0.65) !important;
  box-shadow: none !important;
  transform: none !important;
}

#modal-teacher-subscription .sub-tab-btn.active,
#modal-teacher-subscription .sub-tab-btn.btn-primary,
.sub-tab-btn.active,
.sub-tab-btn.btn-primary {
  background: #ffffff !important;
  color: #1e293b !important;
  font-weight: 700 !important;
  border: 1px solid rgba(15, 23, 42, 0.08) !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transform: none !important;
}

/* Trust Commitments Grid (4 Golden Pillars) */
.terms-trust-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.terms-trust-item {
  background: var(--bento-surface, #ffffff);
  border: 1px solid var(--bento-border, #e2e8f0);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.terms-trust-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.terms-trust-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.terms-trust-content {
  min-width: 0;
}

.terms-trust-title {
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--bento-text-title, #0f172a);
  line-height: 1.25;
}

.terms-trust-desc {
  font-size: 0.7rem;
  color: var(--bento-text-muted, #64748b);
  margin-top: 0.15rem;
}

/* Sticky Legal Sub-Nav Quick Access Bar */
#modal-teacher-subscription .terms-sub-nav-bar,
.terms-sub-nav-bar {
  position: sticky !important;
  top: 0 !important;
  z-index: 15 !important;
  background: #f8fafc !important;
  padding: 5px !important;
  margin-top: 0 !important;
  margin-bottom: 0.75rem !important;
  border-radius: 12px !important;
  border: 1px solid #e2e8f0 !important;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 6px !important;
  min-height: 46px !important;
  align-items: center !important;
  box-shadow: 0 -12px 0 12px #ffffff, 0 4px 10px rgba(15, 23, 42, 0.05) !important;
}

.terms-sub-nav-bar::-webkit-scrollbar {
  display: none;
}

#modal-teacher-subscription .terms-sub-nav-btn,
.terms-sub-nav-btn {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  min-height: 36px !important;
  height: 36px !important;
  padding: 0 0.75rem !important;
  font-size: 0.81rem !important;
  font-weight: 600 !important;
  color: #475569 !important;
  box-shadow: none !important;
  transform: none !important;
  cursor: pointer;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.4rem !important;
  transition: all 0.15s ease !important;
}

#modal-teacher-subscription .terms-sub-nav-btn:hover:not(.active),
.terms-sub-nav-btn:hover:not(.active) {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: none !important;
  transform: none !important;
}

#modal-teacher-subscription .terms-sub-nav-btn.active,
#modal-teacher-subscription .terms-sub-nav-btn.btn-primary,
.terms-sub-nav-btn.active,
.terms-sub-nav-btn.btn-primary {
  background: #4f46e5 !important;
  border-color: #4338ca !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.24) !important;
  transform: none !important;
}

/* Legal Policy Cards (Bento Neo-Minimalism) */
.legal-policy-card {
  background: var(--bento-surface, #ffffff);
  border: 1px solid var(--bento-border, #e2e8f0);
  border-radius: var(--bento-radius-card, 16px);
  padding: 1.15rem 1.35rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.legal-policy-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.2), transparent);
  pointer-events: none;
}

.legal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--bento-border-subtle, #f1f5f9);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.legal-card-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.legal-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.legal-card-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--bento-text-title, #0f172a);
  margin: 0;
}

.legal-badge-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid transparent;
}

.legal-badge-indigo { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.legal-badge-emerald { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.legal-badge-blue { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.legal-badge-amber { background: #fef3c7; color: #92400e; border-color: #fde68a; }

/* Feature Clause Rows inside Cards */
.legal-clauses-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.legal-clause-item {
  background: var(--bento-surface-subtle, #f8fafc);
  border: 1px solid var(--bento-border-subtle, #eef2f6);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  font-size: 0.83rem;
  line-height: 1.6;
  color: var(--bento-text-main, #334155);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.legal-clause-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

.legal-clause-header {
  font-weight: 800;
  color: var(--bento-text-title, #0f172a);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.legal-highlight-text {
  background: rgba(79, 70, 229, 0.08);
  color: #4338ca;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 700;
}

/* Tab responsive label helpers - Scoped & Enforced */
.sub-modal-tab-nav .sub-tab-desktop,
.sub-tab-desktop {
  display: inline !important;
}

.sub-modal-tab-nav .sub-tab-mobile,
.sub-tab-mobile {
  display: none !important;
}

/* Flexbox shrink protection & scroll margins for Terms tab */
#tab-terms-policies.active {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.85rem !important;
  min-height: 0 !important;
  flex: 1 1 auto !important;
  position: relative !important;
  padding: 0 4px 42vh 4px !important;
}

.terms-trust-grid,
.terms-sub-nav-bar,
.legal-policy-card {
  flex-shrink: 0 !important;
}

.terms-sub-nav-btn {
  flex-shrink: 0 !important;
}

.legal-policy-card {
  scroll-margin-top: 56px !important;
}

/* Close button styling */
.sub-modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .terms-trust-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  /* Header & close button mobile ergonomics */
  .sub-modal-header {
    padding-bottom: 0.5rem !important;
    margin-bottom: 0.65rem !important;
  }

  .sub-modal-title {
    font-size: 1.12rem !important;
    line-height: 1.25 !important;
  }

  .sub-modal-subtitle {
    font-size: 0.74rem !important;
    line-height: 1.3 !important;
  }

  .sub-modal-close-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    border-radius: 50% !important;
  }

  .sub-modal-close-btn .btn-close-text {
    display: none !important;
  }

  .sub-modal-close-btn .btn-close-icon {
    font-size: 1rem !important;
    line-height: 1 !important;
  }

  /* Segmented tab nav mobile ergonomics & scroll cue */
  #modal-teacher-subscription .sub-modal-tab-nav,
  .sub-modal-tab-nav {
    display: flex !important;
    overflow-x: auto !important;
    border-radius: 10px !important;
    mask-image: linear-gradient(to right, #000 86%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 86%, transparent 100%);
    padding: 0.25rem !important;
    gap: 0.25rem !important;
    margin-bottom: 0.75rem !important;
  }

  #modal-teacher-subscription .sub-modal-tab-nav .sub-tab-btn,
  .sub-modal-tab-nav .sub-tab-btn {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    padding: 0.4rem 0.65rem !important;
    font-size: 0.75rem !important;
    min-height: 38px !important;
    border-radius: 8px !important;
  }

  .sub-modal-tab-nav .sub-tab-desktop,
  .sub-tab-desktop {
    display: none !important;
  }

  .sub-modal-tab-nav .sub-tab-mobile,
  .sub-tab-mobile {
    display: inline !important;
  }

  /* Trust Commitments Grid (Compact 2x2 on Mobile) */
  .terms-trust-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.45rem !important;
    margin-bottom: 0.65rem !important;
  }

  .terms-trust-item {
    padding: 0.5rem 0.55rem !important;
    border-radius: 10px !important;
    gap: 0.4rem !important;
  }

  .terms-trust-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.92rem !important;
    border-radius: 6px !important;
  }

  .terms-trust-title {
    font-size: 0.72rem !important;
    line-height: 1.2 !important;
  }

  .terms-trust-desc {
    font-size: 0.63rem !important;
    line-height: 1.25 !important;
  }

  /* Sticky sub-nav mobile ergonomics */
  #modal-teacher-subscription .terms-sub-nav-bar,
  .terms-sub-nav-bar {
    display: flex !important;
    overflow-x: auto !important;
    padding: 0.35rem 0.4rem !important;
    margin-bottom: 0.65rem !important;
    gap: 0.3rem !important;
  }

  #modal-teacher-subscription .terms-sub-nav-btn,
  .terms-sub-nav-btn {
    flex: 0 0 auto !important;
    padding: 0.3rem 0.55rem !important;
    font-size: 0.72rem !important;
    min-height: 34px !important;
    border-radius: 7px !important;
  }

  /* Legal policy cards mobile readability */
  .legal-policy-card {
    padding: 0.85rem !important;
    border-radius: 12px !important;
  }

  .legal-card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.35rem !important;
    padding-bottom: 0.45rem !important;
    margin-bottom: 0.55rem !important;
  }

  .legal-card-title {
    font-size: 0.92rem !important;
    line-height: 1.35 !important;
  }

  .legal-card-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.95rem !important;
    border-radius: 7px !important;
  }

  .legal-badge-pill {
    font-size: 0.65rem !important;
    padding: 0.15rem 0.45rem !important;
  }

  .legal-clauses-list {
    gap: 0.5rem !important;
  }

  .legal-clause-item {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.78rem !important;
    line-height: 1.5 !important;
    border-radius: 8px !important;
  }

  .legal-clause-header {
    font-size: 0.8rem !important;
    margin-bottom: 0.2rem !important;
  }
}

/* VietQR Ergonomics & App-to-App Transfer Card */
.btn-save-qr {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  color: var(--bento-text-title, #1e293b) !important;
  border-color: var(--bento-border, #cbd5e1) !important;
}

.btn-save-qr:hover {
  background: var(--bento-surface-subtle, #f1f5f9) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08) !important;
}

.btn-save-qr:active {
  transform: translateY(0);
}

.vietqr-app-transfer-card {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.vietqr-app-transfer-card:focus-within {
  border-color: var(--bento-accent-primary, #3b82f6) !important;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.12);
}

#select-bank-app:focus {
  outline: none;
  border-color: var(--bento-accent-primary, #3b82f6) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

#btn-open-bank-app {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#btn-open-bank-app:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28) !important;
}

#btn-open-bank-app:active {
  transform: translateY(0);
}

/* Searchable Bank Combobox Styling */
.bank-combobox-wrapper {
  position: relative;
  width: 100%;
}

.bank-search-input-box input:focus {
  outline: none;
  border-color: var(--bento-accent-primary, #3b82f6) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

.bank-dropdown-list {
  scrollbar-width: thin;
}

.bank-dropdown-list::-webkit-scrollbar {
  width: 6px;
}

.bank-dropdown-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 999px;
}

.bank-dropdown-item:hover,
.bank-dropdown-item:focus {
  background: var(--bento-surface-subtle, #f1f5f9) !important;
  outline: none;
}

.bank-dropdown-item.selected {
  background: #eff6ff !important;
}

[data-theme="dark"] .bank-dropdown-list {
  background: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] .bank-dropdown-item {
  border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .bank-dropdown-item:hover,
[data-theme="dark"] .bank-dropdown-item:focus {
  background: #334155 !important;
}

[data-theme="dark"] .bank-dropdown-item.selected {
  background: rgba(59, 130, 246, 0.2) !important;
}

[data-theme="dark"] #bank-selected-chip {
  background: rgba(59, 130, 246, 0.18) !important;
  border-color: rgba(59, 130, 246, 0.35) !important;
  color: #93c5fd !important;
}

/* Unified Wallet 3-Bucket, 4-Cycle Switcher & Workload Calculator Responsive Rules (320px -> 1440px) */
[data-theme="dark"] .workload-calculator-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border-color: #334155 !important;
}

@media (max-width: 640px) {
  #modal-teacher-subscription .modal-content {
    padding: 0.85rem !important;
    width: 96vw !important;
    max-width: 96vw !important;
  }

  #modal-teacher-subscription .pricing-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  #modal-teacher-subscription .cycle-switcher-wrapper {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    border-radius: 12px !important;
  }

  #modal-teacher-subscription .cycle-switch-btn {
    width: 100% !important;
    min-height: 38px !important;
    padding: 0.35rem 0.45rem !important;
    font-size: 0.75rem !important;
    text-align: center !important;
  }

  #sub-quota-breakdown {
    grid-template-columns: 1fr !important;
  }

  .workload-calculator-card {
    padding: 0.8rem !important;
  }
}



