/* =============================================
   panel-fix.css â€” Layout & feature patches
   IMPORTANT: Never override display with !important
   JS controls display via element.style.display
   ============================================= */

/* ===== Full-height app layout ===== */
html, body { height: 100%; overflow: hidden; }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar doesn't grow */
.top-bar { flex-shrink: 0; }

/* Results area stretches */
.results-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.distributor-area {
  flex: 1;
  min-height: 0;
}

.hscroll-bar-wrap { flex-shrink: 0; }

/* ===== Tool panel: ONLY layout props, NO display ===== */
/* display is controlled exclusively by JS switchType() */
.tool-panel-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
  background: var(--bg-primary);
}

.tool-panel-inner {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tool-panel-header { flex-shrink: 0; }
.tool-panel-header h2 { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.tool-panel-header p  { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ===== Translate panel ===== */
.translate-ui {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.translate-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}

.translate-box {
  display: flex;
  flex-direction: column;
  min-height: 240px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.translate-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.translate-lang-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}

.translate-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  padding: 16px;
  resize: none;
  font-family: inherit;
  min-height: 180px;
}
.translate-textarea:focus { outline: none; }

.translate-output {
  flex: 1;
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  cursor: pointer;
  min-height: 180px;
  white-space: pre-wrap;
}
.translate-output:hover { background: rgba(99,102,241,.04); }
.translate-placeholder { color: var(--text-muted); font-style: italic; }

.translate-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 40px;
}

.translate-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--accent); color: white;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.translate-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.translate-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.translate-swap-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.translate-swap-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Model selector bar */
.translate-model-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}
.translate-model-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); white-space: nowrap;
}
.translate-model-select {
  flex: 1; padding: 7px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary); font-size: 13px; cursor: pointer;
}
.translate-model-select:focus { outline: none; border-color: var(--accent); }
.translate-model-hint { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Quick phrases */
.quick-phrases { flex-shrink: 0; }
.phrases-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.phrase-btn {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px; cursor: pointer; transition: all .15s;
}
.phrase-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); }

.lang-select {
  padding: 5px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary); font-size: 12px;
}
.lang-select:focus { outline: none; border-color: var(--accent); }

/* Translate states */
.translate-loading { color: var(--text-muted); font-style: italic; animation: pulse 1.5s infinite; }
.translate-result  { color: var(--text-primary); }
.translate-error   { color: #f87171; }
@keyframes pulse { 0%,100% { opacity:.5; } 50% { opacity:1; } }

/* ===== Announcement panel ===== */
.announcement-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.announce-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-secondary);
}
.announce-info    { border-left: 4px solid #818cf8; }
.announce-warning { border-left: 4px solid #fbbf24; }
.announce-urgent  { border-left: 4px solid #f87171; background: rgba(239,68,68,.04); }

.announce-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px; flex-wrap: wrap;
}
.announce-icon { font-size: 18px; flex-shrink: 0; }
.announce-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; }
.announce-level-badge {
  font-size: 11px; font-weight: 600;
  padding: 2px 10px; border-radius: 20px;
  background: rgba(99,102,241,.12); color: var(--accent);
}
.announce-warning .announce-level-badge { background: rgba(245,158,11,.12); color: #fbbf24; }
.announce-urgent  .announce-level-badge { background: rgba(239,68,68,.12);  color: #f87171; }
.announce-time { font-size: 11px; color: var(--text-muted); }
.announce-card-body {
  padding: 0 18px 16px 42px;
  font-size: 13px; line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.announce-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: 14px;
}

/* ===== Distributor enhancements ===== */

/* Website row */
.dist-website-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 4px 0;
}
.dist-website-url {
  font-size: 12px; color: var(--accent);
  cursor: pointer; opacity: .8;
  text-decoration: underline; text-underline-offset: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px;
  transition: opacity .15s;
}
.dist-website-url:hover { opacity: 1; }
.dist-website-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0;
  background: rgba(99,102,241,.12); color: var(--accent);
  font-size: 13px; font-weight: 700; border: 1px solid rgba(99,102,241,.2);
  text-decoration: none; cursor: pointer; transition: all .15s;
}
.dist-website-btn:hover { background: rgba(99,102,241,.25); }

/* Title row layout */
.dist-title-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}

/* Formatted rule items */
.dist-rule-list { list-style: none; padding: 0; margin: 0; }
.dist-rule-item {
  padding: 5px 0 5px 18px;
  position: relative;
  font-size: 13px; line-height: 1.6;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.dist-rule-item:last-child { border-bottom: none; }
.dist-rule-item::before {
  content: 'â€¢'; position: absolute; left: 4px;
  color: var(--accent); opacity: .6;
}
.dist-rule-item strong { color: var(--text-primary); font-weight: 600; }
.dist-rule-item em { color: var(--text-muted); font-style: italic; }
.rule-highlight {
  background: rgba(251,191,36,.15);
  color: #fbbf24;
  padding: 1px 6px; border-radius: 4px;
  font-weight: 500;
}

/* ===== Distributor section labels ===== */
/* Aliases for the header structure used in app.js */
.dist-header {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dist-title-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  flex-wrap: wrap;
}
.dist-title {
  font-size: 16px; font-weight: 700;
  color: var(--primary-light, var(--accent));
}
.dist-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}

.dist-section {
  padding: 10px 18px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.dist-section:first-of-type { border-top: none; }

.dist-section-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 8px;
}

