/* ===========================
   Globy AI – ESP32 Web Flasher (Light UI)
   =========================== */

:root {
  --bg: #f3f4ff;
  --bg-grad: linear-gradient(135deg, #eef2ff, #fdf2ff 45%, #e0f7ff 100%);
  --card: #ffffff;
  --border: rgba(148, 163, 184, 0.35);
  --text: #111827;
  --text-muted: #6b7280;

  --primary: #7c3aed;
  --primary-soft: #ede9fe;
  --primary-soft-2: #f5f3ff;

  --accent: #38bdf8;
  --accent-soft: #e0f2fe;
  --success: #22c55e;
  --danger: #ef4444;

  --shadow-soft: 0 16px 35px rgba(15, 23, 42, 0.12);

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-pill: 999px;
}

/* Reset nhỏ */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-grad);
  color: var(--text);
}

/* Layout chính */
body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 18px 12px;
}

.app {
  width: 100%;
  max-width: 1060px;
  margin: auto;
}

.shell {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 18px 18px 20px;
}

@media (min-width: 768px) {
  .shell {
    padding: 22px 22px 22px;
  }
}

/* Grid */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.col {
  flex: 1 1 260px;
  min-width: 0;
}

.divider {
  height: 1px;
  background: linear-gradient(to right, rgba(148,163,184,0.0), rgba(148,163,184,0.6), rgba(148,163,184,0.0));
  margin: 14px 0 16px;
}

/* Header */
.header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

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

/* Pill info */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 11px;
  background: var(--primary-soft-2);
  border: 1px solid rgba(124, 58, 237, 0.28);
  color: var(--text-muted);
}

.pill-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 0 8px rgba(79,70,229,0.8);
}

/* Title */
.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #4c1d95;
}

@media (min-width: 768px) {
  .app-title {
    font-size: 1.7rem;
  }
}

.app-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  box-shadow: 0 8px 18px rgba(79,70,229,0.6);
}

/* Subtitle */
.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* Status block */
.status-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

@media (min-width: 768px) {
  .status-block {
    align-items: flex-end;
  }
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  font-size: 11px;
  border: 1px solid rgba(148,163,184,0.7);
  background: #f9fafb;
  color: var(--text-muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #9ca3af;
}

.status-chip.connected {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}

.status-chip.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 10px rgba(34,197,94,0.9);
}

.status-chip.connecting {
  background: var(--accent-soft);
  border-color: #7dd3fc;
  color: #0f172a;
}

.status-chip.connecting .status-dot {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(56,189,248,0.9);
}

.status-note {
  font-size: 11px;
  color: var(--text-muted);
}

.status-note strong {
  color: var(--text);
}

/* Chip badge */
.chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid rgba(148,163,184,0.6);
  background: #f9fafb;
  color: var(--text);
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease, opacity 0.12s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.btn-primary {
  background: linear-gradient(120deg, #4f46e5, #7c3aed);
  color: #f9fafb;
  box-shadow: 0 10px 24px rgba(79,70,229,0.38);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(120deg, #4338ca, #6d28d9);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(79,70,229,0.5);
}

.btn-outline {
  border: 1px solid rgba(148,163,184,0.9);
  background: #f9fafb;
  color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
  background: #e5e7eb;
  color: var(--text);
}

.btn-ghost {
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  border: 1px solid rgba(148,163,184,0.7);
  background: #f9fafb;
  color: var(--text-muted);
  font-size: 11px;
}

.btn-ghost:hover:not(:disabled) {
  background: #e0ecff;
  color: #1f2937;
}

.btn-danger {
  border: 1px solid rgba(248,113,113,0.7);
  background: #fee2e2;
  color: #b91c1c;
}

.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

.btn-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #f9fafb;
  background: radial-gradient(circle at 25% 25%, #fefce8 0, #facc15 35%, #fb923c 80%);
  box-shadow: 0 0 6px rgba(234,88,12,0.5);
}

/* Section titles & labels */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.log-title-bullet {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(56,189,248,0.8);
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Preset select */
.preset-select {
  width: 100%;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148,163,184,0.9);
  background: #f9fafb;
  padding: 7px 10px;
  color: var(--text);
  font-size: 12px;
}

.preset-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.45);
  background: #ffffff;
}

