/* ==========================================================================
   Trolysme Hub — term.css
   Style cho Terminal Web (tiền tố .tm-)
   Nền tối #0b0f14, chữ #d6deeb, font ui-monospace,Menlo,Consolas,monospace 13px
   16 màu ANSI kiểu VSCode, responsive trên điện thoại
   ========================================================================== */

.tm-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  background: #0b0f14;
  color: #d6deeb;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.tm-container *,
.tm-container *::before,
.tm-container *::after {
  box-sizing: border-box;
}

/* ---------- 1. Trạng thái chưa mở (Cài đặt & Mã 2 bước) ---------- */
.tm-setup-wrapper {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.tm-setup-card {
  width: 100%;
  max-width: 480px;
  background: #111a2e;
  border: 1px solid #223052;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.tm-setup-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  color: #e6edf7;
  letter-spacing: 0.3px;
}

.tm-warn-box {
  border: 1px solid #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
}

.tm-warn-title {
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tm-warn-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #fde68a;
}

.tm-setup-field {
  margin-bottom: 16px;
}

.tm-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #a9b8d3;
  margin-bottom: 6px;
}

.tm-setup-input {
  width: 100%;
  background: #16213a;
  color: #e6edf7;
  border: 1px solid #223052;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 4px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.tm-setup-input:focus {
  border-color: #38bdf8;
}

.tm-open-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

.tm-err {
  color: #f87171;
  font-size: 12px;
  margin-top: 10px;
  min-height: 18px;
  text-align: center;
  word-break: break-word;
}

.tm-hint {
  color: #a9b8d3;
  font-size: 11px;
  margin-top: 8px;
  text-align: center;
  line-height: 1.4;
}

/* ---------- 2. Trạng thái đã mở (Terminal view) ---------- */
.tm-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* Thanh công cụ trên */
.tm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #111a2e;
  border-bottom: 1px solid #223052;
  flex: none;
  flex-wrap: wrap;
}

.tm-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tm-status {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: #a9b8d3;
}

.tm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex: none;
}

.tm-dot.tm-ok { background: #34d399; box-shadow: 0 0 6px rgba(52, 211, 153, 0.4); }
.tm-dot.tm-warn { background: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
.tm-dot.tm-bad { background: #f87171; box-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }

.tm-status-text {
  white-space: nowrap;
}

.tm-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Nút bấm chung */
.tm-btn {
  background: #16213a;
  color: #e6edf7;
  border: 1px solid #223052;
  border-radius: 6px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tm-btn:hover {
  border-color: #38bdf8;
  color: #fff;
}

.tm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tm-btn-primary {
  background: #38bdf8;
  color: #04202e;
  border-color: #38bdf8;
  font-weight: 600;
}

.tm-btn-primary:hover {
  background: #7dd3fc;
  border-color: #7dd3fc;
  color: #04202e;
}

.tm-btn-danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.4);
}

.tm-btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: #f87171;
  color: #fff;
}

.tm-reopen-btn {
  padding: 3px 8px;
  font-size: 11px;
}

/* Vùng đầu ra terminal */
.tm-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 10px 12px;
  background: #0b0f14;
  color: #d6deeb;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  overscroll-behavior: contain;
}

/* Dòng đầu ra */
.tm-line {
  min-height: 1.45em;
  white-space: pre-wrap;
  word-break: break-all;
}

.tm-reset-notice {
  color: #64748b;
  font-style: italic;
  padding: 2px 0;
  border-bottom: 1px dashed #334155;
  margin-bottom: 4px;
}

/* Nút cuộn xuống cuối */
.tm-scroll-btn {
  position: absolute;
  right: 18px;
  bottom: 110px;
  z-index: 10;
  background: #16213a;
  color: #38bdf8;
  border: 1px solid #38bdf8;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s, background-color 0.15s;
}

.tm-scroll-btn:hover {
  background: #223052;
  transform: translateY(-2px);
}

/* Vùng điều khiển dưới đáy */
.tm-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  background: #111a2e;
  border-top: 1px solid #223052;
  flex: none;
}

/* Hàng nút nhanh điện thoại */
.tm-quick-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.tm-quick-bar::-webkit-scrollbar {
  display: none;
}

.tm-quick-btn {
  background: #16213a;
  color: #e6edf7;
  border: 1px solid #223052;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  min-width: 44px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: all 0.12s;
  flex: none;
}

.tm-quick-btn:hover,
.tm-quick-btn:active {
  background: #223052;
  border-color: #38bdf8;
  color: #fff;
}

