/* Tokens and sidebar follow the Compliance Auditor (XDR Compliance Centre) design master. */
:root {
  --sidebar-width: 240px;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f3ee;
  --bg-card: #ffffff;
  --bg-card-hover: #faf7f3;
  --bg-elevated: #f3eee8;
  --border: #ded4c8;
  --border-subtle: #ece1d4;
  --text-primary: #201c18;
  --text-secondary: #5f5751;
  --text-muted: #867d74;
  --accent-primary: #e8610a;
  --accent-primary-dim: rgba(232,97,10,0.12);
  --accent-primary-glow: rgba(232,97,10,0.26);
  --sn-charcoal: #21232b;
  --nav-ink: #13263c;
  --nav-border: rgba(255,255,255,0.09);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-theme="dark-mode"] {
  --bg-primary: #141414;
  --bg-secondary: #1a1a1a;
  --bg-card: #1d1d1d;
  --bg-card-hover: #242424;
  --bg-elevated: #232323;
  --border: #302d2a;
  --border-subtle: #3a3530;
  --text-primary: #f5f2ee;
  --text-secondary: #cfc6bc;
  --text-muted: #a59a8d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

button { font-family: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-elevated); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

:focus-visible { outline: 3px solid var(--accent-primary); outline-offset: 2px; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 100;
  background:
    linear-gradient(180deg, rgba(242,157,29,0.98) 0%, rgba(236,145,13,0.98) 100%),
    linear-gradient(rgba(0,0,0,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.06) 1px, transparent 1px);
  background-size: auto, 48px 48px, 48px 48px;
  border-right: 1px solid var(--nav-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #2a2d37 0%, var(--sn-charcoal) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  text-decoration: none;
}

.sidebar-kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #f29d1d;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.sidebar-title {
  font-family: 'Sora', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.15;
}

.sidebar-menu-btn { display: none; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(19,38,60,0.72);
  padding: 4px 4px 2px;
}

.nav-section { --sec: #e8610a; }

.nav-section-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.nav-section-label::before {
  content: '';
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--sec);
}

.sidebar-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--nav-ink);
  text-decoration: none;
  border: 1px solid rgba(19,38,60,0.14);
  background: linear-gradient(135deg, rgba(255,255,255,0.42) 0%, rgba(255,255,255,0.18) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.35) inset, 0 1px 2px rgba(19,38,60,0.08);
  overflow: hidden;
  transition: var(--transition);
}

.sidebar-tab::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sec, #e8610a);
  opacity: 0;
  transition: var(--transition);
}

.sidebar-tab:hover {
  background: linear-gradient(135deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.4) 100%);
  border-color: rgba(19,38,60,0.24);
  box-shadow: 0 6px 16px rgba(19,38,60,0.14);
  transform: translateX(2px);
}

.sidebar-tab:hover::before { opacity: 1; }

.sidebar-tab.active {
  background: linear-gradient(135deg, #2b2f39 0%, #1c2028 100%);
  border-color: rgba(32,36,45,0.65);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(18,21,27,0.28);
  transform: none;
}

.sidebar-tab.active::before { opacity: 1; top: 0; bottom: 0; width: 4px; border-radius: 0; }

.sidebar-tab-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--sec, var(--nav-ink));
  box-shadow: 0 1px 3px rgba(19,38,60,0.16);
  transition: var(--transition);
}

.sidebar-tab-icon svg { width: 15px; height: 15px; }
.sidebar-tab-icon .ms-product-icon { width: 19px; height: 19px; display: block; object-fit: contain; }
.sidebar-tab:hover .sidebar-tab-icon { transform: scale(1.06); }
.sidebar-tab.active .sidebar-tab-icon { box-shadow: 0 0 0 2px var(--sec, #e8610a); }
.sidebar-tab-label { flex: 1; line-height: 1.2; }

.sidebar-tab-chev {
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  transform: translateX(-4px);
  transition: var(--transition);
}

.sidebar-tab:hover .sidebar-tab-chev,
.sidebar-tab.active .sidebar-tab-chev { opacity: 0.7; transform: none; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
}

.sidebar-utility-row { display: flex; gap: 6px; }

.theme-toggle-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid rgba(19,38,60,0.22);
  background: rgba(255,255,255,0.28);
  color: var(--nav-ink);
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.theme-toggle-btn svg { width: 14px; height: 14px; }
.theme-toggle-btn .icon-sun { display: none; }
body[data-theme="dark-mode"] .theme-toggle-btn .icon-sun { display: block; }
body[data-theme="dark-mode"] .theme-toggle-btn .icon-moon { display: none; }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  color: #213a5a;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1fcf85;
  box-shadow: 0 0 10px rgba(31,207,133,0.45);
}

.portal-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(19,38,60,0.72);
}


/* ===== MAIN LAYOUT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 20px 24px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body[data-active-view="toolView"] .main-content {
  height: 100vh;
  padding: 0;
}

body[data-active-view="toolView"] .page-header { display: none; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.page-header-copy { min-width: 0; }

.page-header-kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--accent-primary);
  font-weight: 700;
  margin-bottom: 4px;
}

.page-header-title {
  font-family: 'Sora', sans-serif;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}

.page-header-subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Tools carry their own title bar, so the platform header stays compact. */

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.header-btn:hover { border-color: rgba(232,97,10,0.4); background: var(--bg-card-hover); }
.header-btn svg { width: 13px; height: 13px; display: block; }

/* ===== HOME ===== */
.tool-group + .tool-group { margin-top: 28px; }

.tool-group-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.05);
  transition: var(--transition);
}

.tool-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

.tool-card-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #2b2f39 0%, #20242d 100%);
  color: #f29d1d;
}

.tool-card-icon svg { width: 18px; height: 18px; }

.tool-card-name {
  font-family: 'Sora', sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.tool-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  vertical-align: middle;
}

.tool-card-desc {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  flex: 1;
}

.tool-card-cta {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-primary);
}

/* ===== TOOL VIEW ===== */
.tool-view {
  flex: 1;
  min-height: 0;
  display: flex;
}

.tool-view[hidden] { display: none; }

.tool-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #ffffff;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.card-body { padding: 18px; font-size: 13px; color: var(--text-secondary); }

/* ===== SMALL SCREENS ===== */
@media (max-width: 860px) {
  .sidebar {
    position: sticky;
    bottom: auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 16px;
    overflow: visible;
  }

  .sidebar-brand { flex-direction: row; padding: 8px 12px; gap: 8px; }
  .sidebar-title { font-size: 14px; }

  .sidebar-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(19,38,60,0.22);
    background: rgba(255,255,255,0.28);
    color: var(--nav-ink);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  .sidebar-menu-btn svg { width: 16px; height: 16px; }

  .sidebar-nav, .sidebar-footer { display: none; width: 100%; }
  body.menu-open .sidebar-nav, body.menu-open .sidebar-footer { display: flex; }
  .sidebar-footer { margin-top: 0; }
  
  .main-content { margin-left: 0; padding: 16px; }
  body[data-active-view="toolView"] .main-content { height: auto; }
  .tool-frame { min-height: 80vh; }
  .page-header,
  body[data-active-view="toolView"] .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-title { font-size: 22px; }
}

/* Official product icons on the home cards sit on white so their colours read */
.tool-card-icon.has-product-icon { background: #ffffff; box-shadow: 0 0 0 1px var(--border); }
.tool-card-icon .ms-product-icon { width: 22px; height: 22px; display: block; object-fit: contain; }
