/* ── Design Tokens ───────────────────────────────────────── */
:root {
  --primary-glow: radial-gradient(circle, rgba(124, 58, 237, 0.15) 0%, rgba(59, 130, 246, 0) 70%);
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f0529 100%);
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --accent-gradient: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
  --panel-bg: rgba(30, 41, 59, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-focus: rgba(139, 92, 246, 0.4);
  --white: #ffffff;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius-lg: 16px;
  --radius-md: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Inter', sans-serif;
}

/* ── Reset & Globals ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 60px;
  position: relative;
}

/* Dynamic glowing light source behind UI */
.glow-bg {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: var(--primary-glow);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ──────────────────────────────────────────────── */
header {
  position: relative;
  z-index: 10;
  padding: 40px 24px 20px;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 32px;
  font-weight: 800;
  width: 56px;
  height: 56px;
  background: var(--accent-gradient);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
}

.title-wrap h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(120deg, #ffffff, #d8b4fe, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-wrap p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Main Layout ────────────────────────────────────────── */
main {
  position: relative;
  z-index: 10;
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 0 24px;
}

/* ── Glassmorphism Card ──────────────────────────────────── */
.glass-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.converter-box {
  padding: 24px;
  margin-bottom: 30px;
  transition: var(--transition);
}

.converter-box:hover {
  border-color: rgba(139, 92, 246, 0.15);
}

/* ── Direction Bar ──────────────────────────────────────── */
.direction-control {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 24px;
}

.select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.select-wrapper label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

select {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  color: var(--white);
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

select:hover, select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.swap-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  align-self: flex-end;
}

.swap-btn:hover {
  background: var(--accent-gradient);
  color: var(--white);
  border-color: transparent;
  transform: rotate(180deg);
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.4);
}

/* ── Editor Grid ───────────────────────────────────────── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  gap: 16px;
  align-items: center;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  overflow: hidden;
  transition: var(--transition);
}

.editor-panel:focus-within {
  border-color: var(--panel-border-focus);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  padding: 4px 10px;
  border-radius: 4px;
}

.count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

textarea {
  width: 100%;
  height: 250px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
}

textarea::placeholder {
  color: rgba(148, 163, 184, 0.4);
}

textarea[readonly] {
  background: rgba(15, 23, 42, 0.2);
}

.panel-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  gap: 10px;
}

.action-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #9333ea 0%, #2563eb 100%);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
}

/* ── Central Convert Button ────────────────────────────── */
.convert-trigger {
  display: flex;
  justify-content: center;
  align-items: center;
}

#convert-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
  transition: var(--transition);
  position: relative;
}

#convert-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.6);
}

#convert-btn:active {
  transform: scale(0.95);
}

#convert-btn .loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

#convert-btn.loading .arrow {
  display: none;
}

#convert-btn.loading .loader {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Status Bar ────────────────────────────────────────── */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.status-dot.ok { background: var(--success); }
.status-dot.err { background: var(--error); }
.status-dot.warn { background: var(--warning); }

.status-indicator p {
  font-size: 13px;
  color: var(--text-muted);
}

.status-indicator p strong {
  color: var(--white);
}

/* ── Info Cards ────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.info-card {
  padding: 24px;
}

.info-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: #c084fc;
  margin-bottom: 14px;
}

.info-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.signature-details {
  margin-top: 14px;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
}

.signature-details code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
}

/* ── Mappings Table ────────────────────────────────────── */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.mapping-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--panel-border);
}

.mapping-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.mapping-table tr:last-child td {
  border-bottom: none;
}

.mapping-table code {
  background: rgba(139, 92, 246, 0.15);
  color: #d8b4fe;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* ── Toast ─────────────────────────────────────────────── */
.toast-notification {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--accent-gradient);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: var(--transition);
  z-index: 100;
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* ── Responsive Styling ────────────────────────────────── */
@media (max-width: 900px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .convert-trigger {
    padding: 10px 0;
  }

  #convert-btn {
    transform: rotate(90deg);
  }

  #convert-btn:hover {
    transform: rotate(90deg) scale(1.1);
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .direction-control {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .swap-btn {
    align-self: center;
    transform: rotate(90deg);
  }

  .swap-btn:hover {
    transform: rotate(270deg);
  }
}

/* ── Font Info Row ──────────────────────────────────────── */
.font-info-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.font-pill {
  flex: 1 1 160px;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.font-pill p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.font-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  width: fit-content;
}

.font-badge.kap    { background: rgba(59,130,246,0.18); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.font-badge.gopika { background: rgba(139,92,246,0.18); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.font-badge.nil    { background: rgba(16,185,129,0.18); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.font-badge.hari   { background: rgba(245,158,11,0.18); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.font-badge.eklg   { background: rgba(239,68,68,0.18);  color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
