/* css/components.css - Buttons, cards, modals, sheets, navigation, settings, toasts */
/* Cards & Panels */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}

/* Primary Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 3px 12px var(--accent-glow);
}

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

.btn-secondary {
  background-color: var(--bg-muted);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline:hover {
  background-color: var(--accent-subtle);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

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

/* View: Input */
.input-header {
  margin-bottom: 14px;
}
.input-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.input-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.textarea-box {
  width: 100%;
  height: 180px;
  padding: 14px;
  font-size: 18px;
  font-family: var(--font-hanzi);
  line-height: 1.6;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-input);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  user-select: text;
}

.textarea-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.textarea-wrapper {
  position: relative;
  width: 100%;
}

.textarea-clear-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.15s ease;
  z-index: 2;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.textarea-clear-btn:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.samples-container {
  margin-top: 20px;
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s;
}

.recent-item:hover {
  border-color: var(--accent);
}

.recent-text {
  font-family: var(--font-hanzi);
  font-size: 15px;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* View: Settings */
.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 14px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.settings-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.settings-sublabel {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

.settings-control {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.settings-control select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-muted);
  color: var(--text-primary);
  font-size: 13px;
  max-width: 200px;
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  #top-bar {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 11.5px;
    border-radius: 8px;
  }
  .brand-title {
    font-size: 15px;
  }
  .top-lang-btn {
    padding: 3.5px 7px;
    font-size: 10.5px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
  }
  .settings-row {
    padding: 12px 14px;
    gap: 10px;
  }
  .settings-label {
    font-size: 13px;
  }
  .settings-sublabel {
    font-size: 11px;
    line-height: 1.35;
  }
  .settings-control select {
    max-width: 145px;
    font-size: 12px;
    padding: 5px 6px;
  }
}

/* App Promo Banner & Share Controls */
.app-promo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(232, 52, 78, 0.08) 0%, rgba(255, 56, 92, 0.03) 100%);
  border: 1px solid rgba(232, 52, 78, 0.2);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}

.app-promo-banner:hover {
  background: linear-gradient(135deg, rgba(232, 52, 78, 0.12) 0%, rgba(255, 56, 92, 0.06) 100%);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232, 52, 78, 0.1);
}

.app-promo-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.app-promo-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px var(--accent-glow);
}

.app-promo-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.app-promo-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-promo-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.15s;
}

.app-promo-share-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.03);
}

@media (max-width: 480px) {
  .app-promo-banner {
    padding: 10px 12px;
    gap: 8px;
  }
  .app-promo-icon {
    width: 34px;
    height: 34px;
    font-size: 11.5px;
  }
  .app-promo-title {
    font-size: 12.5px;
  }
  .app-promo-subtitle {
    font-size: 10.5px;
  }
  .app-promo-share-btn {
    padding: 4px 10px;
    font-size: 11px;
  }
}

/* Bottom Navigation */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 860px;
  margin: 0 auto;
  height: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab.active {
  color: var(--accent);
}

.nav-tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: transform 0.2s;
}

.nav-tab.active svg {
  transform: translateY(-2px);
}

.nav-tab span {
  font-size: 11px;
  font-weight: 600;
}

/* Bottom Sheet Modal */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg-surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  box-shadow: var(--sheet-shadow);
  z-index: 999;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 86vh;
  overflow-y: auto;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 5px;
  background: var(--border-color);
  border-radius: 3px;
  margin: 0 auto 16px auto;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-hanzi-title {
  font-family: var(--font-hanzi);
  font-size: 40px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.sheet-pinyin {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}

.sheet-hanviet {
  font-size: 15px;
  font-weight: 600;
  color: var(--info);
  margin-top: 2px;
}

.sheet-actions-top {
  display: flex;
  gap: 8px;
}

/* Hanzi Writer Container */
.hanzi-writer-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin: 16px 0;
  flex-wrap: wrap;
  min-height: 120px;
}

.writer-char-box {
  width: 130px;
  height: 130px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.writer-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.sheet-definitions {
  margin-top: 14px;
}

.def-section {
  margin-bottom: 14px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.def-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.def-text {
  font-size: 19px; /* Nghĩa to, rõ nét, dễ đọc trên cả điện thoại */
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.55;
  letter-spacing: -0.2px;
}

.external-links {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* Modal Overlays */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--sheet-shadow);
  max-height: 90vh;
  overflow-y: auto;
}

/* Toast System */
#toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: rgba(30, 32, 38, 0.92);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  backdrop-filter: blur(8px);
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.75s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

/* Closed sheet must not be focusable / readable by screen readers */
.bottom-sheet { visibility: hidden; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.3s; }
.bottom-sheet.active { visibility: visible; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s; }
.sheet-header > div:first-child { min-width: 0; }
.sheet-hanzi-title { word-break: break-all; }

/* Onboarding progress dots never changed (inline styles beat the .active class) */
.onboarding-dot { transition: width 0.2s ease, background-color 0.2s ease; }
.onboarding-dot.active { background: var(--accent) !important; width: 22px !important; }
.onboarding-dot:not(.active) { background: var(--border-color) !important; width: 8px !important; }
