/* ========================================
   Dynamic QRIS — Design System
   ======================================== */

:root {
  --qris-red: #e30019;
  --qris-red-dark: #b8000f;
  --qris-red-light: rgba(227, 0, 25, 0.08);

  --navy-900: #061840;
  --navy-800: #0b2562;
  --navy-700: #0d3380;

  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;

  --text-900: #0f1623;
  --text-600: #4b5563;
  --text-400: #9ca3af;

  --border: #e5e7eb;
  --border-focus: rgba(227, 0, 25, 0.4);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 2px 8px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.08);
  --shadow-payment: 0 8px 40px rgba(6,24,64,0.35), 0 2px 8px rgba(0,0,0,0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition: 200ms ease;
}

/* ===== Reset ===== */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-900);
  min-height: 100vh;
}

/* ===== Layout ===== */

.container {
  max-width: 440px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

/* ===== Header ===== */

.header {
  margin-bottom: 28px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-qris-icon {
  flex-shrink: 0;
}

.header-brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-900);
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.header-sub {
  font-size: 0.8rem;
  color: var(--text-400);
  font-weight: 400;
  margin-top: 2px;
}

/* ===== Form Card ===== */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.form-card-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-400);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-400);
  flex-shrink: 0;
  transition: background var(--transition);
}

.status-dot.loaded { background: #22c55e; }
.status-dot.error  { background: var(--qris-red); }

.status-text.loaded { color: #16a34a; }
.status-text.error  { color: var(--qris-red); }

/* ===== Form Groups ===== */

.form-group {
  margin-bottom: 18px;
}

label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-600);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field-optional {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-400);
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}

.amount-field {
  position: relative;
  display: flex;
  align-items: center;
}

.amount-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-600);
  pointer-events: none;
  z-index: 1;
  line-height: 1;
}

.amount-field input[type="text"] {
  padding: 13px 14px 13px 50px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-900);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-900);
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: var(--text-400);
  font-weight: 400;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(227, 0, 25, 0.08);
}

/* ===== Generate Button ===== */

.btn-generate {
  width: 100%;
  padding: 15px 20px;
  background: var(--qris-red);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 6px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn-generate:hover {
  background: var(--qris-red-dark);
  box-shadow: 0 4px 16px rgba(227, 0, 25, 0.3);
  transform: translateY(-1px);
}

.btn-generate:active {
  transform: translateY(0);
  box-shadow: none;
}

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

.btn-arrow {
  transition: transform var(--transition);
}

.btn-generate:hover .btn-arrow {
  transform: translateX(3px);
}

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
  flex-shrink: 0;
}

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

/* ===== Error Banner ===== */

.error-banner {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(227, 0, 25, 0.06);
  border: 1px solid rgba(227, 0, 25, 0.2);
  border-radius: var(--radius-md);
  color: #b91c1c;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: fadeSlideUp 0.25s ease;
}

/* ===== QRIS Payment Card ===== */

.payment-card {
  margin-top: 24px;
  background: linear-gradient(165deg, var(--navy-700) 0%, var(--navy-900) 100%);
  border-radius: var(--radius-xl);
  padding: 24px 22px 28px;
  color: white;
  box-shadow: var(--shadow-payment);
  animation: fadeSlideUp 0.35s ease;
  position: relative;
  overflow: hidden;
}

.payment-card::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  pointer-events: none;
}

.payment-card::after {
  content: "";
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255,255,255,0.02);
  border-radius: 50%;
  pointer-events: none;
}

.payment-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.qris-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qris-ready-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}

.gpn-badge {
  opacity: 0.85;
}

.payment-card-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin-bottom: 20px;
}

.payment-merchant-info {
  text-align: center;
  margin-bottom: 18px;
}

.merchant-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: white;
  text-transform: uppercase;
}

/* ===== QR Code Area ===== */

.payment-qr-area {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.payment-qr-frame {
  background: white;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.payment-qr-frame img {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: var(--radius-sm);
}

/* ===== Payment Details ===== */

.payment-details {
  text-align: center;
}

.payment-amount {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: white;
  line-height: 1.1;
  margin-bottom: 6px;
}

.payment-remarks {
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  min-height: 22px;
  margin-bottom: 14px;
}

.payment-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* ===== Result Actions ===== */

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  animation: fadeSlideUp 0.35s ease 0.1s both;
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-600);
  font-family: "Inter", sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-card);
}

.btn-action:hover {
  background: var(--surface-2);
  border-color: #d1d5db;
  color: var(--text-900);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card-hover);
}

