/* =========================================================
   ToolHub — shared styles for individual tool pages
   Loaded after style.css (reuses variables, buttons, aurora)
   ========================================================= */

/* ---------- Tool header extras ---------- */
.nav__link--back { display: inline-flex; align-items: center; gap: 7px; }
.header__actions .nav__link--back { padding: 8px 14px; border-radius: var(--radius-pill); }
.header__actions .nav__link--back:hover { background: var(--surface); color: var(--text); }

/* ---------- Tool page shell ---------- */
.tool-page { padding: 40px 0 80px; }
.tool-hero { max-width: 720px; margin: 0 auto 34px; text-align: center; }
.tool-hero__icon {
  display: inline-grid; place-items: center; width: 66px; height: 66px; margin-bottom: 20px;
  border-radius: 19px; color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  box-shadow: 0 14px 34px -12px rgba(99,102,241,0.75);
}
.tool-hero__icon svg { width: 32px; height: 32px; }
.tool-hero h1 { margin: 0; font-size: clamp(1.9rem, 5vw, 2.9rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.tool-hero p { margin: 12px 0 0; color: var(--text-soft); font-size: 1.05rem; }

.breadcrumb { display: flex; justify-content: center; gap: 8px; margin-bottom: 22px; color: var(--text-mute); font-size: 0.86rem; }
.breadcrumb a { color: var(--text-mute); transition: color .2s; }
.breadcrumb a:hover { color: var(--text-soft); }

/* ---------- Layout grids ---------- */
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: stretch; }
.tool-grid--wide { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.tool-single { max-width: 820px; margin: 0 auto; }

/* ---------- Panel (glass card) ---------- */
.panel {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
  backdrop-filter: blur(12px);
  padding: 26px;
}
.panel--sticky { position: sticky; top: 88px; }
.panel__title { margin: 0 0 4px; font-size: 1.15rem; font-weight: 700; }
.panel__sub { margin: 0 0 20px; color: var(--text-mute); font-size: 0.9rem; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field__label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; color: var(--text-soft); }
.field__hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--text-mute); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; padding: 13px 16px; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.25); border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: 1rem; font-weight: 500;
  transition: border-color .2s, background .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.input:focus { outline: none; border-color: rgba(139,92,246,0.7); box-shadow: 0 0 0 3px rgba(139,92,246,0.18); background: rgba(0,0,0,0.35); }
.input::placeholder { color: var(--text-mute); }
.input--suffix { padding-right: 58px; }
.input__suffix { position: absolute; right: 16px; color: var(--text-mute); font-size: 0.9rem; font-weight: 600; pointer-events: none; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237b7b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 42px; cursor: pointer; }

/* Segmented control */
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius-pill); background: rgba(0,0,0,0.3); border: 1px solid var(--border); width: 100%; }
.seg__btn { flex: 1; padding: 9px 14px; border: none; background: transparent; color: var(--text-soft); font-size: 0.9rem; font-weight: 600; border-radius: var(--radius-pill); transition: background .2s, color .2s; white-space: nowrap; }
.seg__btn.active { background: var(--surface-2); color: var(--text); box-shadow: 0 2px 8px -2px rgba(0,0,0,0.5); }

