/* ══════════════════════════════════════════════════════════════
   RTR FORMAT MODULE  — v6.1
   Layout: TopBar → HorizontalCategoryTabs → [Sidebar | Detail]
   Matches the AIVR reference screenshot exactly.
══════════════════════════════════════════════════════════════ */

#rtr-format-app {
  --fmt-bg:        #0c1824;
  --fmt-bg2:       #0f1d2c;
  --fmt-sidebar-bg:#f5f5f0;
  --fmt-sidebar-txt:#1a1a2a;
  --fmt-sidebar-sub:#666;
  --fmt-sidebar-bdr:#e0e0d8;
  --fmt-sidebar-hover:#e8e8e2;
  --fmt-sidebar-active-bg:#1a2540;
  --fmt-sidebar-active-txt:#ffffff;
  --fmt-bdr:       rgba(0,212,255,.14);
  --fmt-acc:       #00d4ff;
  --fmt-green:     #00c853;
  --fmt-amber:     #ff9800;
  --fmt-red:       #ff3b5c;
  --fmt-txt:       #d4e8f5;
  --fmt-txt2:      #6a8fa8;
  --fmt-mono:      'Share Tech Mono','Courier New',monospace;
  --fmt-head:      'Orbitron','Arial',sans-serif;
  --fmt-sans:      'Inter','Segoe UI',Arial,sans-serif;
  box-sizing: border-box;
  font-family: var(--fmt-sans);
  background: #ffffff;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #d8d8d0;
  border-radius: 8px;
  overflow: hidden;
}
#rtr-format-app *, #rtr-format-app *::before, #rtr-format-app *::after { box-sizing: inherit; }

/* ─── Top Bar ─── */
.fmt-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 50px;
  background: #1a2540;
  border-bottom: 1px solid #0d1830;
  flex-shrink: 0;
}
.fmt-topbar-logo { font-family: var(--fmt-head); font-size: .65rem; letter-spacing: 3px; color: var(--fmt-acc); }
.fmt-topbar-badge {
  font-size: .6rem; letter-spacing: 2px; color: #90cad8;
  border: 1px solid rgba(0,212,255,.3); padding: 2px 9px; border-radius: 3px;
  background: rgba(0,212,255,.07); font-family: var(--fmt-mono);
}
.fmt-topbar-search { margin-left: auto; }
.fmt-search-wrap { position: relative; }
.fmt-search-wrap::before {
  content: '🔍'; position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%); font-size: .72rem; pointer-events: none; line-height: 1;
}
#fmt-search {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 20px;
  color: #e8f4f8; font-family: var(--fmt-sans); font-size: .8rem;
  padding: 6px 14px 6px 30px; outline: none; width: 200px;
  transition: border-color .2s, width .25s;
}
#fmt-search::placeholder { color: rgba(255,255,255,.35); }
#fmt-search:focus { border-color: rgba(0,212,255,.5); width: 240px; background: rgba(255,255,255,.12); }

/* ─── Horizontal Category Tabs (matches screenshot nav exactly) ─── */
#fmt-tabbar {
  display: flex; align-items: stretch;
  background: #f0f0ea;
  border-bottom: 2px solid #d0d0c8;
  overflow-x: auto; scrollbar-width: none;
  flex-shrink: 0; min-height: 44px;
}
#fmt-tabbar::-webkit-scrollbar { display: none; }