.btn-action:active {
  transform: translateY(0);
  box-shadow: var(--shadow-card);
}

/* ===== QRIS String Collapsible ===== */

.qris-string-detail {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: fadeSlideUp 0.35s ease 0.15s both;
}

.qris-string-detail summary {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-400);
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color var(--transition);
}

.qris-string-detail summary::before {
  content: "▸";
  font-size: 0.7rem;
  transition: transform 150ms ease;
}

.qris-string-detail[open] summary::before {
  transform: rotate(90deg);
}

.qris-string-detail summary:hover {
  color: var(--text-600);
}

.qris-string-detail code {
  display: block;
  padding: 12px 16px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.72rem;
  color: var(--text-600);
  word-break: break-all;
  line-height: 1.7;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ===== Footer ===== */

.footer {
  text-align: center;
  margin-top: 48px;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-400);
  letter-spacing: 0.2px;
}

/* ===== Animations ===== */

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

/* ===== Send Button variant ===== */

.btn-action-primary {
  background: var(--qris-red);
  border-color: var(--qris-red);
  color: white;
}

.btn-action-primary:hover {
  background: var(--qris-red-dark);
  border-color: var(--qris-red-dark);
  color: white;
  transform: translateY(-1px);
}

/* ===== Modal Overlay ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 35, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.12);
  animation: slideUp 0.22s ease;
  overflow: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== Modal Header ===== */

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

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-900);
}

.modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-600);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--border);
  color: var(--text-900);
}

/* ===== Modal Search ===== */

.modal-search-wrap {
  position: relative;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-400);
  pointer-events: none;
}

.contact-search-input {
  width: 100%;
  padding: 10px 12px 10px 36px !important;
  font-size: 0.9rem !important;
  font-weight: 400 !important;
}

/* ===== Contact List ===== */

.contact-list-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 220px;
  max-height: 320px;
}

.contact-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  font-size: 0.85rem;
  color: var(--text-400);
  text-align: center;
  height: 100%;
  min-height: 200px;
}

.contact-state-error {
  color: #b91c1c;
}

.spinner-muted {
  border-color: rgba(0,0,0,0.1) !important;
  border-top-color: var(--text-400) !important;
  width: 20px !important;
  height: 20px !important;
}

.contact-list {
  padding: 4px 0;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background var(--transition);
}

.contact-item:hover {
  background: var(--surface-2);
}

.contact-item.selected {
  background: var(--qris-red-light);
}

.contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-900);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-phone {
  font-size: 0.75rem;
  color: var(--text-400);
  display: block;
  margin-top: 1px;
}

.contact-check {
  color: var(--qris-red);
  display: none;
  flex-shrink: 0;
}

.contact-item.selected .contact-check {
  display: flex;
}

/* ===== Modal Footer ===== */

.modal-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.selected-contact-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--qris-red-light);
  border-radius: var(--radius-md);
  border: 1px solid rgba(227,0,25,0.15);
}

.selected-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.selected-meta {
  flex: 1;
  min-width: 0;
}

.selected-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-900);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-phone {
  font-size: 0.72rem;
  color: var(--text-400);
  display: block;
}

.btn-confirm-send {
  width: 100%;
  padding: 14px 16px;
  background: var(--qris-red);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-confirm-send:disabled {
  background: var(--border);
  color: var(--text-400);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-confirm-send:not(:disabled):hover {
  background: var(--qris-red-dark);
  box-shadow: 0 4px 14px rgba(227,0,25,0.3);
}

/* ===== Send Success Overlay ===== */

.modal-card {
  position: relative; /* needed for success overlay */
}

.modal-success-overlay {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border-radius: var(--radius-xl);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  flex: 1;
  gap: 12px;
}

.modal-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(22, 163, 74, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #16a34a;
}

.modal-success p {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-900);
}

.modal-success span {
  font-size: 0.8rem;
  color: var(--text-400);
}

/* ===== Responsive ===== */

@media (max-width: 480px) {
  .container {
    padding: 28px 16px 48px;
  }

  .form-card {
    padding: 20px;
  }

  .payment-card {
    padding: 20px 18px 24px;
  }

  .payment-qr-frame img {
    width: 190px;
    height: 190px;
  }

  .payment-amount {
    font-size: 1.5rem;
  }

  .header-brand h1 {
    font-size: 1.3rem;
  }
}

/* ===== Login / Logout ===== */

.login-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.btn-logout {
  margin-left: auto;
  padding: 8px 12px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-600);
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-logout:hover {
  border-color: var(--qris-red);
  color: var(--qris-red);
}
