/* AIM Training Native CSS */
#aim-training-root {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  --at-nav-bg: rgba(10, 22, 40, 0.95);
  --at-card-bg: rgba(15, 31, 61, 0.6);
  --at-card-hover: rgba(201, 168, 76, 0.08);
  --at-border: rgba(201, 168, 76, 0.2);
  --at-border-light: rgba(255, 255, 255, 0.1);
  --at-text: #e8eaf0;
  --at-text-dim: #8892a4;
  --at-gold: #c9a84c;
  --at-gold-hover: #e8c96a;
  --at-green: #4caf78;
  --at-red: #e05c5c;
  --at-bg: var(--navy, #050d1a);
  --at-panel: var(--navy2, #0a1628);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--at-text);
  padding-bottom: 60px;
}

#aim-training-root .at-container {
  width: 100%;
  min-width: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

#aim-training-root a {
  color: var(--at-gold);
  text-decoration: none;
  cursor: pointer;
}

#aim-training-root a:hover {
  text-decoration: underline;
}

/* Search and Library */
.at-search-container {
  display: flex;
  align-items: center;
  position: relative;
}
.at-search-input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--at-border);
  border-radius: 6px;
  color: white;
  font-size: 16px;
  box-sizing: border-box;
}
.at-search-input:focus {
  outline: none;
  border-color: var(--at-gold);
}
.at-search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--at-text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.at-search-clear:hover {
  color: white;
}
.at-library-filters {
  gap: 8px;
  border-bottom: none;
}
.at-library-filters button.at-nav-item {
  background: var(--at-card-bg);
  border: 1px solid var(--at-border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--at-text-dim);
}
.at-library-filters button.at-nav-item:hover {
  background: var(--at-card-hover);
  color: var(--at-text);
}
.at-library-filters button.at-nav-item.active {
  background: var(--at-gold);
  color: #000;
  border-color: var(--at-gold);
}
.at-chapter-matches {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  border-top: 1px solid var(--at-border-light);
  padding-top: 8px;
}
.at-chapter-match-link {
  font-size: 13px;
  color: var(--at-gold);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.at-chapter-match-link:hover {
  text-decoration: underline;
}

/* Chapter matches expand/collapse */
.at-chapter-matches-details {
  margin-top: 4px;
}
.at-chapter-match-summary {
  font-size: 11px;
  color: var(--at-text-dim);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.at-chapter-match-summary::-webkit-details-marker {
  display: none;
}
.at-chapter-match-summary:hover {
  color: white;
}
.at-chapter-matches-more {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-left: 8px;
  border-left: 1px solid var(--at-border-light);
}

/* Nav */
.at-nav {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--at-border);
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.at-nav-item {
  color: var(--at-text-dim);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 4px;
  transition: all 0.2s;
}

.at-nav-item:hover, .at-nav-item.active {
  color: var(--at-text);
  background: var(--at-card-hover);
  text-decoration: none;
}

.at-nav-item.active {
  border-bottom: 2px solid var(--at-gold);
  border-radius: 4px 4px 0 0;
}

.at-library-filters button.at-nav-item.active {
  border-bottom: 1px solid var(--at-gold);
  border-radius: 20px;
}

/* Typography */
.at-title {
  font-family: 'Cinzel', serif;
  font-size: 32px;
  color: var(--at-gold);
  margin-bottom: 8px;
  line-height: 1.2;
}

.at-subtitle {
  color: var(--at-text-dim);
  font-size: 16px;
  margin-bottom: 24px;
}

.at-disclaimer {
  background: rgba(240, 165, 0, 0.1);
  border: 1px solid rgba(240, 165, 0, 0.3);
  color: #f0a500;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.at-disclaimer:empty { display: none; }

/* Buttons */
.at-btn {
  background: linear-gradient(135deg, var(--at-gold), #a07830);
  border: none;
  border-radius: 6px;
  color: #050d1a;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
}

.at-btn:hover { opacity: 0.88; }
#aim-training-root a.at-btn:not(.at-btn-outline):not(.at-btn-secondary) {
  color: #050d1a;
}
.at-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

.at-btn-outline {
  background: transparent;
  border: 1px solid var(--at-gold);
  color: var(--at-gold);
}
.at-btn-outline:hover {
  background: var(--at-card-hover);
}

.at-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--at-text);
  border: 1px solid var(--at-border-light);
}
.at-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Layout */
.at-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 24px;
}

