:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --teal: #00bfa5;
  --teal-light: #e0f7f4;
  --danger: #e53935;
  --warning: #f9a825;
  --success: #43a047;
  --bg: #f8f9fc;
  --sidebar-bg: #fff;
  --card-bg: #fff;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(26,115,232,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;

  /* Bento Styling */
  --bento-radius: 24px;
  --bento-gap: 16px;
  --bento-padding: 24px;
  --bento-bg: rgba(255, 255, 255, 0.8);
  --bento-border: 1px solid rgba(0, 0, 0, 0.04);
  --bento-shadow: 0 4px 24px rgba(0, 0, 0, 0.03);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 16px; left: 16px; bottom: 16px;
  height: calc(100vh - 32px);
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-logo .logo-text span {
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  padding: 4px 8px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 16px;
  transition: all 0.2s;
}
.btn-logout:hover { color: var(--danger); background: #ffebee; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: calc(var(--sidebar-w) + 32px);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: transparent;
  border-bottom: none;
  padding: 24px 28px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.balance-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}

.page-content {
  padding: 24px 28px;
  flex: 1;
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ===== OVERVIEW BENTO ===== */
.overview-bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(180px, auto);
  gap: var(--bento-gap);
  margin-bottom: 24px;
}

.bento-card {
  background: var(--bento-bg);
  border-radius: var(--bento-radius);
  padding: var(--bento-padding);
  border: var(--bento-border);
  box-shadow: var(--bento-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.bento-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(26, 115, 232, 0.08);
}

.bento-balance { grid-column: 1 / 2; grid-row: 1 / 3; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(135deg, #e8f0fe 0%, #fff 100%); }
.bento-success { grid-column: 2 / 3; grid-row: 1 / 2; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.bento-keys { grid-column: 3 / 4; grid-row: 1 / 2; display: flex; flex-direction: column; justify-content: center; }
.bento-tasks { grid-column: 2 / 4; grid-row: 2 / 3; }

/* Responsive Overview Bento */
@media (max-width: 1024px) {
  .overview-bento {
    grid-template-columns: repeat(2, 1fr);
  }
  .bento-balance { grid-column: 1 / 2; grid-row: 1 / 2; }
  .bento-success { grid-column: 2 / 3; grid-row: 1 / 2; }
  .bento-keys { grid-column: 1 / 3; grid-row: 2 / 3; }
  .bento-tasks { grid-column: 1 / 3; grid-row: 3 / 4; }
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
  }
  .sidebar {
    top: 0; left: -100%; bottom: 0; height: 100vh;
    border-radius: 0;
    transition: left 0.3s ease;
  }
  .sidebar.active {
    left: 0;
  }
  .overview-bento {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  .bento-balance, .bento-success, .bento-keys, .bento-tasks {
    grid-column: 1 / 2; grid-row: auto;
  }
}


.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.teal { background: var(--teal-light); }
.stat-icon.green { background: #e8f5e9; }
.stat-icon.orange { background: #fff3e0; }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,115,232,0.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,115,232,0.35);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-danger {
  background: #ffebee;
  color: var(--danger);
  border: 1.5px solid #ffcdd2;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead tr { background: #f9fafb; }

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: #f9fafb; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-success { background: #e8f5e9; color: var(--success); }
.badge-danger { background: #ffebee; color: var(--danger); }
.badge-warning { background: #fff8e1; color: var(--warning); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: #f3f4f6; color: #6b7280; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

/* ===== API KEY DISPLAY ===== */
.key-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  flex: 1;
}

.key-hidden { color: var(--text-secondary); letter-spacing: 2px; }
.key-visible { color: var(--text-primary); word-break: break-all; }

/* ===== NOTIFICATIONS ===== */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { position: relative; }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  background: var(--primary);
  border-radius: 50%;
}

.notif-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.notif-text { flex: 1; }
.notif-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.notif-desc { font-size: 12px; color: var(--text-secondary); }
.notif-time { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 17px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}
.modal-close:hover { background: #f3f4f6; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--text-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease;
  min-width: 260px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state .empty-desc { font-size: 13px; }

/* ===== COPY BUTTON ===== */
.btn-copy {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
}
.btn-copy:hover { color: var(--primary); background: var(--primary-light); }

/* ===== API TEST MODAL (DUAL PANE WOW EDITION) ===== */
.modal-overlay {
  backdrop-filter: blur(10px);
  background: rgba(10, 15, 25, 0.6);
  display: flex; /* Override to handle wrapper */
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-wrapper {
  display: flex;
  gap: 24px;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 1300px;
  transform: translateY(40px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  opacity: 0;
}

.modal-overlay.active .modal-wrapper {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Modals general */
.modal-api-test, .modal-api-code {
  flex: 1;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  min-width: 0;
}

/* Grid items for API docs page - prevent content blowout */
#page-apidocs > div > div {
  min-width: 0;
  overflow: hidden;
}

/* Modal 1: The Request Form */
.modal-api-test {
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-api-test::-webkit-scrollbar { width: 6px; }
.modal-api-test::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Existing form styling... */
.api-test-endpoint-bar {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(to right, #f8fafc, #f1f5f9);
  padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 20px;
}
.api-test-method-badge { font-weight: 800; font-size: 11px; padding: 4px 12px; border-radius: 6px; color: #fff; }
.api-test-method-badge.get { background: #3b82f6; box-shadow: 0 0 8px rgba(59, 130, 246, 0.4); }
.api-test-method-badge.post { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.api-test-select { flex: 1; border: none; background: transparent; font-size: 15px; font-weight: 600; outline: none; cursor: pointer; }
.api-test-chips { display: flex; gap: 6px; }
.api-test-chip { font-size: 10px; font-weight: 600; padding: 3px 8px; background: #e2e8f0; border-radius: 4px; }
.api-test-chip.required { background: #fee2e2; color: #ef4444; }
.api-test-divider { height: 1px; background: var(--border); margin: 16px 0; }
.api-test-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.api-test-group { position: relative; }
.api-test-group.full-width { grid-column: 1 / -1; }
.api-test-group label { display: flex; justify-content: space-between; font-size: 12px; color: #475569; }
.api-test-group.required label::after { content: " *"; color: #ef4444; }
.api-test-input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #f8fafc; transition: all 0.3s;
}
.api-test-input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(26, 115, 232, 0.1); }
textarea.api-test-input { resize: vertical; min-height: 80px; }
.api-test-media-id-array { margin-top: 4px; }
.api-test-media-id-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.api-test-media-id-list .api-test-media-id-item { margin-bottom: 0; }
.api-test-media-id-row { display: flex; align-items: center; gap: 8px; }
.api-test-media-id-row .api-test-input { flex: 1; min-width: 0; }
.api-test-remove-media-id {
  flex-shrink: 0; width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px;
  background: #f8fafc; color: #64748b; font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.2s, color 0.2s;
}
.api-test-remove-media-id:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
.api-test-add-media-id { margin-top: 4px; }
.api-test-advanced-toggle { font-size: 13px; font-weight: 600; color: #94a3b8; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; }
.api-test-advanced-toggle.active { color: var(--primary); }
.api-test-advanced-toggle .toggle-icon { font-size: 10px; transition: transform 0.3s; }
.api-test-advanced-toggle.active .toggle-icon { transform: rotate(180deg); }
.api-test-advanced-container { display: none; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; padding: 16px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; }
.api-test-advanced-container.active { display: grid; }
.api-test-actions { display: flex; align-items: center; gap: 16px; margin-top: 24px; }
.btn-send-request { position: relative; min-width: 180px; overflow: hidden; }
.btn-send-request:disabled { background: #cbd5e1; cursor: not-allowed; box-shadow: none; }
.btn-spinner { position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; display: none; }
.btn-send-request.loading .btn-text { opacity: 0; }
.btn-send-request.loading .btn-spinner { display: block; animation: spinner 0.8s linear infinite; }
.api-test-timer { font-size: 12px; font-variant-numeric: tabular-nums; color: #64748b; font-weight: 500; }
.api-test-response-wrapper { margin-top: 20px; overflow: hidden; min-width: 0; }
.api-test-response-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.api-test-status-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 4px; background: #f1f5f9; color: #64748b; }
.api-test-status-badge.success { background: #ecfdf5; color: #10b981; box-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
.api-test-status-badge.error { background: #fef2f2; color: #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.2); }
.btn-copy-response { background: #f1f5f9; border: none; color: #64748b; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 4px; cursor: pointer; transition: 0.2s; }
.btn-copy-response:hover { background: var(--primary-light); color: var(--primary); }
.api-test-response {
  max-height: 350px;
  overflow-y: auto;
  overflow-x: auto;
  padding: 16px;
  font-size: 12px;
}
.api-test-response pre {
  margin: 0;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* Custom Webkit Scrollbar for Response Block */
.api-test-response::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.api-test-response::-webkit-scrollbar-track {
  background: transparent;
}
.api-test-response::-webkit-scrollbar-thumb {
  background: rgba(139, 148, 158, 0.3);
  border-radius: 4px;
}
.api-test-response::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 148, 158, 0.6);
}
.api-test-response::-webkit-scrollbar-corner {
  background: transparent;
}


/* ================== MODAL 2: CODE IDE WOW EDITION ================== */
.modal-api-code {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 0; /* full-width MacOS frame inside panel */
}
.modal-api-code::-webkit-scrollbar { width: 6px; }
.modal-api-code::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.modal-api-code::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Mac OSX Title Bar */
.macos-titlebar {
  background: #f1f5f9;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #e2e8f0;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.window-dots {
  display: flex;
  gap: 8px;
  position: absolute; /* Keep dots always to the left */
}

.macos-title {
  flex: 1;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.code-window-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 16px;
  display: flex;
  align-items: center;
}
.window-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
}
.wd-red { background: #ff5f56; box-shadow: 0 0 6px rgba(255,95,86,0.3); }
.wd-yellow { background: #ffbd2e; box-shadow: 0 0 6px rgba(255,189,46,0.3); }
.wd-green { background: #27c93f; box-shadow: 0 0 6px rgba(39,201,63,0.3); }

/* Glowing Tabs */
.code-schema-tabs {
  display: flex;
  gap: 16px;
  flex: 1;
}
.cs-tab {
  background: none; border: none;
  color: #64748b;
  font-size: 13px; font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
  display: flex; align-items: center; gap: 6px;
}
.cs-tab:hover { color: #1e293b; }
.cs-tab.active {
  color: #2563eb;
  text-shadow: 0 0 10px rgba(37, 99, 235, 0.2);
}
.cs-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: #2563eb;
  box-shadow: 0 -2px 10px rgba(37,99,235,0.3);
}

.cs-tab-content {
  flex: 1;
  display: none;
  flex-direction: column;
  padding: 16px;
  animation: fadeUp 0.3s ease forwards;
}
.cs-tab-content.active { display: flex; }

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Language Selector */
.lang-selector-wrapper {
  position: relative;
  align-self: flex-end;
  margin-bottom: 8px;
  z-index: 5;
}
.pulse-ring {
  position: absolute; inset: 0; border-radius: 20px;
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
  animation: pulseRing 2s infinite; pointer-events: none;
}
@keyframes pulseRing {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.3); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.lang-select-glass {
  appearance: none; background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid #cbd5e1; border-radius: 20px;
  padding: 6px 30px 6px 16px;
  color: #1e293b; font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif;
  cursor: pointer; transition: 0.3s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.lang-select-glass:hover { background-color: #ffffff; border-color: #2563eb; }
.lang-select-glass option { background: #ffffff; color: #1e293b; }

/* Code Editor Block & Syntax Highlights */
.code-editor-block {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.code-editor-block pre {
  margin: 0; padding: 20px; flex: 1;
  overflow-y: auto; overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13px; line-height: 1.6; color: #0f172a;
  transition: all 0.3s ease;
}

/* Custom Webkit Scrollbar for Code Block */
.code-editor-block pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.code-editor-block pre::-webkit-scrollbar-track {
  background: #f8fafc;
  border-left: 1px solid #e2e8f0;
}
.code-editor-block pre::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}
.code-editor-block pre::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Magic Copy Button */
.btn-copy-magic {
  position: absolute; right: 12px; top: 12px;
  background: #ffffff; border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #334155; font-size: 11px; font-weight: 600;
  padding: 6px 12px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.btn-copy-magic:hover { background: #f8fafc; color: #0f172a; border-color: #3b82f6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59,130,246,0.15); }
.btn-copy-magic:active { transform: translateY(1px) scale(0.95); }
.btn-copy-magic.copied { background: #10b981; color: #fff; border-color: #059669; box-shadow: 0 0 15px rgba(16,185,129,0.3); }

/* Schema Tab Info Bar */
.schema-info-bar { margin-bottom: 12px; background: #eff6ff; border-left: 4px solid #3b82f6; padding: 10px 14px; border-radius: 4px; color: #1e40af; font-size: 12px; font-weight: 500; }

/* Schema Sections Container */
.schema-sections-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
}

.schema-sections-container::-webkit-scrollbar { width: 6px; }
.schema-sections-container::-webkit-scrollbar-track { background: transparent; }
.schema-sections-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.schema-sections-container::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Individual Schema Section Card */
.schema-section {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
  background: #fff;
}
.schema-section:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-color: #cbd5e1;
}

/* Section Header - Color coded */
.schema-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.schema-section-header.request {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1e40af;
  border-bottom: 1px solid #bfdbfe;
}
.schema-section-header.response {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #065f46;
  border-bottom: 1px solid #a7f3d0;
}
.schema-section-header.error {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  color: #991b1b;
  border-bottom: 1px solid #fecaca;
}
.schema-section-icon { font-size: 14px; }

/* Section Code Block */
.schema-section-code {
  background: #ffffff;
  overflow-x: auto;
}
.schema-section-code pre {
  margin: 0;
  padding: 14px 16px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #0f172a;
}
.schema-section-code::-webkit-scrollbar { height: 6px; }
.schema-section-code::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Syntax Theme (High Contrast Light) */
.hl-keyword { color: #d946ef; font-weight: 700; } /* Magenta */
.hl-string { color: #16a34a; } /* Green */
.hl-url { color: #2563eb; text-decoration: underline; } /* Solid Blue */
.hl-key { color: #0284c7; font-weight: 600; } /* Light Blue / Sky */
.hl-number { color: #ea580c; } /* Orange */
.hl-bool { color: #ea580c; font-style: italic; font-weight: 600; } /* Orange */
.hl-comment { color: #94a3b8; font-style: italic; } /* Slate */
.hl-function { color: #0f172a; font-weight: 500;} /* Almost Black */


/* ===== RESPONSIVE ===== */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .hamburger { display: block; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

/* ================== CHAT UI (DASHBOARD) WOW EDITION ================== */
#page-chat {
  height: calc(100vh - 120px);
  flex-direction: column;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  position: relative;
}

/* Only apply flex when the page is actually shown (display:block set by JS) */
#page-chat[style*="block"] {
  display: flex !important;
}


.chat-header {
  padding: 16px 24px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.chat-header-left {
  display: flex; align-items: center; gap: 14px;
}

.chat-header-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
  position: relative;
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

.chat-admin-ripple {
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: rippleHeartbeat 2s infinite ease-out;
  pointer-events: none;
}
@keyframes rippleHeartbeat {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.chat-header-info { display: flex; flex-direction: column; }
.chat-header-name { font-weight: 800; font-size: 16px; color: #0f172a; }
.chat-header-status { font-size: 12px; color: #10b981; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chat-header-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 8px #10b981; display: inline-block; }

.chat-header-right { display: flex; gap: 12px; }
.chat-header-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: #f8fafc; border: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: 0.2s; font-size: 14px; color: #64748b;
}
.chat-header-btn:hover { background: #e2e8f0; color: #0f172a; transform: translateY(-2px); }

.chat-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: auto;
  position: relative;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Date Separator */
.chat-date-separator {
  align-self: center;
  background: rgba(226, 232, 240, 0.6);
  backdrop-filter: blur(8px);
  color: #475569; font-size: 11px; font-weight: 700;
  padding: 4px 14px; border-radius: 20px;
  margin: 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  z-index: 2; position: sticky; top: 10px;
}

/* Chat Bubbles */
.chat-msg {
  display: flex; flex-direction: column; max-width: 75%;
  position: relative;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0; transform: translateY(20px) scale(0.9);
}
@keyframes popIn {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg.out { align-self: flex-end; }
.chat-msg.in { align-self: flex-start; }

.chat-bubble {
  padding: 12px 18px; border-radius: 22px;
  font-size: 14px; line-height: 1.5; font-weight: 500;
  position: relative; word-wrap: break-word; white-space: pre-wrap;
}
.chat-msg.out .chat-bubble {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; border-bottom-right-radius: 6px;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
}
.chat-msg.in .chat-bubble {
  background: #ffffff;
  color: #0f172a; border-bottom-left-radius: 6px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 15px rgba(0,0,0,0.04);
}

/* Floating Action Menu */
.chat-msg-actions {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: flex; gap: 6px; opacity: 0; pointer-events: none; transition: 0.2s;
}
.chat-msg.out .chat-msg-actions { right: calc(100% + 10px); }
.chat-msg.in .chat-msg-actions { left: calc(100% + 10px); }
.chat-msg:hover .chat-msg-actions { opacity: 1; pointer-events: all; }
.chat-action-btn {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 50%;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; color: #64748b; box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  transition: 0.2s; padding: 0;
}
.chat-action-btn:hover { background: #f1f5f9; color: #2563eb; transform: scale(1.1); }

.chat-time {
  font-size: 11px; color: #94a3b8; font-weight: 600;
  margin-top: 6px; display: flex; align-items: center; gap: 6px;
}
.chat-msg.out .chat-time { justify-content: flex-end; }
.chat-msg.in .chat-time { justify-content: flex-start; }

/* Image Attachments */
.chat-img-attachment {
  max-width: 280px; border-radius: 14px; cursor: pointer; display: block;
  margin-top: 4px; transition: transform 0.2s; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.chat-img-attachment:hover { transform: scale(1.02); }
.chat-bubble:has(> img:only-child) {
  padding: 0; background: transparent !important; border: none !important; box-shadow: none !important; margin-bottom: 4px;
}
.chat-bubble > img:only-child { margin-top: 0; border-radius: 18px; }

/* Read Receipt */
.msg-read-icon {
  font-size: 12px; color: #3b82f6; display: inline-flex; align-items: center; justify-content: center;
}
.msg-read-icon.unread { color: #94a3b8; }

/* Footer */
.chat-footer {
  padding: 16px 24px; background: #fff; border-top: 1px solid #f1f5f9;
  display: flex; align-items: flex-end; gap: 14px; z-index: 10;
}
.chat-input-wrapper {
  flex: 1; background: #f8fafc; border-radius: 28px; padding: 4px 6px;
  display: flex; align-items: flex-end; border: 1px solid #e2e8f0;
  transition: all 0.3s;
}
.chat-input-wrapper:focus-within {
  background: #fff; border-color: #3b82f6; box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.chat-input {
  flex: 1; border: none; background: transparent; padding: 12px 18px;
  font-size: 14px; resize: none; max-height: 120px; min-height: 24px;
  outline: none; font-family: inherit; line-height: 1.5; color: #0f172a;
  font-weight: 500;
}
.chat-input::-webkit-scrollbar { width: 4px; }
.chat-input::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.btn-chat-attach {
  background: none; border: none; font-size: 20px; color: #94a3b8;
  padding: 8px 12px; cursor: pointer; border-radius: 50%;
  transition: 0.2s; height: 44px; display: flex; align-items: center; justify-content: center;
}
.btn-chat-attach:hover { color: #2563eb; background: #eff6ff; }

.btn-chat-send {
  background: linear-gradient(135deg, #3b82f6, #2563eb); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 15px rgba(37,99,235,0.3);
}
.btn-chat-send:hover { transform: scale(1.1) rotate(-10deg); box-shadow: 0 6px 20px rgba(37,99,235,0.4); }
.btn-chat-send:active { transform: scale(0.9); }
.btn-chat-send:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; transform: none; }

/* Typing Wave */
.typing-wave {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; justify-content: center;
}
.typing-wave span {
  width: 6px; height: 6px; background: #94a3b8; border-radius: 50%;
  animation: typingWave 1.2s infinite ease-in-out;
}
.typing-wave span:nth-child(1) { animation-delay: 0s; }
.typing-wave span:nth-child(2) { animation-delay: 0.2s; }
.typing-wave span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingWave {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); background: #3b82f6; }
}

/* Dropzone & Preview Modal */
.chat-dropzone {
  position: absolute; inset: 16px; border: 3px dashed #3b82f6;
  background: rgba(239, 246, 255, 0.7); backdrop-filter: blur(8px);
  border-radius: 20px; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(0.95);
}
.chat-dropzone.drag-over { opacity: 1; pointer-events: all; transform: scale(1); }
.chat-dropzone-icon { font-size: 64px; margin-bottom: 20px; animation: bounceDrop 1s infinite alternate; }
.chat-dropzone-text { font-size: 24px; font-weight: 800; color: #1e40af; }
@keyframes bounceDrop { from { transform: translateY(0); } to { transform: translateY(-15px); } }

.image-preview-overlay {
  position: absolute; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(12px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: 0.3s;
}
.image-preview-overlay.active { opacity: 1; pointer-events: all; }
.image-preview-card {
  background: #fff; padding: 24px; border-radius: 24px; box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  width: 90%; max-width: 480px; display: flex; flex-direction: column; gap: 20px;
  transform: translateY(30px) scale(0.9); transition: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.image-preview-overlay.active .image-preview-card { transform: translateY(0) scale(1); }
.image-preview-box { width: 100%; max-height: 45vh; border-radius: 16px; overflow: hidden; background: #f8fafc; display: flex; align-items: center; justify-content: center; }
.image-preview-box img { max-width: 100%; max-height: 45vh; object-fit: contain; }

/* Photo Fullscreen Theater */
.photo-theater {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(15px);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: 0.3s; cursor: zoom-out;
}
.photo-theater.active { opacity: 1; pointer-events: all; }
.photo-theater img {
  max-width: 90vw; max-height: 90vh; border-radius: 12px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5); object-fit: contain;
  transform: scale(0.8); transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.photo-theater.active img { transform: scale(1); }
.theater-close { position: absolute; top: 24px; right: 24px; background: rgba(255,255,255,0.1); border: none; color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; cursor: pointer; transition: 0.2s; backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 10000; }
.theater-close:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); }

/* Smart Scroll Down Bubble */
.scroll-bottom-btn {
  position: absolute; right: 24px; bottom: 90px;
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  border: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(20px);
  transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); z-index: 20; color: #475569; font-size: 18px;
}
.scroll-bottom-btn.visible { opacity: 1; pointer-events: all; transform: translateY(0); }
.scroll-bottom-btn:hover { color: #2563eb; background: #f8fafc; }
.scroll-bottom-badge {
  position: absolute; top: -6px; right: -6px; background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 10px;
  box-shadow: 0 2px 5px rgba(239,68,68,0.4); animation: popBadge 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popBadge { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* ================== QR PAYMENT MODAL ================== */
.qr-modal {
  background: #fff;
  border-radius: 20px;
  width: 92%;
  max-width: 420px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1);
  overflow: hidden;
  animation: qrModalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes qrModalIn {
  0% { opacity: 0; transform: scale(0.9) translateY(30px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.qr-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 0;
}

.qr-modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #1a1a2e;
}

.qr-modal-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.qr-modal-body {
  padding: 20px 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* VietQR Logo */
.qr-vietqr-logo {
  text-align: center;
}

/* QR Image */
.qr-image-container {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 16px;
  border: 3px solid #e5e7eb;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.qr-code-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

.qr-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* Bank Info */
.qr-bank-info {
  text-align: center;
}

.qr-bank-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.qr-bank-divider {
  width: 1px;
  height: 16px;
  background: #d1d5db;
  margin: 0 4px;
}

.qr-account-name {
  font-size: 15px;
  font-weight: 800;
  color: #1a1a2e;
  letter-spacing: 0.3px;
}

.qr-account-no {
  font-size: 12px;
  color: #6b7280;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  margin-top: 2px;
}

.qr-amount-display {
  font-size: 13px;
  color: #374151;
  margin-top: 6px;
  font-weight: 500;
}

.qr-amount-display strong {
  color: #e53935;
  font-weight: 800;
  font-size: 15px;
}

/* Transfer Content Box */
.qr-transfer-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  background: #fffbeb;
  border: 1.5px solid #fbbf24;
  border-radius: 12px;
  padding: 12px 16px;
}

.qr-transfer-label {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
}

.qr-transfer-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qr-transfer-value span {
  font-size: 16px;
  font-weight: 800;
  color: #d97706;
  letter-spacing: 1px;
  font-family: 'Courier New', monospace;
}

.qr-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}

.qr-copy-btn:hover {
  background: #fef3c7;
  transform: scale(1.1);
}

.qr-copy-btn.copied span {
  display: inline-block;
  animation: popCopy 0.3s ease;
}

@keyframes popCopy {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Countdown */
.qr-countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #10b981;
  font-weight: 600;
}

.qr-countdown.warning {
  color: #f59e0b;
}

.qr-countdown.danger {
  color: #ef4444;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.qr-countdown strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* Note */
.qr-note {
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  line-height: 1.5;
  padding: 0 8px;
}

/* Action Buttons */
.qr-modal-actions {
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qr-btn-error {
  width: 100%;
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 12px;
  background: #fff;
  color: #6b7280;
  border: 1.5px solid #e5e7eb;
  transition: all 0.3s;
  cursor: pointer;
}

.qr-btn-error:hover {
  border-color: #f59e0b;
  color: #d97706;
  background: #fffbeb;
}

/* ===== TOPUP CREDIT PACKAGES ===== */
.topup-packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 170px));
  gap: 12px;
  justify-content: center;
}

.topup-pkg {
  position: relative;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 20px 14px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  overflow: hidden;
}

.topup-pkg::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  padding: 2px;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
}

.topup-pkg:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(26, 115, 232, 0.15);
  border-color: var(--primary);
}

.topup-pkg:hover::before {
  opacity: 1;
}

.topup-pkg.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 4px 20px rgba(26, 115, 232, 0.2);
  transform: translateY(-2px);
}

.topup-pkg.selected::before {
  opacity: 1;
}

.topup-pkg.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: checkPop 0.3s ease;
}

@keyframes checkPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.topup-pkg:active {
  transform: translateY(0) scale(0.97);
}

.topup-pkg-emoji {
  font-size: 32px;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  transition: transform 0.3s;
}

.topup-pkg:hover .topup-pkg-emoji {
  transform: scale(1.15) rotate(-5deg);
}

.topup-pkg-credits {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.topup-pkg-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.topup-pkg-price {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(26, 115, 232, 0.08);
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
}

/* Popular package glow */
.topup-pkg.popular {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fff 100%);
}

.topup-pkg.popular .topup-pkg-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 0 0 8px 8px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.5); }
}

.topup-pkg.popular:hover {
  border-color: #f59e0b;
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.2);
}

.topup-pkg.popular.selected {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fef3c7 0%, #fff 100%);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.25);
}

.topup-pkg.popular.selected::after {
  background: #f59e0b;
}

/* Conversion preview under input */
.topup-conversion {
  background: linear-gradient(135deg, #e0f2fe, #e8f0fe);
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #0369a1;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fadeSlideIn 0.25s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.topup-conversion strong {
  font-weight: 800;
  color: #0c4a6e;
}

/* Responsive */
@media (max-width: 768px) {
  .topup-packages-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .topup-pkg {
    padding: 14px 8px 12px;
  }

  .topup-pkg-emoji {
    font-size: 24px;
  }

  .topup-pkg-credits {
    font-size: 16px;
  }

  .topup-pkg-price {
    font-size: 10px;
    padding: 3px 6px;
  }
}

@media (max-width: 480px) {
  .topup-packages-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
