:root {
  --bg-deep: #121221;
  --bg-panel: #1a1a2e;
  --accent: #FFCD30;
  --accent-glow: rgba(255, 205, 48, 0.4);
  --text-main: #e0e0e0;
  --text-dim: rgba(224, 224, 224, 0.4);
  --sidebar-width: 240px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Montserrat', sans-serif;
  display: flex;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 40px;
}

.logo-section img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.logo-text {
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 2px;
  color: #fff;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* ─── Sidebar Collapse Logic (PC & Shared) ─── */
.sidebar.collapsed {
  width: 84px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span {
  opacity: 0;
  visibility: hidden;
  width: 0;
  margin: 0;
  display: none; /* Ensure no layout space taken */
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
  width: 52px;
  margin: 0 auto 8px;
  gap: 0;
}

.sidebar.collapsed .logo-section {
  padding: 0 0 40px;
  justify-content: center;
  gap: 0;
}

/* ─── Nav Items (Tabs) ─── */
.nav-item {
  position: relative;
  width: 100%;
  height: 52px;
  border: none;
  background: transparent;
  border-radius: 14px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  overflow: hidden;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}

.nav-item.active {
  background: rgba(255, 205, 48, 0.1);
  color: var(--accent);
}

.nav-item span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Ripple Effect */
.nav-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  transform: scale(0.6);
  transition: none;
}
.nav-item:active::after {
  opacity: 0.15;
  transform: scale(1);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ─── Master Icon Styles ─── */
.icon-box {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── 1. Focus Icon (Session) ─── */
.icon-session {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-session::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  background: currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
}
.nav-item:hover .icon-session {
  transform: scale(1.1);
}
.nav-item:hover .icon-session::before {
  box-shadow: 0 0 8px 2px var(--accent-glow);
  width: 6px; height: 6px;
}
.nav-item.active .icon-session::before {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ─── 2. Analytics Icon (Bars) ─── */
.icon-analytics {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}
.icon-analytics div {
  width: 3px;
  background: currentColor;
  border-radius: 1px;
  transition: height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-analytics .b1 { height: 60%; }
.icon-analytics .b2 { height: 100%; }
.icon-analytics .b3 { height: 40%; }

.nav-item:hover .icon-analytics .b1 { height: 100%; }
.nav-item:hover .icon-analytics .b2 { height: 50%; }
.nav-item:hover .icon-analytics .b3 { height: 80%; }

/* ─── 3. Benchmark Icon (Rank/Stairs) ─── */
.icon-benchmark {
  position: relative;
  width: 16px;
  height: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.icon-benchmark div {
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: width 0.4s ease, transform 0.4s ease;
}
.icon-benchmark .l1 { width: 100%; }
.icon-benchmark .l2 { width: 70%; }
.icon-benchmark .l3 { width: 40%; }

.nav-item:hover .icon-benchmark .l1 { width: 40%; transform: translateX(12px); }
.nav-item:hover .icon-benchmark .l2 { width: 100%; transform: translateX(0); }
.nav-item:hover .icon-benchmark .l3 { width: 70%; transform: translateX(6px); }

/* ─── 4. Settings Icon (Sliders) ─── */
.icon-settings {
  width: 18px;
  height: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.icon-settings .row {
  position: relative;
  width: 100%;
  height: 2px;
  background: rgba(224, 224, 224, 0.2);
  border-radius: 1px;
}
.nav-item.active .icon-settings .row { background: rgba(255, 205, 48, 0.2); }

.icon-settings .dot {
  position: absolute;
  top: 50%;
  width: 5px; height: 5px;
  background: currentColor;
  border-radius: 50%;
  transform: translateY(-50%);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 5px rgba(0,0,0,0.2);
}
.icon-settings .d1 { left: 20%; }
.icon-settings .d2 { left: 70%; }
.icon-settings .d3 { left: 40%; }

.nav-item:hover .icon-settings .d1 { left: 70%; }
.nav-item:hover .icon-settings .d2 { left: 10%; }
.nav-item:hover .icon-settings .d3 { left: 80%; }

.nav-item.active .icon-settings .dot {
  box-shadow: 0 0 6px 1px var(--accent-glow);
}

/* ─── Content Area ─── */
.main-content {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative; 
  /* Fix: Ensure scrolling is always possible when content exceeds height */
  min-height: 0; 
}

.tab-content {
  width: 100%;
}

/* Premium Scrollbar Styling for Main Content */
.main-content::-webkit-scrollbar {
  width: 6px;
}

.main-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.01);
}

.main-content::-webkit-scrollbar-thumb {
  background: rgba(255, 205, 48, 0.1);
  border-radius: 10px;
  border: 2px solid var(--bg-deep); /* Gap effect */
}

.main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 205, 48, 0.3);
}

.placeholder-card {
  width: 100%;
  height: 200px;
  background: var(--bg-panel);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.1);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* ─── Global Date Input Styling (Shared across tabs & modals) ─── */
.date-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.date-input-wrapper i, 
.date-input-wrapper svg {
  position: absolute;
  left: 15px !important; 
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.4) !important;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  z-index: 2;
}

/* Base styles for centered date picker variant */
.date-input-centered-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.date-input-centered-wrapper i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  z-index: 2;
}

.date-input-centered-wrapper svg {
  display: block;
  width: 14px;
  height: 14px;
}


.date-input-small,
#analytics-date-picker,
#graph-date-picker,
#logbook-date-filter {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  font-family: 'Montserrat', sans-serif !important;
  font-size: 11px !important;
  padding: 8px 12px 8px 50px !important; /* Uniform air */
  border-radius: 10px !important;
  outline: none !important;
  cursor: pointer !important;
  transition: all 0.3s !important;
  width: 195px !important; /* Increased width to accommodate air and long text */
  font-weight: 700 !important;
}

