/* MPGS Sample Web App - Blue Theme */

:root {
  --primary: #1976D2;
  --primary-dark: #1565C0;
  --primary-light: #42A5F5;
  --secondary: #0D47A1;
  --background: #F5F7FA;
  --surface: #FFFFFF;
  --text-primary: #212121;
  --text-secondary: #757575;
  --success: #4CAF50;
  --success-light: #E8F5E9;
  --error: #F44336;
  --error-light: #FFEBEE;
  --warning: #FF9800;
  --border: #E0E0E0;
  --shadow: rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.page-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 24px;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px var(--shadow);
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-header p {
  opacity: 0.9;
  font-size: 14px;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 12px var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header .icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
  color: var(--primary);
}

/* Grid Layout */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Two Column Layout */
.two-column {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
}

@media (max-width: 900px) {
  .two-column {
    grid-template-columns: 1fr;
  }
}

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

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.form-group input.valid {
  border-color: var(--success);
}

.form-group input.invalid {
  border-color: var(--error);
}

.form-group .error-message {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 500px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Hosted Fields */
.hosted-field {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.hosted-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.hosted-field.valid {
  border-color: var(--success);
}

.hosted-field.invalid {
  border-color: var(--error);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover {
  background: rgba(25, 118, 210, 0.05);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #388E3C 100%);
  color: white;
}

.btn-error {
  background: linear-gradient(135deg, var(--error) 0%, #C62828 100%);
  color: white;
}

.btn-full {
  width: 100%;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-group label {
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--primary);
  background: rgba(25, 118, 210, 0.05);
}

.tab.active {
  color: var(--primary);
  background: rgba(25, 118, 210, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Order Summary */
.order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.order-item:last-child {
  border-bottom: none;
}

.order-item-name {
  font-weight: 500;
}

.order-item-details {
  font-size: 13px;
  color: var(--text-secondary);
}

.order-item-price {
  font-weight: 600;
  color: var(--primary);
}

.order-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.order-summary-row.total {
  font-size: 18px;
  font-weight: 700;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 2px solid var(--primary);
  color: var(--primary);
}

/* Card Info Display */
.card-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--background);
  border-radius: var(--radius);
  margin-top: 12px;
}

.card-info img {
  height: 32px;
}

.card-info-details {
  flex: 1;
}

.card-info-scheme {
  font-weight: 600;
}

.card-info-funding {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Test Cards Panel */
.test-cards-panel {
  background: #FFFDE7;
  border: 1px solid #FFF59D;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  font-size: 13px;
}

.test-cards-panel h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.test-cards-panel table {
  width: 100%;
  font-family: "Monaco", "Consolas", monospace;
  font-size: 12px;
}

.test-cards-panel td {
  padding: 4px 8px 4px 0;
}

.test-cards-panel .card-type {
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
}

.test-cards-panel .card-number {
  letter-spacing: 0.5px;
}

.test-cards-panel .info-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #FFF59D;
  color: var(--text-secondary);
}

/* Debug Log Panel */
.debug-panel {
  background: #263238;
  border-radius: var(--radius);
  overflow: hidden;
  font-family: "Monaco", "Consolas", monospace;
  font-size: 12px;
}

.debug-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1E272C;
  color: #90A4AE;
}

.debug-panel-header h4 {
  font-size: 13px;
  font-weight: 500;
}

.debug-panel-content {
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
}

.debug-entry {
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: #1E272C;
}

.debug-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #90A4AE;
  cursor: pointer;
}

.debug-entry-header:hover {
  color: white;
}

.debug-entry.success .debug-entry-header {
  color: #81C784;
}

.debug-entry.error .debug-entry-header {
  color: #E57373;
}

.debug-entry-time {
  color: #546E7A;
}

.debug-entry-method {
  font-weight: 600;
}

.debug-entry-path {
  flex: 1;
}

.debug-entry-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.debug-entry.success .debug-entry-status {
  background: rgba(129, 199, 132, 0.2);
}

.debug-entry.error .debug-entry-status {
  background: rgba(229, 115, 115, 0.2);
}

.debug-entry-duration {
  color: #78909C;
}

.debug-entry-body {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #37474F;
}

.debug-entry.expanded .debug-entry-body {
  display: block;
}

.debug-entry-body pre {
  color: #CFD8DC;
  white-space: pre-wrap;
  word-break: break-all;
}

.debug-entry-body .label {
  color: #78909C;
  margin-bottom: 4px;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

.spinner-dark {
  border-color: rgba(25, 118, 210, 0.3);
  border-top-color: var(--primary);
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay .spinner {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  margin-bottom: 10px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

/* Result Pages */
.result-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.result-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.result-icon.error {
  background: var(--error-light);
  color: var(--error);
}

.result-icon svg {
  width: 40px;
  height: 40px;
}

.result-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.result-details {
  background: var(--background);
  border-radius: var(--radius);
  padding: 16px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.result-row-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.result-row-value {
  font-weight: 500;
}

/* Expandable Sections */
.expandable {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.expandable-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--background);
  border-radius: var(--radius);
}

.expandable-header:hover {
  background: #ECEFF1;
}

.expandable-header h4 {
  font-size: 14px;
  font-weight: 500;
}

.expandable-header .chevron {
  transition: transform 0.2s;
}

.expandable.expanded .expandable-header .chevron {
  transform: rotate(180deg);
}

.expandable-content {
  display: none;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.expandable.expanded .expandable-content {
  display: block;
}

.expandable-content pre {
  background: #263238;
  color: #CFD8DC;
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 12px;
}

/* Wallet Buttons */
.wallet-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wallet-btn {
  height: 48px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.wallet-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.wallet-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.wallet-btn-apple {
  background: #000;
  color: #fff;
}

.wallet-btn-google {
  background: #fff;
  color: #3c4043;
  border: 1px solid var(--border);
}

.wallet-btn-google img {
  height: 20px;
}

.wallet-not-available {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Modal / Lightbox */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* 3DS Challenge Lightbox */
.threeds-lightbox {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 500px;
  max-width: 95vw;
  height: 600px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
}

.threeds-lightbox iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.threeds-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

/* Payment Method Selection */
.payment-method-options {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.payment-method-option {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.payment-method-option:hover {
  border-color: var(--primary-light);
}

.payment-method-option.selected {
  border-color: var(--primary);
  background: rgba(25, 118, 210, 0.05);
}

.payment-method-option img {
  height: 32px;
  margin-bottom: 8px;
}

.payment-method-option span {
  display: block;
  font-size: 14px;
  font-weight: 500;
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-secondary);
}

.text-success {
  color: var(--success);
}

.text-error {
  color: var(--error);
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}

/* Sticky sidebar */
.sticky {
  position: sticky;
  top: 20px;
}