.fmt-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 18px; min-height: 44px;
  border: none; border-right: 1px solid #d0d0c8;
  background: transparent; color: #444;
  font-family: var(--fmt-sans); font-size: .78rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s;
  position: relative; letter-spacing: .2px;
}
.fmt-tab:first-child { border-left: none; }
.fmt-tab:hover { background: #e2e2da; }
.fmt-tab-active {
  background: #1a2540 !important;
  color: #ffffff !important;
  font-weight: 600;
}
.fmt-tab-active::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 2px; background: #00d4ff;
}
.fmt-tab-icon { font-size: .9rem; flex-shrink: 0; }
.fmt-tab-name { font-size: .78rem; }
.fmt-tab-count {
  font-size: .6rem; font-family: var(--fmt-mono);
  background: rgba(0,0,0,.1); border-radius: 10px; padding: 1px 7px;
  color: inherit; opacity: .7; flex-shrink: 0;
}
.fmt-tab-active .fmt-tab-count { background: rgba(0,212,255,.2); opacity: 1; color: #7ef4ff; }

/* ─── Two-column body ─── */
.fmt-body {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
  height: calc(100vh - 162px); min-height: 500px;
}

/* ─── LEFT SIDEBAR ─── */
#fmt-sidebar {
  width: 260px; min-width: 220px;
  background: var(--fmt-sidebar-bg);
  border-right: 1px solid var(--fmt-sidebar-bdr);
  overflow-y: auto; flex-shrink: 0; padding: 0 0 20px;
  scrollbar-width: thin; scrollbar-color: #ccc transparent;
}
#fmt-sidebar::-webkit-scrollbar { width: 4px; }
#fmt-sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.fmt-sidebar-cat-label {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 8px; border-bottom: 1px solid var(--fmt-sidebar-bdr);
  margin-bottom: 2px; background: #ecece6;
}
.fmt-sidebar-cat-label--sm { margin-top: 10px; }
.fmt-sidebar-cat-icon { font-size: .88rem; flex-shrink: 0; }
.fmt-sidebar-cat-title {
  font-size: .67rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--fmt-sidebar-sub); flex: 1;
}
.fmt-sidebar-cat-count {
  font-size: .62rem; font-family: var(--fmt-mono);
  background: #1a2540; color: #fff; border-radius: 10px; padding: 1px 8px; flex-shrink: 0;
}

.fmt-cat-items { list-style: none; margin: 0; padding: 4px 0; }
.fmt-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 14px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s; color: var(--fmt-sidebar-txt);
}
.fmt-item:hover { background: var(--fmt-sidebar-hover); }
.fmt-item-active {
  background: var(--fmt-sidebar-active-bg) !important;
  border-left-color: #00d4ff !important;
  color: var(--fmt-sidebar-active-txt) !important;
}
.fmt-item-active .fmt-item-num  { color: rgba(255,255,255,.5) !important; }
.fmt-item-active .fmt-item-title{ color: #fff !important; font-weight: 600; }
.fmt-item-num {
  font-family: var(--fmt-mono); font-size: .62rem; color: #aaa;
  min-width: 18px; text-align: right; flex-shrink: 0;
}
.fmt-item-title { font-size: .82rem; line-height: 1.35; color: inherit; }
.fmt-no-results { padding: 24px 16px; font-size: .8rem; color: #888; font-style: italic; }

/* ─── RIGHT DETAIL PANEL ─── */
#fmt-detail-wrap {
  flex: 1; overflow-y: auto; background: #ffffff; min-width: 0;
  scrollbar-width: thin; scrollbar-color: #ccc transparent;
}
#fmt-detail-wrap::-webkit-scrollbar { width: 5px; }
#fmt-detail-wrap::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
#fmt-detail { padding: 28px 36px 52px; max-width: 860px; }

/* Breadcrumb */
.fmt-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .67rem; color: #888; margin-bottom: 10px; letter-spacing: .3px;
}
.fmt-bc-sep { opacity: .5; }
.fmt-bc-title { color: #1a2540; font-weight: 600; }

/* Title row — numbered box + title text, like screenshot */
.fmt-detail-title-row {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 14px; border-bottom: 2px solid #e8e8e0; margin-bottom: 22px;
}
.fmt-detail-num {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: #1a2540; color: #fff;
  font-family: var(--fmt-sans); font-size: .9rem; font-weight: 700;
  border-radius: 7px; flex-shrink: 0;
}
.fmt-detail-title {
  font-family: var(--fmt-sans); font-size: 1.4rem; font-weight: 700;
  color: #1a1a2a; margin: 0; line-height: 1.25;
  display: flex; align-items: center; gap: 8px;
}
.fmt-emg-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #ff3b5c;
  animation: emgblink 1.2s infinite; flex-shrink: 0;
}
@keyframes emgblink { 0%,100%{opacity:1;} 50%{opacity:.25;} }