/* Preset info */
.preset-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: none;
  border-left: 3px solid var(--primary);
  padding-left: 8px;
  line-height: 1.4;
  background: #f5f3ff;
  border-radius: 6px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.preset-info strong {
  color: var(--text);
}

/* File drop zone */
.file-zone {
  border-radius: var(--radius-md);
  border: 2px dashed rgba(124,58,237,0.7);
  background: #faf5ff;
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.08s ease;
  margin-top: 10px;
}

.file-zone:hover {
  border-color: var(--primary);
  background: #f3e8ff;
  box-shadow: 0 8px 20px rgba(148,163,184,0.2);
}

.file-zone.drag-over {
  border-style: solid;
  border-color: #7c3aed;
  background: #e0e7ff;
  transform: translateY(-1px);
}

.file-zone-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #a855f7);
  margin: 0 auto 6px;
  box-shadow: 0 8px 18px rgba(79,70,229,0.7);
}

.file-zone-text-main {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.file-zone-text-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.file-zone-text-sub span {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.file-meta {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-muted);
}

.file-meta span {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: #f9fafb;
  border: 1px solid rgba(148,163,184,0.7);
}

/* Address input */
.address-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.address-input {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148,163,184,0.9);
  background: #f9fafb;
  padding: 6px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  min-width: 130px;
}

.address-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.5);
  background: #ffffff;
}

.address-help {
  font-size: 11px;
  color: var(--text-muted);
}

.address-help code {
  background: #eef2ff;
  border-radius: 999px;
  padding: 2px 6px;
  border: 1px solid rgba(148,163,184,0.7);
  font-size: 10px;
}

/* Warning text */
.warning-text {
  font-size: 11px;
  color: var(--text-muted);
}

.warning-text strong {
  color: #b91c1c;
}

/* Progress */
.progress-shell {
  width: 100%;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148,163,184,0.8);
  background: #eef2ff;
  height: 9px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #0ea5e9, #6366f1);
  background-size: 220% 100%;
  animation: progressFlow 1.2s linear infinite;
  transition: width 0.15s linear;
}

@keyframes progressFlow {
  0% { background-position: 0% 0; }
  100% { background-position: 100% 0; }
}

/* Stats */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.stat-block {
  display: flex;
  gap: 4px;
  align-items: baseline;
}

.stat-value {
  color: var(--text);
  font-weight: 600;
}

/* Log */
.log-shell {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148,163,184,0.9);
  background: #0b1120;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  color: #e5e7eb;
  max-height: 280px;
  min-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-shell::-webkit-scrollbar {
  width: 7px;
}

.log-shell::-webkit-scrollbar-thumb {
  background: #6b7280;
  border-radius: 999px;
}

.log-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.log-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Footer */
.footer {
  margin-top: 12px;
  font-size: 11px;
  text-align: center;
  color: var(--text-muted);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}
/* Swap icon Tiger/Rabbit */
.app-title-icon-swap {
  position: relative;
  width: 38px;
  height: 38px;
}
.app-title-icon-swap .icon {
  position: absolute;
  top: 0; left: 0;
  font-size: 34px;
  opacity: 0;
  animation: swapIcon 6s infinite;
}
.app-title-icon-swap .icon-1 { animation-delay: 0s; }
.app-title-icon-swap .icon-2 { animation-delay: 3s; }

/* Swap icon in file-zone */
.file-zone-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  position: relative;
}
.fz-icon {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  text-align: center;
  font-size: 34px;
  opacity: 0;
  animation: swapIcon 6s infinite;
}
.fz-1 { animation-delay: 0s; }
.fz-2 { animation-delay: 3s; }

/* Fade animation */
@keyframes swapIcon {
  0%   { opacity: 0; transform: scale(0.8); }
  10%  { opacity: 1; transform: scale(1); }
  40%  { opacity: 1; }
  50%  { opacity: 0; transform: scale(0.8); }
  100% { opacity: 0; }
}


