/* ========== Design Tokens ========== */
:root {
  --bg: #050a14;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(99, 102, 241, 0.5);

  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;

  --text-1: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;

  --font: 'Inter', 'Noto Sans Bengali', system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Reset ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ========== Ambient Background ========== */
.ambient-bg {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  animation: drift 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px; height: 600px;
  background: var(--primary);
  top: -200px; left: -150px;
  animation-duration: 25s;
}

.orb-2 {
  width: 500px; height: 500px;
  background: #8b5cf6;
  bottom: -150px; right: -100px;
  animation-duration: 30s;
  animation-delay: -10s;
}

.orb-3 {
  width: 400px; height: 400px;
  background: var(--success);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.06;
  animation-duration: 35s;
  animation-delay: -5s;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -60px) scale(1.05); }
  66% { transform: translate(-30px, 40px) scale(0.97); }
}

.grid-overlay {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ========== Header ========== */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(5, 10, 20, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 10px;
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 0 20px var(--primary-glow);
}

.logo-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.3s var(--ease);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background 0.3s;
}

.status-ready .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-ready { color: var(--success); border-color: rgba(16,185,129,0.2); }

.status-searching .status-dot { background: var(--primary); animation: pulse 1s ease infinite; }
.status-searching { color: var(--primary-light); border-color: rgba(99,102,241,0.2); }

.status-success .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-success { color: var(--success); border-color: rgba(16,185,129,0.2); }

.status-error .status-dot { background: var(--error); }
.status-error { color: var(--error); border-color: rgba(239,68,68,0.2); }

.status-loading .status-dot { background: var(--warning); animation: pulse 1s ease infinite; }
.status-loading { color: var(--warning); border-color: rgba(245,158,11,0.2); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ========== Main ========== */
.main {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 20px 40px;
}

/* ========== Card ========== */
.card {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  backdrop-filter: blur(10px);
  animation: fadeUp 0.5s var(--ease);
}

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

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

.card-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 14px;
  display: grid; place-items: center;
  color: var(--primary-light);
  flex-shrink: 0;
}

.card-header h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.card-header p {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 2px;
}

/* ========== Form ========== */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.label-badge {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.input-box {
  position: relative;
}

.input-box input {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s var(--ease);
  outline: none;
}

.input-box input::placeholder {
  color: var(--text-3);
  font-weight: 400;
}

.input-box input:focus {
  border-color: var(--border-focus);
  background: rgba(99, 102, 241, 0.04);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.char-count {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Validation */
.field.valid .input-box input {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.04);
}

.field.valid .char-count { color: var(--success); }

.field.has-error .input-box input {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.04);
}

.field.has-error .char-count { color: var(--error); }

/* ========== CAPTCHA ========== */
.captcha-field label { margin-bottom: 4px; }

.captcha-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.captcha-img-box {
  min-width: 180px;
  min-height: 56px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
}

.captcha-img-box img {
  max-height: 56px;
  width: auto;
  display: block;
}

.captcha-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-3);
}

.captcha-err { font-size: 0.72rem; }

.mini-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.icon-btn {
  width: 42px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.25s var(--ease);
}

.icon-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: rotate(180deg);
}

.captcha-input { flex: 1; }

.captcha-input input {
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  letter-spacing: 3px;
  text-align: center;
  height: 100%;
}

/* ========== Search Button ========== */
.search-btn {
  margin-top: 8px;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s var(--ease);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.search-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px var(--primary-glow);
}

.search-btn:not(:disabled):active { transform: translateY(0); }

.search-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.search-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.search-btn:not(:disabled):hover::before { opacity: 1; }

.btn-text, .btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ========== Error ========== */
.error-area {
  margin-top: 20px;
  animation: fadeUp 0.3s var(--ease);
}

.error-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: var(--error-glow);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--error);
}

.error-box svg { flex-shrink: 0; margin-top: 2px; }
.error-title { font-size: 0.88rem; font-weight: 700; }
.error-desc { font-size: 0.78rem; color: var(--text-2); margin-top: 4px; line-height: 1.5; }

/* ========== Result View (Fullscreen) ========== */
.result-view {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.35s var(--ease);
}

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

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(5, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
  z-index: 10;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.back-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.back-btn svg {
  transition: transform 0.2s var(--ease);
}

.back-btn:hover svg {
  transform: translateX(-3px);
}

.result-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success);
}

.iframe-frame {
  flex: 1;
  width: 100%;
  background: white;
  overflow: hidden;
  position: relative;
}

.iframe-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ========== Footer ========== */
.footer {
  margin-top: 32px;
  text-align: center;
}

.footer p {
  font-size: 0.7rem;
  color: var(--text-3);
}

.footer strong {
  color: var(--text-2);
  font-weight: 600;
}

/* ========== Toast ========== */
.toast-wrap {
  position: fixed;
  top: 68px; right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s var(--ease);
  max-width: 320px;
}

.toast.show { transform: translateX(0); opacity: 1; }

.t-success { background: rgba(16, 185, 129, 0.9); }
.t-error { background: rgba(239, 68, 68, 0.9); }
.t-info { background: rgba(59, 130, 246, 0.9); }

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .card { padding: 24px 18px; border-radius: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .captcha-row { flex-wrap: wrap; }
  .captcha-img-box { min-width: 100%; }
  .captcha-input { width: 100%; }
  .card-header h1 { font-size: 1.1rem; }

  .result-toolbar { padding: 8px 12px; }
  .back-btn { padding: 7px 12px; font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .main { padding: 72px 12px 24px; }
  .card { padding: 20px 14px; }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