.at-card {
  background: var(--at-card-bg);
  border: 1px solid var(--at-border);
  border-radius: 8px;
  padding: 20px;
  transition: border-color 0.2s;
  display: flex;
  flex-direction: column;
}

.at-card:hover {
  border-color: var(--at-gold);
}

.at-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--at-text);
  margin-bottom: 8px;
}

.at-card-desc {
  font-size: 14px;
  color: var(--at-text-dim);
  margin-bottom: 16px;
  flex-grow: 1;
}

.at-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.at-badge.completed { background: rgba(76, 175, 120, 0.15); color: var(--at-green); border: 1px solid rgba(76, 175, 120, 0.3); }
.at-badge.incomplete { background: rgba(255, 255, 255, 0.05); color: var(--at-text-dim); border: 1px solid var(--at-border-light); }

/* Error Message */
.at-error {
  background: rgba(224, 92, 92, 0.1);
  border: 1px solid rgba(224, 92, 92, 0.3);
  color: var(--at-red);
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-size: 14px;
  display: none;
}
.at-error.visible { display: block; }

/* Lesson/Article Content */
.at-content {
  min-width: 0;
  max-width: 100%;
  background: var(--at-panel);
  border: 1px solid var(--at-border);
  border-radius: 8px;
  padding: 32px;
  margin-bottom: 32px;
  line-height: 1.6;
}

.at-content h1, .at-content h2, .at-content h3 {
  color: #fff;
  margin-top: 24px;
  margin-bottom: 16px;
  font-family: 'Cinzel', serif;
}

.at-content p, .at-content ul {
  margin-bottom: 16px;
  color: #d0d8e8;
}
.at-content li { margin-bottom: 8px; margin-left: 20px; }

/* Reader HUD */
.at-reader-hud {
  position: sticky;
  bottom: 20px;
  left: 0;
  right: 0;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: rgba(10, 22, 40, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--at-border);
  border-radius: 30px;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 100;
}
.at-reader-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.at-reader-stat-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--at-gold);
}
.at-reader-stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--at-text-dim);
}

/* Wiki Grid */
.at-wiki-cat {
  margin-bottom: 40px;
}
.at-wiki-cat-title {
  font-size: 20px;
  font-family: 'Cinzel', serif;
  color: var(--at-gold);
  border-bottom: 1px solid var(--at-border);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

/* Table */
.at-table {
  width: 100%;
  border-collapse: collapse;
}
.at-table th, .at-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--at-border-light);
}
.at-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--at-text-dim);
  font-weight: 700;
}
.at-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* Manual Reader */
.at-manual-layout {
  display: flex;
  gap: 32px;
  margin-top: 24px;
}
.at-manual-sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--at-border);
  padding-right: 16px;
  max-height: 80vh;
  overflow-y: auto;
}
.at-manual-content {
  flex-grow: 1;
  min-width: 0;
}
.at-manual-chapter-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--at-text-dim);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 4px;
}
.at-manual-chapter-btn:hover { background: rgba(255,255,255,0.05); color: var(--at-text); }
.at-manual-chapter-btn.active { background: rgba(201, 168, 76, 0.1); color: var(--at-gold); font-weight: 600; }
.at-manual-search {
  width: 100%;
  padding: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--at-border);
  border-radius: 4px;
  color: white;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  body:has(#screen-aim-training.active) .main { min-width: 0; width: 100%; }
  body:has(#screen-aim-training.active) .content { min-width: 0; padding: 16px; }
  body:has(#screen-aim-training.active) .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  body:has(#screen-aim-training.active) .topbar-right { flex-wrap: wrap; max-width: 100%; gap: 8px; }
  #screen-aim-training .firm-scope-hdr { flex-wrap: wrap; min-width: 0; }
  #aim-training-root .at-container { padding: 8px 0; }
  #aim-training-root .at-content { padding: 20px 16px; }
  #aim-training-root .at-title { font-size: 26px; }
  #aim-training-root .at-nav { gap: 4px; }
  #aim-training-root .at-nav-item { padding: 8px 10px; }
  #aim-training-root .at-btn { white-space: normal; max-width: 100%; justify-content: center; }
  #aim-training-root .at-table { display: block; overflow-x: auto; max-width: 100%; }
  .at-manual-layout { flex-direction: column; }
  .at-manual-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--at-border); padding-bottom: 16px; max-height: 200px; }
  .at-reader-hud { width: 100%; padding: 12px; gap: 12px; border-radius: 8px; justify-content: center; bottom: 8px; }
  .at-reader-hud .at-btn { flex-basis: 100%; }
}