.date-input-small:hover {
  border-color: rgba(255, 255, 255, 0.2) !important;
  background: rgba(255, 255, 255, 0.08) !important;
}


/* ─── Grid Feedback & Animations ─── */
.grid-cell.cell-correct {
  background: rgba(34, 197, 94, 0.4) !important;
  box-shadow: inset 0 0 20px rgba(34, 197, 94, 0.4);
  transition: background 0.1s ease;
}

.grid-cell.cell-wrong {
  background: rgba(239, 68, 68, 0.4) !important;
  box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.4);
  transition: background 0.1s ease;
}


.key-cap.press-active {
  background: var(--accent);
  color: #000;
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 0 15px var(--accent-glow);
}

/* Auto-Hide Cursor */
body.session-running.hide-cursor-active .grid-stage {
  cursor: none !important;
}

/* ─── Tablet & Mobile Adaptivity ─── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 70px; /* Narrow width for mobile by default */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 9999;
    width: var(--sidebar-width);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    background: var(--bg-panel);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* When expanded on mobile, take full screen */
  .sidebar:not(.collapsed) {
    width: 100% !important;
    background: var(--bg-deep); /* Darker background for full-screen menu */
  }

  .sidebar.collapsed {
    width: 70px !important;
    padding: 24px 0; /* Remove horizontal padding to help centering */
  }

  .sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0 !important;
    margin: 0 auto 8px !important;
    width: 100%;
  }

  .sidebar.collapsed .logo-section {
    justify-content: center;
    padding: 0 0 30px !important;
    margin: 0;
  }

  .sidebar.collapsed .logo-section img {
    margin: 0;
  }

  /* Open sidebar: vertical stack, aligned to one axis */
  .sidebar:not(.collapsed) .nav-menu {
    flex-direction: column;
    align-items: center;       /* Center the nav block */
    gap: 4px;
    flex: 0 0 auto;
    width: 100%;
  }

  .sidebar:not(.collapsed) .nav-item {
    width: 240px;              /* Fixed width — all items on one line */
    height: 56px;
    justify-content: flex-start;
    padding: 0 20px;
    gap: 16px;
    border-bottom: none;
    border-radius: 14px;
    font-size: 13px;
  }

  .sidebar:not(.collapsed) .logo-section {
    width: 240px;
    align-self: center;
    justify-content: flex-start;
    padding: 40px 20px 20px;
  }

  /* Progress bar: compact, not full-width */
  .sidebar:not(.collapsed) .sidebar-progress-box {
    width: 240px;
    align-self: center;
  }

  .main-content {
    margin-left: 70px;
    padding: 20px;
    width: calc(100% - 70px);
    flex: none; /* Break flex layout on mobile since sidebar is fixed */
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 16px;
    margin-left: 60px;
    width: calc(100% - 60px);
  }
  
  .sidebar.collapsed {
    width: 60px !important;
    padding: 20px 0;
  }
  
  .sidebar.collapsed .nav-item {
    width: 100%;
  }

  .sidebar:not(.collapsed) .nav-item span {
    font-size: 14px;
    letter-spacing: 1px;
  }
}

/* ─── Sidebar Bell Icon (Notifications) ─── */
.sidebar-notif-btn {
  display: none; /* Hidden by default — shown only at ≤315px */
  width: 100%;
  height: 52px;
  border: none;
  background: transparent;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding: 0;
  margin-bottom: 4px;
}

.sidebar-notif-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}

.sidebar-notif-btn .icon-box {
  position: relative;
}

/* Red dot indicator for unread notifications */
.notif-bell-dot {
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  background: #ff4d4d;
  border-radius: 50%;
  border: 1px solid var(--bg-panel);
}

.notif-bell-dot.has-notifs {
  display: block;
}

/* ─── Show bell at ≤315px, hide when sidebar is open ─── */
@media (max-width: 315px) {
  .sidebar-notif-btn {
    display: none !important;
  }
}

/* ─── Hide feedback widget when sidebar is open on mobile (≤1024px) ─── */
@media (max-width: 1024px) {
  .sidebar:not(.collapsed) ~ * .chat-trigger,
  .sidebar:not(.collapsed) ~ * .feedback-window {
    display: none !important;
    pointer-events: none !important;
  }

  /* Feedback widget is appended to body, not inside main — target directly */
  body:has(.sidebar:not(.collapsed)) .chat-trigger,
  body:has(.sidebar:not(.collapsed)) .feedback-window {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s !important;
  }
}

/* Hide date filter placeholder on screens up to 769px */
@media (max-width: 769px) {
  #logbook-date-filter::placeholder {
    color: transparent !important;
    opacity: 0 !important;
  }
}
