/* ══════════════════════════════════════════════
   THEME TOKENS — light (default) + dark (Nexa)
   ══════════════════════════════════════════════ */
:root {
  --bg-app:         #f2f2f7;
  --bg-header:      #ffffff;
  --bg-sidebar:     #f5f5f7;
  --bg-card:        #ffffff;
  --bg-input:       #f9f9fb;
  --bg-tab-bar:     #f2f2f7;
  --bg-tab-inner:   #e3e3e8;
  --bg-tab-active:  #ffffff;
  --bg-chip-bar:    #e3e3e8;
  --bg-chip-active: #ffffff;

  --border:         rgba(0,0,0,0.08);
  --border-strong:  rgba(0,0,0,0.15);
  --border-input:   #e5e5ea;

  --text-primary:   #1d1d1f;
  --text-secondary: #636366;
  --text-tertiary:  #8e8e93;

  --accent:         #007aff;
  --accent-bg:      #f0f7ff;
  --accent-border:  #007aff;

  --btn-ghost-bg:    #ffffff;
  --btn-ghost-color: #1d1d1f;
  --btn-ghost-hover: #f5f5f7;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.10);
  --scrollbar-thumb: #d1d1d6;
}

[data-theme="dark"] {
  /* Nexa black × gold — đúng brand */
  --bg-app:         #111111;
  --bg-header:      #0d0d0d;
  --bg-sidebar:     #141414;
  --bg-card:        #1a1a1a;
  --bg-input:       #1e1e1e;
  --bg-tab-bar:     #0d0d0d;
  --bg-tab-inner:   #1a1a1a;
  --bg-tab-active:  #242424;
  --bg-chip-bar:    #1a1a1a;
  --bg-chip-active: #242424;

  --border:         rgba(255,209,0,0.12);
  --border-strong:  rgba(255,209,0,0.25);
  --border-input:   rgba(255,255,255,0.08);

  --text-primary:   #f0f0f0;
  --text-secondary: #888888;
  --text-tertiary:  #555555;

  --accent:         #FFD100;
  --accent-bg:      rgba(255,209,0,0.08);
  --accent-border:  #FFD100;

  --btn-ghost-bg:    #1a1a1a;
  --btn-ghost-color: #f0f0f0;
  --btn-ghost-hover: #222222;

  --shadow-sm: 0 1px 6px rgba(0,0,0,0.6);
  --shadow-md: 0 4px 32px rgba(0,0,0,0.7);
  --scrollbar-thumb: rgba(255,209,0,0.22);
}

/* ── Theme switch: 1s transition on all color props ── */
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition:
    background-color 1s cubic-bezier(0.4, 0, 0.2, 1),
    background     1s cubic-bezier(0.4, 0, 0.2, 1),
    border-color   1s cubic-bezier(0.4, 0, 0.2, 1),
    color          1s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow     1s cubic-bezier(0.4, 0, 0.2, 1),
    text-shadow    1s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, #root {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-outfit), 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

