/*
  LAYOUT — khung ngoài cùng của app: sidebar, topbar, vùng nội dung.
  KHÔNG đặt style riêng của 1 module cụ thể ở đây — chỉ những gì thuộc "cái vỏ" app,
  giống nhau ở mọi màn hình (đúng nguyên tắc core/shell trong CLAUDE.md).
*/

.app-shell {
  display: flex; min-height: calc(100vh - 32px);
  margin: 16px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

@media (max-width: 760px) {
  .app-shell { margin: 0; border-radius: 0; min-height: 100vh; }
}

/* --- Sidebar --- */
.sidebar {
  width: 218px;
  flex-shrink: 0;
  background: var(--surface-muted);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: linear-gradient(155deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  box-shadow: 0 6px 14px -6px var(--accent-shadow);
}

.brand-name { margin: 0; font-size: 14px; font-weight: 700; }
.brand-sub { margin: 0; font-size: 11px; color: var(--ink-muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-muted);
  border: none; background: transparent;
  text-align: left; width: 100%;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 8px 18px -10px var(--accent-shadow); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 12px; }
.sidebar-footer p { margin: 0 0 8px; font-size: 11px; color: var(--ink-muted); }
.sidebar-actions { display: flex; gap: 6px; }

/* --- Main / Topbar --- */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }

.app-topbar { padding: 20px 30px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.app-topbar h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -.015em; }
.topbar-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-muted); }
.topbar-date { margin: 0; font-size: 12.5px; color: var(--ink-muted); white-space: nowrap; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-pill {
  width: 34px; height: 34px; border-radius: 100px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-muted); border: 1px solid var(--line);
  color: var(--ink-muted); cursor: pointer; position: relative; flex-shrink: 0;
}
.icon-pill:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.icon-pill .dot {
  position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--surface);
}

.app-content { padding: 22px 30px 48px; }

/* --- Nút đổi ngôn ngữ (core shell, luôn ở topbar) --- */
.lang-switch { position: relative; flex-shrink: 0; }

.lang-trigger { padding: 0; }
.lang-trigger .flag { border-radius: 3px; display: block; box-shadow: 0 0 0 1px rgba(15, 42, 71, .12); }

.lang-menu[hidden] { display: none; }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  min-width: 168px; padding: 5px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.lang-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: none; background: transparent;
  border-radius: var(--radius);
  font: inherit; font-size: 13px;
  color: var(--ink-muted);
  text-align: left; width: 100%; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.lang-option .flag { border-radius: 3px; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(15, 42, 71, .12); }
.lang-option:hover { background: var(--surface-muted); color: var(--ink); }
.lang-option.is-current { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.lang-option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* --- Nhãn môi trường dev/prod ở góc sidebar --- */
.env-badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 100px;
  margin-bottom: 8px;
}
.env-dev { background: var(--amber-soft); color: var(--amber); }
.env-prod { background: var(--sage-soft); color: var(--sage); }

/* --- Toast (thông báo nổi góc dưới) --- */
#toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 15px; border-radius: var(--radius);
  font-size: 13px; max-width: 320px; opacity: 1; transition: opacity .4s ease;
  box-shadow: var(--shadow-soft);
}
.toast-danger { background: var(--red); }
.toast-out { opacity: 0; }