/* When to use */
.fmt-when-section {
  background: #f8f8f5; border: 1px solid #e4e4da;
  border-radius: 8px; overflow: hidden; margin-bottom: 20px;
}
.fmt-section-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  font-size: .6rem; font-weight: 700; letter-spacing: 2px;
  color: #555; border-bottom: 1px solid #e4e4da;
  text-transform: uppercase; background: #efefea;
}
.fmt-section-icon { font-size: .82rem; }
.fmt-when-body { padding: 14px 16px; font-size: .875rem; line-height: 1.8; color: #333; }

/* Transmission cards */
.fmt-tx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.fmt-tx-card { border-radius: 8px; overflow: hidden; border: 1px solid #e0e0da; }
.fmt-tx-pilot { background: #f0faf4; border-color: #b8dfc4; }
.fmt-tx-atc   { background: #f0f5ff; border-color: #b8cbef; }
.fmt-tx-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  font-size: .6rem; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.fmt-tx-pilot .fmt-tx-header { color: #2e7d32; background: #e8f5ec; }
.fmt-tx-atc   .fmt-tx-header { color: #1565c0; background: #e8eeff; }
.fmt-tx-icon { font-size: .82rem; }
.fmt-tx-body {
  padding: 13px 16px; font-family: var(--fmt-mono);
  font-size: .82rem; line-height: 1.75; color: #1a1a2a;
}
.fmt-placeholder { color: #c77700; font-style: italic; }

/* Example conversation */
.fmt-convo-section { background: #f8f8f5; border: 1px solid #e4e4da; border-radius: 8px; overflow: hidden; }
.fmt-convo-header {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; border-bottom: 1px solid #e4e4da; background: #efefea;
}
.fmt-convo-icon { font-size: .82rem; }
.fmt-convo-label {
  font-size: .6rem; font-weight: 700; letter-spacing: 2px;
  color: #555; text-transform: uppercase; flex: 1;
}
.fmt-convo-source { font-family: var(--fmt-mono); font-size: .58rem; color: #888; letter-spacing: 1px; }

.fmt-convo-body {
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; background: #fafaf7;
}
.fmt-convo-row { display: flex; flex-direction: column; gap: 4px; }
.fmt-convo-pilot { align-items: flex-end; }
.fmt-convo-atc   { align-items: flex-start; }
.fmt-convo-role-badge { font-size: .6rem; font-weight: 700; letter-spacing: 1px; }
.fmt-badge-pilot {
  color: #1a5c33; background: rgba(0,200,83,.1);
  border: 1px solid rgba(0,200,83,.3); padding: 1px 8px; border-radius: 3px;
}
.fmt-badge-atc {
  color: #0d47a1; background: rgba(21,101,192,.1);
  border: 1px solid rgba(21,101,192,.3); padding: 1px 8px; border-radius: 3px;
}
.fmt-bubble {
  font-family: var(--fmt-mono); font-size: .82rem; line-height: 1.6;
  padding: 10px 15px; border-radius: 8px; max-width: 82%;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
/* Yellow pilot bubble + dark ATC bubble — exactly like screenshot */
.fmt-bubble-pilot { background: #f5c842; color: #1a1200; border-bottom-right-radius: 3px; }
.fmt-bubble-atc   { background: #1a2540; color: #e8f4f8; border-bottom-left-radius: 3px; }

/* ─── Mobile Back button ─── */
#fmt-back-btn {
  display: none; align-items: center; gap: 6px;
  padding: 7px 14px; margin: 10px 16px 0;
  background: #f0f0ea; border: 1px solid #ccc; border-radius: 5px;
  color: #1a2540; font-size: .78rem; cursor: pointer;
  font-family: var(--fmt-sans); font-weight: 600;
}

/* ─── Responsive ─── */
@media (max-width: 960px) {
  .fmt-tab { padding: 0 12px; }
  .fmt-tab-name { font-size: .72rem; }
}
@media (max-width: 800px) {
  .fmt-tab-name { display: none; }
  .fmt-tab-active .fmt-tab-name { display: inline; }
  .fmt-tab-count { display: none; }
  .fmt-tab-icon { font-size: 1rem; }
}
@media (max-width: 760px) {
  .fmt-body { position: relative; flex-direction: column; height: auto; min-height: auto; }
  #fmt-sidebar { width: 100%; max-width: 100%; border-right: none; border-bottom: 1px solid #ddd; max-height: 50vh; }
  #fmt-detail-wrap {
    position: fixed; inset: 0; background: #fff;
    transform: translateX(100%); transition: transform .28s ease; z-index: 9999; overflow-y: auto;
  }
  #fmt-detail-wrap.fmt-detail-visible { transform: translateX(0); }
  #fmt-back-btn { display: flex; }
  #fmt-detail { padding: 14px 16px 40px; }
  .fmt-detail-title { font-size: 1.1rem; }
  #fmt-search { width: 130px; }
}
@media (max-width: 480px) {
  #fmt-detail { padding: 10px 12px 40px; }
  .fmt-tx-grid { grid-template-columns: 1fr; }
  .fmt-tx-body, .fmt-bubble, .fmt-when-body { font-size: .76rem; }
}
