/* ==========================================================================
   Tree Sidebar Component Styles (Desktop Flyout & Mobile Drill-down)
   ========================================================================== */

:root {
  --sidebar-mobile-width: 85%;
  --sidebar-desktop-width: 280px;
  --sidebar-bg: #ffffff;
  --sidebar-border: #f1f5f9;
  --sidebar-text: #1e293b;
  --sidebar-text-muted: #64748b;
  --sidebar-hover-bg: #f8fafc;
}

/* Overlay container */
.app-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  z-index: 3000;
  pointer-events: none;
  display: none;
}

.app-sidebar-overlay.is-open {
  pointer-events: auto;
  display: block;
}

/* Background blur backdrop */
.app-sidebar-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.app-sidebar-overlay.is-open .app-sidebar-backdrop {
  opacity: 1;
}

/* Main Drawer */
.app-sidebar-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sidebar-mobile-width);
  max-width: 360px;
  height: 100%;
  background: var(--sidebar-bg);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
}

.app-sidebar-overlay.is-open .app-sidebar-drawer {
  transform: translateX(0);
}

/* Desktop Overrides */
@media (min-width: 768px) {
  .app-sidebar-drawer {
    width: var(--sidebar-desktop-width);
    overflow: visible; /* Allow flyouts */
  }
}

/* Header */
.app-sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sidebar-bg);
  z-index: 10;
}

.app-sidebar-logo {
  width: 32px;
  height: 32px;
  background: #2563eb;
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.app-sidebar-brand-title {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

/* Panels Container */
.sidebar-panels-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden; /* For mobile drill-down stack */
  background: var(--sidebar-bg);
}

@media (min-width: 768px) {
  .sidebar-panels-wrapper {
    overflow: visible; /* Allow desktop flyouts to pop right */
  }
}

/* Individual Panel */
.sidebar-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--sidebar-bg);
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
}

/* Mobile Transition States */
.sidebar-panel.is-active-mobile {
  transform: translateX(0);
  z-index: 2;
}
.sidebar-panel.is-prev-mobile {
  transform: translateX(-30%);
  opacity: 0.5;
  z-index: 1;
}
.sidebar-panel.is-next-mobile {
  transform: translateX(100%);
  z-index: 3;
}

/* Desktop Transition States (Flyouts) */
@media (min-width: 768px) {
  .sidebar-panel.is-active-mobile,
  .sidebar-panel.is-prev-mobile,
  .sidebar-panel.is-next-mobile {
    transform: none; /* Disable mobile horizontal sliding */
    opacity: 1;
  }

  .sidebar-panel[data-level="1"] {
    position: relative;
    z-index: 30;
    box-shadow: 1px 0 0 var(--sidebar-border);
  }

  .sidebar-panel[data-level="2"],
  .sidebar-panel[data-level="3"] {
    position: absolute;
    left: 100%;
    width: var(--sidebar-desktop-width);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    border-left: 1px solid var(--sidebar-border);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
  }
  
  .sidebar-panel[data-level="3"] {
    left: calc(100% + var(--sidebar-desktop-width));
    z-index: 10;
  }

  .sidebar-panel.is-desktop-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }
}

/* Panel Header (Mobile Back Button) */
.panel-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--sidebar-border);
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 5;
}

.panel-header:active {
  background: #f1f5f9;
}

@media (min-width: 768px) {
  .panel-header {
    display: none; /* Hide back buttons on desktop flyouts */
  }
}

.panel-header-icon {
  margin-right: 12px;
  color: var(--sidebar-text-muted);
}
.panel-header-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
}
.panel-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-text);
}

/* Tree Item Lists */
.tree-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.tree-item:hover,
.tree-item.is-selected {
  background: var(--sidebar-hover-bg);
}

.tree-item-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0; /* for text truncation */
}

/* Target Exam Logo (Level 3) */
.tree-item-logo {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.tree-item-icon {
  color: var(--sidebar-text-muted);
  display: flex;
  flex-shrink: 0;
}

.tree-item-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item-chevron {
  color: #cbd5e1;
  display: flex;
  transition: transform 0.2s;
}

.tree-item:hover .tree-item-chevron,
.tree-item.is-selected .tree-item-chevron {
  color: #64748b;
}

/* State Loading/Empty */
.sidebar-message {
  padding: 32px 20px;
  text-align: center;
  color: var(--sidebar-text-muted);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Level 3 Target Exams Grid Styles (App Theme & Full Text Visibility)
   ========================================================================== */

.sidebar-panel-level-3 {
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

/* Theme Back Button Header (Mobile) */
.panel-header-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px 4px 16px;
  color: #475569;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.panel-header-back:hover {
  color: #0f172a;
}

@media (min-width: 768px) {
  .panel-header-back {
    display: none; /* Hide back button on desktop side-by-side flyout */
  }
}

.panel-header-back-icon {
  display: flex;
  align-items: center;
}
.panel-header-back-icon svg {
  width: 18px;
  height: 18px;
  stroke: #475569;
  stroke-width: 2px;
}

.panel-header-back-text {
  color: #475569;
  font-size: 14px;
  font-weight: 600;
}

/* Subcategory Heading (App theme dark slate black) */
.level3-subcat-heading {
  margin: 6px 16px 14px 16px;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

/* Target Exams 3-Column Grid */
.target-exams-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 14px 20px 14px;
  overflow-y: auto;
}

/* Exam Card */
.exam-grid-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 6px 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  min-height: 112px;
}

.exam-grid-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.exam-grid-card:active {
  transform: translateY(0);
  background: #f8fafc;
}

/* Exam Card Logo Image - Bigger container */
.exam-card-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: contain;
  margin-bottom: 8px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border: 1px solid #f1f5f9;
  flex-shrink: 0;
}

/* Exam Card Logo Fallback Badge - Bigger container */
.exam-card-logo-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

/* Exam Card Title - Full length text visible without truncation cutoffs */
.exam-card-title {
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  word-break: normal;
  overflow: visible;
}

/* Desktop Flyout Width for Level 3 */
@media (min-width: 768px) {
  .sidebar-panel[data-level="3"] {
    width: 340px;
    left: calc(100% + var(--sidebar-desktop-width));
  }
}