button {
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

button:focus-visible {
  outline: 2px solid #0f0f0f;
  outline-offset: 2px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app__workspace {
  display: flex;
  flex: 1 1;
  overflow: hidden;
  min-height: 0;
}

.app__main {
  flex: 1 1;
  display: flex;
  overflow: hidden;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .app__workspace {
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 56px; /* chỗ cho toolbar fixed */
    min-height: 0;
  }

  .app__main {
    flex: 1 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* bắt buộc — flex item co lại được để scroll hoạt động */
  }
}

.processing-overlay {
  position: fixed;
  inset: 0;

  background: rgba(0,0,0,.55);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 99999;

  -webkit-backdrop-filter: blur(4px);

          backdrop-filter: blur(4px);
}

.processing-modal {
  background: white;

  padding: 32px;

  border-radius: 16px;

  min-width: 320px;

  text-align: center;

  box-shadow:
    0 20px 60px rgba(0,0,0,.25);
}

.processing-modal h3 {
  margin: 16px 0 8px;
}

.processing-modal p {
  margin: 0;
}

.processing-spinner {
  width: 50px;
  height: 50px;
  margin: 10px auto 20px;
  border: 3px solid rgba(0, 122, 255, 0.1);
  border-top-color: #007aff;
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.processing-modal-desc {
  margin: 10px 0 0;
  font-size: 13px;
  color: #8e8e93;
  line-height: 1.5;
}

.processing-logo--success {
  color: #34c759; /* Apple Green */
  animation: bounceSuccess 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes bounceSuccess {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.processing-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  animation: fadeInActions 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInActions {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0,0,0,.55);
  -webkit-backdrop-filter: blur(5px);
          backdrop-filter: blur(5px);
}

.processing-modal {
  width: 420px;
  max-width: calc(100vw - 32px);

  background: #fff;

  border-radius: 20px;

  padding: 30px;

  text-align: center;

  box-shadow:
    0 25px 60px rgba(0,0,0,.2);
}

.processing-logo {
  font-size: 48px;
  margin-bottom: 12px;

  animation: pulse 1.5s infinite;
}

.processing-steps {
  margin-top: 20px;

  text-align: left;

  display: flex;
  flex-direction: column;

  gap: 10px;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

/* ── Mobile: drop the heavy blur on full-screen scrims ──
   `backdrop-filter: blur()` forces the GPU to recompose the whole page every
   frame — brutal on phones, and while a synchronous task (AI remove-bg / effect)
   blocks the main thread it "freezes" mid-blur, so the sidebar underneath looks
   smeared. A plain dark scrim reads the same but costs almost nothing. */
@media (max-width: 768px) {
  .processing-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.62);
  }
}

/* ── Main Area and FAB Transitions ── */
.app__main {
  animation: mainFadeScale 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.sidebar-fab {
  animation: fabBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes mainFadeScale {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes fabBounce {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

.app__tabs {
  display: flex;
  justify-content: center;
  background: var(--bg-tab-bar);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
  align-items: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.app__tabs::-webkit-scrollbar {
  display: none;
}

/* Segmented control wrapper */
.app__tabs-inner {
  display: flex;
  background: var(--bg-tab-inner);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
  transition: background 0.3s ease;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 8px 18px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  font-family: inherit;
}

.tab-btn__icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  /* Icon đơn sắc: tô màu theo màu chữ của tab (currentColor) ở mọi trạng thái */
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transition: background-color 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn--active {
  background: var(--bg-tab-active);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Dark mode: gold accent on active tab */
[data-theme="dark"] .tab-btn--active {
  color: #FFD100;
  background: #23233a;
  box-shadow: 0 0 0 1px rgba(255,209,0,0.15), 0 2px 8px rgba(0,0,0,0.4);
}

/* Tab label helpers */
.tab-label--short { display: none; }

@media (max-width: 768px) {
  .app__tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .app__tabs {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .app__tabs-inner {
    flex: 1 1;
    min-width: 0;
    justify-content: space-between;
  }

  .tab-btn {
    flex: 1 1;
    justify-content: center;
    padding: 7px 6px;
    font-size: 11.5px;
    gap: 4px;
  }

  .tab-btn__icon {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 540px) {
  /* Chuyển sang label ngắn */
  .tab-label--full  { display: none; }
  .tab-label--short { display: inline; }

  .app__tabs {
    padding: 7px 8px;
  }

  .tab-btn {
    padding: 7px 5px;
    font-size: 11px;
    gap: 3px;
  }

  .tab-btn__icon {
    width: 15px;
    height: 15px;
  }
}

@media (max-width: 380px) {
  .tab-label--short { display: none; }

  .app__tabs {
    padding: 6px 6px;
  }

  .tab-btn {
    padding: 8px 6px;
  }

  .tab-btn__icon {
    width: 18px;
    height: 18px;
  }
}

/* ── Mockup Disclaimer Banner ── */
.mockup-disclaimer {
  padding: 8px 16px;
  background: transparent;
  border-top: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 4px;
}

.disclaimer-vi {
  font-size: 12px;
  font-weight: 600;
  color: #d9383a; /* Subtle premium red warning */
  margin: 0;
  letter-spacing: 0.2px;
  text-align: center;
}

.disclaimer-en {
  font-size: 10px;
  font-weight: 500;
  color: #8e8e93;
  margin: 0;
  letter-spacing: 0.1px;
  text-align: center;
}

@media (max-width: 768px) {
  .app__workspace--full {
    padding-bottom: 0 !important;
  }

  .contact-fab__btn {
    width: 44px;
    height: 44px;
  }

  .contact-fab__assistant {
    width: 44px;
    height: 44px;
  }

  .sidebar-fab {
    bottom: 72px;
    width: 44px;
    height: 44px;
  }
}

/* ── Safe area insets (iPhone notch / home bar) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .app__workspace {
      padding-bottom: calc(56px + env(safe-area-inset-bottom));
    }
  }
}
