/* ============ PAYMENT MODAL ============ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.payment-modal {
  background: white;
  width: 90%;
  max-width: 450px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-overlay.active .payment-modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 24px 24px 16px;
  text-align: center;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #f3f4f6;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  transition: background 0.2s;
}

.modal-close:hover {
  background: #e5e7eb;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.modal-body {
  padding: 0 24px 24px;
  overflow-y: auto;
}

/* Steps */
.payment-step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.payment-step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Amounts */
.amount-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.amount-btn {
  background: #f9fafb;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.amount-btn:hover {
  background: #f3f4f6;
  border-color: rgba(16, 185, 129, 0.2);
}

.amount-btn.selected {
  background: #10b981;
  color: white;
  border-color: #10b981;
  transform: scale(1.02);
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
}

.amount-btn .amount-val {
  font-size: 1.125rem;
  font-weight: 700;
  display: block;
}

.amount-btn .amount-desc {
  font-size: 0.75rem;
  opacity: 0.8;
  display: block;
  margin-top: 4px;
  line-height: 1.2;
}

.amount-badge {
  position: absolute;
  top: -10px;
  right: 10px;
  background: white;
  color: #10b981;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 99px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.amount-btn.selected .amount-badge {
  background: white;
  color: #10b981;
}

.custom-amount-input {
  width: 100%;
  height: 56px;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  padding: 0 20px 0 40px;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 24px;
  outline: none;
  transition: border-color 0.2s;
}

.custom-amount-input:focus {
  border-color: #10b981;
}

.custom-amount-wrapper {
  position: relative;
}

.custom-amount-wrapper::before {
  content: "€";
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  font-weight: 600;
}

/* Method Selection */
.method-summary {
  background: rgba(16, 185, 129, 0.1);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  margin-bottom: 24px;
}

.method-summary p {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.method-summary h3 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #10b981;
  margin: 0;
}

.method-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.method-btn:hover {
  border-color: rgba(16, 185, 129, 0.5);
}

.method-btn.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.05);
}

.method-icon {
  width: 48px;
  height: 48px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #10b981;
  flex-shrink: 0;
}

.method-info flex {
  flex: 1;
}

.method-title {
  font-weight: 600;
  color: #111827;
  display: block;
}

.method-desc {
  font-size: 0.75rem;
  color: #6b7280;
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: #111827;
}

.input-with-icon {
  position: relative;
}

.input-with-icon svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  width: 18px;
  height: 18px;
}

.input-with-icon input {
  width: 100%;
  height: 52px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 0 16px 0 44px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-icon input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Buttons */
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn-modal-primary {
  flex: 1;
  height: 52px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-modal-primary:hover {
  background: #0d9488;
}

.btn-modal-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-modal-secondary {
  flex: 1;
  height: 52px;
  background: white;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-secondary:hover {
  background: #f3f4f6;
}

/* Spinner */
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(16, 185, 129, 0.2);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Multibanco Box */
.mb-box {
  background: #f3f4f6;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
}

.mb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.mb-row:last-child {
  border-bottom: none;
}

.mb-label {
  font-size: 0.875rem;
  color: #6b7280;
}

.mb-value {
  font-size: 1.125rem;
  font-family: monospace;
  font-weight: 700;
  color: #111827;
}

.mb-value-primary {
  color: #10b981;
}

/* ============ MOBILE BOTTOM SHEET (APP-LIKE) ============ */
@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-end;
  }

  .payment-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 28px 28px 0 0;
    transform: translateY(100%) scale(1);
    padding-bottom: 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
  }

  .modal-overlay.active .payment-modal {
    transform: translateY(0) scale(1);
  }

  .modal-header {
    padding: 20px 20px 10px;
    flex-shrink: 0;
  }

  .modal-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 6px;
  }

  .modal-title {
    font-size: 1.05rem;
    line-height: 1.3;
    padding-right: 30px;
  }

  .modal-body {
    padding: 0 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 16px));
  }

  .amount-grid {
    gap: 8px;
    margin-bottom: 16px;
  }

  .amount-btn {
    padding: 12px 10px;
  }

  .amount-btn .amount-val {
    font-size: 1rem;
  }

  .amount-btn .amount-desc {
    font-size: 0.7rem;
  }

  /* Make primary button sticky at bottom */
  .btn-modal-primary {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    border-radius: 0;
    z-index: 10001;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  
  .btn-modal-secondary,
  .input-with-icon input,
  .custom-amount-input {
    height: 52px;
  }

  .step-question {
    font-size: 0.9rem;
    margin-bottom: 12px;
  }
}