/* ===== Script card chips (new renderer) ===== */
.dist-script-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 14px;
  background: var(--bg-tertiary, var(--bg-input));
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
  cursor: pointer;
  transition: all .18s;
  min-width: 0;
}
.dist-script-card:hover {
  border-color: var(--accent);
  background: rgba(99,102,241,.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,.15);
}
.dist-script-name {
  font-size: 12px; font-weight: 600;
  color: var(--text-primary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.dist-script-preview {
  font-size: 11px; color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* Rule items in new renderer */
.dist-rule-item {
  position: relative;
  padding: 4px 0 4px 16px;
  font-size: 13px; line-height: 1.55;
  color: var(--text-primary);
}
.dist-rule-item::before {
  content: '\2022'; position: absolute; left: 0;
  color: var(--primary-light, var(--accent));
  font-weight: bold;
}
.dist-rule-item strong { font-weight: 600; color: var(--text-primary); }
.dist-rule-item em { font-style: italic; color: var(--text-muted); }
.rule-highlight {
  background: rgba(251,191,36,.15); color: #fbbf24;
  padding: 1px 6px; border-radius: 4px; font-weight: 500;
}


/* Override dist-scripts-grid ¡ª more compact */.dist-scripts-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important; gap: 10px !important; margin-top: 0 !important; }

/* ===========================
   Copied from original style.css
   =========================== */

/* Plan name cell */
.plan-name-cell { font-weight: 600; color: var(--text-primary); }
.plan-name-en { display: block; font-size: 13px; color: var(--primary-light); font-weight: 700; }
.plan-name-zh { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* Reset cell - structured */
.reset-cell { display: flex; flex-direction: column; gap: 5px; }
.reset-row  { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.reset-type-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  border-radius: 3px; padding: 1px 5px; flex-shrink: 0; white-space: nowrap;
}
.reset-data { background: rgba(99,102,241,.12); color: var(--primary-light); border: 1px solid rgba(99,102,241,.25); }
.reset-date { background: rgba(245,158,11,.10); color: #f59e0b; border: 1px solid rgba(245,158,11,.25); }
.reset-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.reset-countdown {
  font-size: 10px; font-weight: 600; color: #34d399;
  background: rgba(16,185,129,.09); border: 1px solid rgba(16,185,129,.2);
  border-radius: 10px; padding: 1px 7px; white-space: nowrap; transition: color .4s;
}
.reset-empty { color: var(--text-muted); opacity: .4; font-size: 13px; }
.reset-extra-text { font-size: 10px; color: var(--text-muted); line-height: 1.5; margin-top: 2px; padding-top: 3px; border-top: 1px dashed var(--border); }
.reset-plain-text  { font-size: 11px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; }

/* Telecom column */
.telecom-cell { }
.telecom-row-line {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  padding: 2px 0; border-bottom: 1px solid var(--border);
}
.telecom-row-line:last-of-type { border-bottom: none; }
.telecom-row-line > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.telecom-row-line.copyable { cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: 0 -4px; transition: background .12s; }
.telecom-row-line.copyable:hover { background: var(--hover-bg, rgba(255,255,255,.06)); }
.network-badge-inline { font-size: 10px; padding: 1px 7px; opacity: .85; flex-shrink: 0; }
.telecom-more-hint {
  cursor: pointer; color: var(--primary-light); font-size: 10px;
  padding: 3px 4px; margin-top: 2px;
  border-top: 1px dashed var(--border); border-radius: 3px; transition: background .12s;
}
.telecom-more-hint:hover { background: var(--hover-bg, rgba(255,255,255,.06)); opacity: 1; }

/* ===========================
   Distributor Search + Examples
   =========================== */

/* Header right side ¡ª contact info + examples button aligned */
.dist-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dist-header-right { display: flex; align-items: flex-start; gap: 10px; flex-shrink: 0; }

/* Examples toggle button */
.dist-examples-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-card, rgba(255,255,255,.04));
  color: var(--text-secondary); font-size: 12px; cursor: pointer;
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.dist-examples-btn:hover { border-color: var(--primary); color: var(--primary); }
.dist-examples-btn.active { background: rgba(99,102,241,.15); border-color: var(--primary); color: var(--primary); }

/* Examples expand section */
.dist-examples-section {
  border-top: 1px solid var(--border);
  background: var(--bg-card, rgba(255,255,255,.02));
  animation: slideDown .2s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px) } to { opacity:1; transform:none } }

.dist-example-item {
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
}

.dist-example-text {
  font-size: 13px; line-height: 1.6; color: var(--text-primary);
  background: var(--bg-hover, rgba(255,255,255,.04));
  border-radius: 6px; padding: 10px 12px;
  border-left: 3px solid var(--primary);
  white-space: pre-wrap;
}

.dist-example-img {
  max-width: 100%; max-height: 380px; object-fit: contain;
  border-radius: 8px; border: 1px solid var(--border);
  cursor: zoom-in; transition: transform .15s, box-shadow .15s;
  display: block;
}
.dist-example-img:hover { transform: scale(1.01); box-shadow: 0 4px 20px rgba(0,0,0,.4); }

/* Lightbox overlay */
.img-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.85); display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
.img-lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 8px; box-shadow: 0 8px 48px rgba(0,0,0,.6); }
.img-lightbox-close {
  position: absolute; top: 20px; right: 24px;
  font-size: 24px; color: #fff; opacity: .7; cursor: pointer;
  transition: opacity .15s;
}
.img-lightbox-close:hover { opacity: 1; }

/* ===========================
   Announcement Image
   =========================== */
.announce-card-img-wrap {
  padding: 0 18px 14px;
}
.announce-card-img {
  max-width: 100%; max-height: 320px; object-fit: contain;
  border-radius: 8px; border: 1px solid var(--border);
  display: block; cursor: zoom-in;
  transition: transform .15s, box-shadow .15s;
}
.announce-card-img:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
}