/* Hàng nhập lệnh */
.tm-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tm-input {
  flex: 1;
  min-width: 0;
  background: #0b0f14;
  color: #d6deeb;
  border: 1px solid #223052;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.tm-input:focus {
  border-color: #38bdf8;
}

.tm-input::placeholder {
  color: #64748b;
}

.tm-btn-send {
  background: #38bdf8;
  color: #04202e;
  border: 1px solid #38bdf8;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: none;
  transition: background-color 0.15s;
}

.tm-btn-send:hover {
  background: #7dd3fc;
  border-color: #7dd3fc;
}

/* Hàng gợi ý lệnh */
.tm-sugg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tm-sugg-label {
  font-size: 11px;
  color: #a9b8d3;
  margin-right: 2px;
  flex: none;
}

.tm-chip {
  background: #16213a;
  color: #93c5fd;
  border: 1px solid #223052;
  border-radius: 4px;
  padding: 3px 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tm-chip:hover {
  background: #223052;
  border-color: #38bdf8;
  color: #fff;
}

/* Thước đo ký tự (ẩn) */
.tm-measure {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  top: -9999px;
  left: -9999px;
  pointer-events: none;
}

/* ---------- 3. 16 màu ANSI & Kiểu chữ (VSCode Dark Style) ---------- */
.tm-fg0  { color: #484f58; } /* Black (làm sáng để đọc được trên nền đen) */
.tm-fg1  { color: #cd3131; } /* Red */
.tm-fg2  { color: #0dbc79; } /* Green */
.tm-fg3  { color: #e5e510; } /* Yellow */
.tm-fg4  { color: #2472c8; } /* Blue */
.tm-fg5  { color: #bc3fbc; } /* Magenta */
.tm-fg6  { color: #11a8cd; } /* Cyan */
.tm-fg7  { color: #e5e5e5; } /* White */
.tm-fg8  { color: #768390; } /* Bright Black (Gray) */
.tm-fg9  { color: #f14c4c; } /* Bright Red */
.tm-fg10 { color: #23d18b; } /* Bright Green */
.tm-fg11 { color: #f5f543; } /* Bright Yellow */
.tm-fg12 { color: #3b8eea; } /* Bright Blue */
.tm-fg13 { color: #d670d6; } /* Bright Magenta */
.tm-fg14 { color: #29b8db; } /* Bright Cyan */
.tm-fg15 { color: #ffffff; } /* Bright White */

.tm-bg0  { background-color: #000000; }
.tm-bg1  { background-color: #cd3131; color: #fff; }
.tm-bg2  { background-color: #0dbc79; color: #000; }
.tm-bg3  { background-color: #e5e510; color: #000; }
.tm-bg4  { background-color: #2472c8; color: #fff; }
.tm-bg5  { background-color: #bc3fbc; color: #fff; }
.tm-bg6  { background-color: #11a8cd; color: #000; }
.tm-bg7  { background-color: #e5e5e5; color: #000; }
.tm-bg8  { background-color: #666666; color: #fff; }
.tm-bg9  { background-color: #f14c4c; color: #fff; }
.tm-bg10 { background-color: #23d18b; color: #000; }
.tm-bg11 { background-color: #f5f543; color: #000; }
.tm-bg12 { background-color: #3b8eea; color: #fff; }
.tm-bg13 { background-color: #d670d6; color: #fff; }
.tm-bg14 { background-color: #29b8db; color: #000; }
.tm-bg15 { background-color: #ffffff; color: #000; }

.tm-bold { font-weight: 700; }
.tm-dim { opacity: 0.65; }
.tm-italic { font-style: italic; }
.tm-underline { text-decoration: underline; }
.tm-inv { filter: invert(100%); }

/* ---------- 4. Responsive cho điện thoại ---------- */
@media (max-width: 768px) {
  .tm-topbar {
    padding: 6px 10px;
    gap: 6px;
  }
  .tm-actions .tm-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .tm-bottom {
    padding: 6px 10px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  /* Font input >= 16px để iOS không tự phóng to màn hình */
  .tm-input {
    font-size: 16px;
    padding: 10px 12px;
  }
  .tm-quick-btn {
    min-height: 40px;
    min-width: 48px;
    font-size: 14px;
  }
  .tm-btn-send {
    padding: 10px 16px;
    font-size: 14px;
  }
  .tm-scroll-btn {
    bottom: 125px;
    right: 12px;
  }
  .tm-sugg-row {
    display: none;
  }
}

/* sửa: hidden luôn ẩn; hàng nút nhanh xuống dòng thay vì tràn */
[class*="tm-"][hidden]{display:none !important}
.tm-quick-bar{flex-wrap:wrap !important;overflow-x:visible !important}