/* HTML Content Formatting */
.at-html {
   color: #d0d8e8;
   line-height: 1.7;
}
.at-html a { color: var(--at-gold); }
.at-html strong { color: #fff; }
.at-html p { margin-bottom: 16px; }
.at-html ul, .at-html ol { margin-bottom: 16px; margin-left: 24px; }
.at-html li { margin-bottom: 8px; }
.at-html h1, .at-html h2, .at-html h3, .at-html h4 { color: #fff; margin-top: 24px; margin-bottom: 12px; }
.at-html pre { background: rgba(0,0,0,0.4); padding: 12px; border-radius: 4px; overflow-x: auto; margin-bottom: 16px; border: 1px solid var(--at-border-light); }
.at-html code { font-family: monospace; background: rgba(255,255,255,0.05); padding: 2px 4px; border-radius: 3px; }
.at-html blockquote { border-left: 4px solid var(--at-gold); padding-left: 16px; color: var(--at-text-dim); margin-left: 0; font-style: italic; }

/* Take over the main app sidebar when in training */
body.aim-training-active .sidebar { display:flex !important; width:280px; }
body.aim-training-active .main { margin-left:280px !important; min-width:0; }
#training-sidebar-root .nav-item { white-space:normal; text-decoration:none; }
#training-sidebar-root .at-sb-scroll { min-height:0; }
#training-sidebar-root { --at-gold:#c9a84c; --at-text:#d0d8e8; --at-border:rgba(201,168,76,.3); }
body.aim-training-active .at-manual-sidebar { display:none; }
body.aim-training-active .at-manual-content { width:100%; min-width:0; }
.at-roadmap-toggle { display:none; }
@media (max-width:768px) {
  body.aim-training-active #app { flex-direction:column; }
  body.aim-training-active .sidebar { position:relative; width:100%; height:55vh !important; min-height:0; flex:none; }
  body.aim-training-active .main { margin-left:0 !important; width:100%; }
  body.aim-training-active #training-sidebar-root { max-height:55vh; }
  .at-roadmap-toggle { display:block; margin:10px 16px; background:#c9a84c; color:#0b1526; }
  body.aim-training-active.at-roadmap-collapsed .sidebar { height:300px !important; }
  body.at-roadmap-collapsed #training-sidebar-root .at-sb-scroll { max-height:205px; flex:none !important; }
  body.at-roadmap-collapsed #training-sidebar-root .sidebar-footer { display:none; }
}
body.aim-training-active .sidebar > .sidebar-logo,
body.aim-training-active .sidebar > .logout-btn,
body.aim-training-active .sidebar > .sidebar-nav,
body.aim-training-active .sidebar > .sidebar-footer {
  display: none !important;
}

body.aim-training-active .sidebar > #training-sidebar-root {
  display: flex !important;
}

#training-sidebar-root details > summary::-webkit-details-marker {
  display: none;
}

.at-sb-scroll::-webkit-scrollbar {
  width: 6px;
}
.at-sb-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.at-sb-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
.at-sb-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}
