/* Critical inline styles extracted from dashboard.html */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
  font-family: 'Inter', sans-serif;
}

.modal-content.billing-modal,
.modal-content.account-modal {
  max-width: 720px;
  background: rgba(8, 10, 20, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-content.billing-modal h3,
.modal-content.account-modal h3 {
  font-size: 1.6rem;
}

.billing-modal-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 900px) {
  .billing-modal-grid {
    flex-direction: row;
  }
}

.billing-card,
.billing-help-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 1.25rem;
}

.billing-plan-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.billing-plan-name {
  font-size: 1.35rem;
  font-weight: 600;
}

.billing-plan-meta,
.billing-plan-status,
.billing-plan-renewal {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.billing-plan-status {
  text-transform: capitalize;
}

.billing-plan-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.billing-metric {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.billing-metric span {
  display: block;
}

.billing-metric-label {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.billing-metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.billing-plan-features {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 1rem;
  margin-bottom: 1rem;
}

.billing-plan-features ul {
  margin: 0;
  padding: 0;
}

.billing-plan-features li {
  list-style: none;
  margin-bottom: 0.45rem;
  color: rgba(255, 255, 255, 0.85);
  position: relative;
  padding-left: 1.4rem;
  font-size: 0.95rem;
}

.billing-plan-features li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: #ff89f0;
}

.billing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.billing-plan-price {
  text-align: right;
}

.billing-plan-amount {
  font-size: 1.9rem;
  font-weight: 700;
}

.billing-plan-price-note {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.85rem;
}

.billing-button,
.account-action {
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
}

.billing-button {
  background: linear-gradient(135deg, #7f7cff, #6de1ff);
  color: #05060f;
}

.billing-button--secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.billing-status {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
  min-height: 1.2rem;
}

.billing-help-card ul {
  margin-top: 0.75rem;
  padding-left: 1.2rem;
  color: rgba(255, 255, 255, 0.78);
}

.account-warning {
  background: rgba(255, 99, 132, 0.12);
  border: 1px solid rgba(255, 99, 132, 0.4);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1.1rem;
  color: rgba(255, 255, 255, 0.85);
}

.account-list {
  margin: 0;
  padding-left: 1.2rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.6;
}

.account-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.account-action.primary {
  background: linear-gradient(135deg, #ff6b6b, #ff3b3b);
  color: #fff;
}

.account-action.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.account-modal-head {
  margin-bottom: 1.5rem;
}

.account-modal-head p {
  color: rgba(255, 255, 255, 0.75);
  margin-top: 0.35rem;
}

.account-modal-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.account-card {
  flex: 1 1 280px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 1.25rem;
}

.account-card h4 {
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
}

.settings-checkbox {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  margin-top: 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 0.15rem;
  accent-color: #7f7cff;
  flex-shrink: 0;
}

.settings-checkbox .checkbox-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}

.settings-checkbox .checkbox-copy {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.3rem;
  line-height: 1.4;
}

.account-avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.account-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-outline {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.account-form label {
  display: block;
  margin-bottom: 1rem;
}

.account-form span {
  display: block;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 0.35rem;
}

.account-form input,
.account-form textarea,
.account-form select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}

.account-form select option {
  color: #05060f;
  background: #fff;
}

.account-form textarea {
  min-height: 100px;
  resize: vertical;
}

.account-divider {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 1rem 0 1.5rem;
}

.danger-card {
  background: rgba(255, 99, 132, 0.12);
  border: 1px solid rgba(255, 99, 132, 0.3);
}

.account-help {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.4rem;
}

.account-phone-note {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.35rem;
}

.personalization-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 1rem 1.5rem;
  margin: 2rem auto 1.5rem;
  width: min(700px, 100%);
}

.personalization-banner p {
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
}

.personalization-banner button {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  background: linear-gradient(135deg, #ff89f0, #7f7cff);
  color: #05060f;
  cursor: pointer;
}

.personalization-banner[hidden] {
  display: none;
}

.personalization-banner .banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-save {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, #ff89f0, #7f7cff);
  color: #05060f;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.btn-save:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-save--success {
  background: rgba(16, 185, 129, 0.15);
  color: #22d3a6;
  box-shadow: 0 0 0 1px rgba(34, 211, 166, 0.35) inset;
}

/* Settings Modal - Location Grid */
.location-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.75rem;
  max-width: 100%;
  overflow: hidden;
}

.location-grid label {
  min-width: 0;
}

.location-grid input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .location-grid {
    grid-template-columns: 1fr 1fr;
  }
  .location-grid label:first-child {
    grid-column: 1 / -1;
  }
}

/* Settings Modal responsive */
.modal-content {
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Prevent overflow in forms */
.modal-content form,
.modal-content div[style*="background"] {
  max-width: 100%;
  overflow: hidden;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.modal-content label {
  min-width: 0;
  max-width: 100%;
}

/* ============================================
   MOBILE RESPONSIVE FIXES FOR MODALS
   ============================================ */

/* Settings Modal - Identity grids */
.settings-identity-grid,
.settings-identity-grid-alt {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .settings-identity-grid,
  .settings-identity-grid-alt {
    grid-template-columns: 1fr;
  }
}

/* Account Modal - Profile Photos Grid */
.account-photos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 520px) {
  .account-photos-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* Account Modal - Avatar item layout */
.account-avatar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  min-width: 0;
  max-width: 100%;
}

.account-avatar-item img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.account-avatar-item .avatar-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.account-avatar-item .avatar-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
}

.account-avatar-item .avatar-actions button {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  max-width: 80px;
}

@media (max-width: 400px) {
  .account-avatar-item .avatar-actions {
    flex-direction: column;
    align-items: center;
  }
  .account-avatar-item .avatar-actions button {
    max-width: 100%;
    width: 100%;
  }
}

/* Account Modal - Details Grid */
.account-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .account-details-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   MOBILE MODAL FIXES - iOS Safe Area + Bottom Nav
   ============================================ */

/* Fix modal overlay to account for iOS safe areas */
@media (max-width: 768px) {
  .modal-overlay {
    padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 12px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 12px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 80px); /* Extra space for browser nav */
  }

  .modal-content {
    max-height: calc(100vh - env(safe-area-inset-top, 20px) - env(safe-area-inset-bottom, 20px) - 100px);
    max-height: calc(100dvh - env(safe-area-inset-top, 20px) - env(safe-area-inset-bottom, 20px) - 100px);
    margin: 0;
    border-radius: 20px;
    padding: 1.25rem;
    padding-top: 3rem; /* Space for close button */
    padding-bottom: 1.5rem;
  }

  /* Ensure close button is always visible and tappable */
  .modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.75rem;
    z-index: 100;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }

  /* Modal footer should be sticky at bottom with proper spacing */
  .modal-footer,
  .modal-footer--stack {
    position: sticky;
    bottom: 0;
    background: inherit;
    padding-top: 1rem;
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    margin-top: 1rem;
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* Ensure buttons in footer are large enough to tap */
  .modal-footer button,
  .modal-footer--stack button,
  .btn-save,
  .btn-cancel,
  .btn-save--full,
  .btn-cancel--full {
    min-height: 48px;
    font-size: 1rem;
  }
}

/* Extra small screens (iPhone SE, small Android) */
@media (max-width: 380px) {
  .modal-content {
    padding: 1rem;
    padding-top: 2.75rem;
    border-radius: 16px;
    max-height: calc(100vh - 90px);
    max-height: calc(100dvh - 90px);
  }

  .modal-close {
    top: 6px;
    right: 6px;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 1.5rem;
  }

  .modal-footer,
  .modal-footer--stack {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Billing modal specific fixes */
  .billing-modal .billing-plan-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .billing-modal .billing-plan-price {
    text-align: left;
  }

  .billing-modal .billing-plan-amount {
    font-size: 1.5rem;
  }
}

/* Landscape mode on mobile - reduce height further */
@media (max-height: 500px) and (max-width: 900px) {
  .modal-content {
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    padding: 0.75rem;
    padding-top: 2.5rem;
  }

  .modal-close {
    top: 4px;
    right: 4px;
  }
}