/* ===== Liquid Glass Theme ===== */
:root {
  --bg-color: #F0F9FF;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-inverse: #FFFFFF;
  --accent-color: #0EA5E9;
  --accent-hover: #0284C7;
  --border-color: rgba(14, 165, 233, 0.15);
  --error-color: #EF4444;
  --success-color: #10B981;
  --warning-color: #F59E0B;
  --shadow-sm: 0 4px 6px -1px rgba(14, 165, 233, 0.05), 0 2px 4px -1px rgba(14, 165, 233, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(14, 165, 233, 0.08), 0 4px 6px -2px rgba(14, 165, 233, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(14, 165, 233, 0.1), 0 10px 10px -5px rgba(14, 165, 233, 0.04);
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-heading: 'Rubik', sans-serif;
  --font-body: 'Nunito Sans', sans-serif;
  --font-mono: 'Fira Code', monospace;
}

[data-theme="dark"] {
  --bg-color: #0F172A;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --accent-color: #38BDF8;
  --accent-hover: #7DD3FC;
  --border-color: rgba(148, 163, 184, 0.1);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
.brand {
  font-family: var(--font-heading);
  font-weight: 700;
}

a {
  color: var(--accent-color);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: inherit;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 0;
}

[data-theme="dark"] .navbar {
  background-color: rgba(15, 23, 42, 0.8);
}

[data-theme="light"] .navbar {
  background-color: rgba(240, 249, 255, 0.85);
}

.navbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.35rem;
  color: var(--text-main);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme toggle */
.btn-icon {
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
}

.icon-sm {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .sun-icon {
  display: block;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

[data-theme="light"] .sun-icon {
  display: none;
}

[data-theme="light"] .moon-icon {
  display: block;
}

/* Key chip */
.key-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.key-chip.disconnected {
  background: rgba(239, 68, 68, 0.08);
  color: var(--error-color);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.key-chip.connected {
  background: rgba(16, 185, 129, 0.08);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.key-chip:hover {
  transform: scale(1.03);
}

/* ===== Buttons ===== */
.btn-primary {
  background-color: var(--accent-color);
  color: var(--text-inverse);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s;
}

.btn-ghost:hover {
  background-color: var(--bg-card-hover);
}

/* ===== Hero / Key Bind ===== */
.hero-section {
  padding: 48px 0 12px;
  text-align: center;
}

.hero-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(124, 58, 237, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

.section-title {
  font-size: 2rem;
  margin-bottom: 6px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 1rem;
}

.key-bind-card {
  max-width: 480px;
  margin: 24px auto 0;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.key-bind-inner {
  padding: 20px 24px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 11px 40px 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.key-eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.key-eye-btn:hover {
  color: var(--accent-color);
}

.text-error {
  color: var(--error-color);
  font-size: 0.85rem;
}

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

/* ===== Stats Row Mini ===== */
.stats-card-mini {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--shadow-sm);
}

.mini-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mini-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-color);
}

/* ===== Two Column Layout ===== */
.two-col-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
  align-items: start;
}

.col-left {
  min-width: 0;
}

.col-right {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

/* Scrollbar styling for history column */
.col-right::-webkit-scrollbar {
  width: 4px;
}

.col-right::-webkit-scrollbar-track {
  background: transparent;
}

.col-right::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.col-right::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* ===== New Task Area (Top) ===== */
.new-task-area-top {
  text-align: center;
  padding: 24px;
  margin-bottom: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.live-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* ===== Session Card ===== */
.session-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-pending {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.status-received {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.status-completed {
  background: rgba(14, 165, 233, 0.1);
  color: #0ea5e9;
}

.status-cancelled {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

.status-refunded {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.status-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Timer Ring */
.timer-ring {
  position: relative;
  width: 48px;
  height: 48px;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 2.5;
}

.timer-fg {
  fill: none;
  stroke: var(--accent-color);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray 1s linear;
}

.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Code Display */
.code-display-area {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.phone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.phone-number {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.copy-btn {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  font-size: 0.75rem;
}

.copy-btn:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 12px 0 4px;
  border-top: 1px dashed var(--border-color);
  margin-top: 8px;
}

.code-value {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: 6px;
  text-shadow: 0 0 20px rgba(14, 165, 233, 0.15);
  animation: codePopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes codePopIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Waiting animation */
.waiting-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.waiting-dots span:not(:last-child) {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
  margin: 0 3px;
  animation: dotBounce 1.4s ease-in-out infinite both;
}

.waiting-dots span:nth-child(1) {
  animation-delay: 0s;
}

.waiting-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.waiting-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes dotBounce {

  0%,
  80%,
  100% {
    transform: scale(0.4);
    opacity: 0.3;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Session Actions */
.session-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 100px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.action-btn:hover:not(:disabled) {
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-1px);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn.action-success {
  color: var(--success-color);
  border-color: rgba(16, 185, 129, 0.2);
}

.action-btn.action-success:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.06);
  border-color: var(--success-color);
}

.action-btn.action-danger {
  color: var(--error-color);
  border-color: rgba(239, 68, 68, 0.2);
}

.action-btn.action-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.06);
  border-color: var(--error-color);
}

.action-hint {
  margin-top: 10px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 18px;
}

/* ===== New Task Button ===== */
.btn-new-task {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-color), #6366f1);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.25);
  transition: all 0.3s;
}

.btn-new-task:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 32px rgba(14, 165, 233, 0.35);
}

.btn-new-task:active {
  transform: scale(0.97);
}

/* ===== History ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
  cursor: default;
}

.history-item:hover {
  border-color: rgba(14, 165, 233, 0.3);
  box-shadow: var(--shadow-sm);
}

.history-left {
  flex: 1;
  min-width: 0;
}

.history-phone {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
}

.history-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.history-code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-color);
  background: rgba(14, 165, 233, 0.06);
  padding: 3px 10px;
  border-radius: 8px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
}

.toast.error {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

.toast.info {
  background: rgba(14, 165, 233, 0.9);
  color: #fff;
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .two-col-layout {
    grid-template-columns: 1fr;
  }

  .col-right {
    position: static;
    max-height: none;
    margin-top: 24px;
  }

  .container-wide {
    padding: 0 16px;
  }
}

@media (max-width: 640px) {
  .session-actions {
    flex-wrap: wrap;
  }

  .action-btn {
    min-width: calc(50% - 4px);
  }

  .section-title {
    font-size: 1.6rem;
  }

  .code-value {
    font-size: 1.6rem;
    letter-spacing: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01s !important;
    transition-duration: 0.01s !important;
  }
}