/* Range slider */
.range-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.range-row__val { font-weight: 700; color: var(--text); font-size: 0.95rem; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.12); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(135deg, #b7a9ff, #7fb0ff); cursor: pointer; border: 2px solid #12121c; box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #b7a9ff; cursor: pointer; border: 2px solid #12121c; }

/* ---------- Results ---------- */
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: none; }
.result-row:has(+ .result-row--total) { border-bottom: none; } /* tránh 2 đường kẻ sát nhau trước dòng tổng */
.result-row__label { color: var(--text-soft); font-size: 0.94rem; }
.result-row__val { font-weight: 700; font-size: 1rem; text-align: right; }
.result-row--total { margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--border-strong); border-bottom: none; }
.result-row--total .result-row__label { color: var(--text); font-weight: 700; font-size: 1.05rem; }
.result-row--total .result-row__val { font-size: 1.5rem; background: linear-gradient(100deg, #fff, #b7a9ff, #7fb0ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.val--neg { color: #fca5a5; }
.val--pos { color: #86efac; }

.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { padding: 18px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.04); border: 1px solid var(--border); }
.stat-card__label { font-size: 0.82rem; color: var(--text-mute); font-weight: 500; }
.stat-card__val { margin-top: 4px; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-top: 8px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 460px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: right; white-space: nowrap; }
.tbl th { background: #181820; color: var(--text-mute); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
.tbl th:first-child, .tbl td:first-child { text-align: center; color: var(--text-mute); }
.tbl tbody tr:nth-child(even), .tbl tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.tbl td { border-top: 1px solid var(--border); color: var(--text-soft); }
.table-scroll { max-height: 420px; overflow-y: auto; }

/* ---------- Dropzone / uploader ---------- */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 46px 24px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: rgba(255,255,255,0.02); cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone.drag { border-color: rgba(139,92,246,0.8); background: rgba(139,92,246,0.06); }
.dropzone.drag { transform: scale(1.01); }
.dropzone__icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-soft); }
.dropzone__icon svg { width: 28px; height: 28px; }
.dropzone__title { font-weight: 700; font-size: 1.05rem; }
.dropzone__sub { color: var(--text-mute); font-size: 0.88rem; }
.dropzone input[type="file"] { display: none; }

/* ---------- File result items ---------- */
.file-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.file-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.04); border: 1px solid var(--border); }
.file-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: rgba(0,0,0,0.4); flex-shrink: 0; border: 1px solid var(--border); }
.file-meta { min-width: 0; flex: 1; }
.file-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sizes { margin-top: 3px; font-size: 0.82rem; color: var(--text-mute); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.saved-badge { padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.saved-badge--good { background: rgba(134,239,172,0.14); color: #86efac; }
.saved-badge--neutral { background: rgba(255,255,255,0.08); color: var(--text-soft); }
.file-dl { flex-shrink: 0; }

/* ---------- Preview (editor / convert) ---------- */
.preview-stage { display: grid; place-items: center; padding: 18px; border-radius: var(--radius); background: repeating-conic-gradient(#15151f 0% 25%, #1b1b28 0% 50%) 50% / 22px 22px; border: 1px solid var(--border); min-height: 300px; }
.preview-stage canvas, .preview-stage img { max-width: 100%; max-height: 460px; border-radius: 8px; box-shadow: 0 20px 50px -20px rgba(0,0,0,0.8); }

/* Preset chips */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.preset { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--surface); transition: border-color .2s, transform .2s; padding: 0; }
.preset.active { border-color: rgba(139,92,246,0.9); box-shadow: 0 0 0 2px rgba(139,92,246,0.3); }
.preset:hover { transform: translateY(-2px); }
.preset canvas, .preset img { width: 100%; height: 64px; object-fit: cover; display: block; }
.preset__name { display: block; padding: 6px 4px; font-size: 0.72rem; font-weight: 600; text-align: center; color: var(--text-soft); }

/* ---------- Misc ---------- */
.note { display: flex; gap: 10px; padding: 14px 16px; border-radius: var(--radius-sm); background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.25); color: var(--text-soft); font-size: 0.86rem; margin-top: 18px; }
.note svg { width: 18px; height: 18px; flex-shrink: 0; color: #7fb0ff; margin-top: 1px; }
.note--warn { background: rgba(251,146,60,0.08); border-color: rgba(251,146,60,0.28); }
.note--warn svg { color: var(--orange); }
.btn--block { width: 100%; }
.btn--wide { padding: 14px 26px; }
.actions-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hidden { display: none !important; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; color: var(--text-mute); padding: 40px 20px; font-size: 0.94rem; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  /* minmax(0,1fr) — NOT plain 1fr — so a wide table (min-width) can't force
     the column (and the whole page) wider than the viewport. Lets the
     table's own overflow-x scroll engage instead of breaking the layout. */
  .tool-grid, .tool-grid--wide { grid-template-columns: minmax(0, 1fr); }
  .panel--sticky { position: static; }
  /* Mobile performance: live backdrop blur overheats phones — drop it.
     The panel keeps its own translucent gradient background. */
  .panel { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (max-width: 720px) {
  .header__actions .nav__link--back span { display: none; }
  .tool-page { padding: 26px 0 60px; }
  .panel { padding: 20px; }
  .stat-cards { grid-template-columns: 1fr; }
}
