/* ============================================================
   layout.css  -  Anchor HQ  |  Stardew Valley Theme
   App shell layout: sidebar, main content, responsive
   ============================================================ */

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ─── App Layout Shell ─── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}


/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w, 240px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  /* Dark wooden panel background with grain */
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 3px,
      rgba(139, 90, 43, 0.03) 3px,
      rgba(139, 90, 43, 0.03) 4px
    ),
    linear-gradient(
      180deg,
      var(--wood-dark, #3a2415) 0%,
      var(--panel, #1e1914) 25%,
      var(--panel, #1e1914) 100%
    );
  border-right: 2px solid var(--wood, #6b4423);
  z-index: 100;
  transition: width var(--duration-slow, 320ms) var(--ease);
  overflow: hidden;
}

/* ─── Sidebar Brand (logo + title) ─── */
.sidebar-brand {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--wood, #6b4423);
  flex-shrink: 0;
  position: relative;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--gold, #daa520), var(--gold-bright, #f0c040));
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  /* Pixel art border */
  border: 2px solid var(--wood, #6b4423);
  box-shadow: var(--shadow-glow);
  image-rendering: pixelated;
}

.sidebar-brand h1 {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold-bright, #f0c040);
  letter-spacing: 0.04em;
  text-shadow: 1px 1px 0 var(--wood-dark, #3a2415);
  line-height: 1.3;
}

.sidebar-brand small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.6rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ─── Workspace Tabs ─── */
.workspace-tabs {
  display: flex;
  gap: 0;
  padding: 0 4px;
  border-bottom: 2px solid var(--wood, #6b4423);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.workspace-tabs::-webkit-scrollbar {
  display: none;
}

.workspace-tab {
  padding: 8px 8px 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration, 180ms) var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  letter-spacing: 0.01em;
}

.workspace-tab:hover {
  color: var(--text);
}

.workspace-tab.active {
  color: var(--gold, #daa520);
}

.workspace-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 4px;
  right: 4px;
  height: 2px;
  background: var(--gold, #daa520);
  border-radius: 1px 1px 0 0;
}

/* ─── Sidebar Navigation ─── */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  transition: all var(--duration, 180ms) var(--ease);
  border: 1px solid transparent;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: var(--earth-soft, rgba(92, 74, 50, 0.3));
  color: var(--text);
  border-color: var(--border);
}

.nav-item.active {
  background: var(--gold-soft, rgba(218, 165, 32, 0.15));
  color: var(--gold-bright, #f0c040);
  border-color: var(--border-accent);
  /* Golden left accent bar */
  box-shadow: inset 3px 0 0 var(--gold, #daa520);
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  image-rendering: pixelated;
}

/* ─── Nav Badge (pixel-styled notification count) ─── */
.nav-badge {
  margin-left: auto;
  background: var(--gold, #daa520);
  color: var(--wood-dark, #3a2415);
  font-family: var(--font-pixel);
  font-size: 0.45rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 2px;
  min-width: 18px;
  text-align: center;
  /* Pixel border look */
  border: 1px solid var(--gold-bright, #f0c040);
  box-shadow: 1px 1px 0 var(--wood-dark, #3a2415);
  line-height: 1;
}

.nav-badge.red {
  background: var(--red, #e04040);
  color: #fff;
  border-color: #ff6060;
}

.nav-badge.green {
  background: var(--green, #6cbf4a);
  color: var(--wood-dark, #3a2415);
  border-color: #8dd868;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 2px solid var(--wood, #6b4423);
  font-size: 0.68rem;
  color: var(--muted);
  flex-shrink: 0;
}

.sidebar-footer .refresh-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-footer .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: var(--green, #6cbf4a);
  animation: pulse 2s ease infinite;
  /* Square pixel dot */
  image-rendering: pixelated;
}

.sidebar-footer .theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  cursor: pointer;
  transition: all var(--duration, 180ms) var(--ease);
}

.sidebar-footer .theme-toggle:hover {
  background: var(--earth-soft);
  color: var(--text);
  border-color: var(--border-accent);
}


/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  background: var(--bg);
}

/* ─── Sections ─── */
.section {
  display: none;
  padding: 24px 28px 40px;
  animation: fadeIn 280ms var(--ease);
}

.section.active {
  display: block;
}

/* ─── Section Header ─── */
.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: 0.03em;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

.section-header p {
  font-family: var(--font-body);
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
  line-height: 1.4;
}


/* ============================================================
   Desktop (>= 1025px) - Full sidebar visible
   ============================================================ */
@media (min-width: 1025px) {
  .sidebar {
    width: var(--sidebar-w, 240px);
  }

  .mobile-topbar {
    display: none !important;
  }

  .mobile-nav {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}


/* ============================================================
   Tablet (641px - 1024px) - Collapsed icon sidebar, expand on hover
   ============================================================ */
@media (min-width: 641px) and (max-width: 1024px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }

  .sidebar:hover {
    width: var(--sidebar-w, 240px);
    box-shadow: var(--shadow);
  }

  /* Hide text when collapsed */
  .sidebar-brand h1,
  .sidebar-brand small,
  .workspace-tabs,
  .nav-item span,
  .nav-badge,
  .sidebar-footer .refresh-info span,
  .sidebar-footer .theme-toggle span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--duration, 180ms) var(--ease);
  }

  .sidebar:hover .sidebar-brand h1,
  .sidebar:hover .sidebar-brand small,
  .sidebar:hover .workspace-tabs,
  .sidebar:hover .nav-item span,
  .sidebar:hover .nav-badge,
  .sidebar:hover .sidebar-footer .refresh-info span,
  .sidebar:hover .sidebar-footer .theme-toggle span {
    opacity: 1;
    width: auto;
  }

  /* Center icons when collapsed */
  .nav-item {
    justify-content: center;
    padding: 9px;
  }

  .sidebar:hover .nav-item {
    justify-content: flex-start;
    padding: 9px 12px;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 14px 12px;
  }

  .sidebar:hover .sidebar-brand {
    justify-content: flex-start;
    padding: 18px 16px 14px;
  }

  .mobile-topbar {
    display: none !important;
  }

  .mobile-nav {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}


/* ============================================================
   Mobile (<= 640px) - Hidden sidebar, hamburger, bottom nav
   ============================================================ */
@media (max-width: 640px) {
  /* Hide sidebar by default on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w, 240px);
    transform: translateX(-100%);
    transition: transform var(--duration-slow, 320ms) var(--ease);
    z-index: 200;
    box-shadow: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  /* Sidebar Overlay */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-slow, 320ms) var(--ease);
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile Top Bar */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 150;
    height: var(--topbar-h, 52px);
    padding: 0 16px;
    background: var(--panel, #1e1914);
    border-bottom: 2px solid var(--wood, #6b4423);
    flex-shrink: 0;
  }

  .mobile-topbar .hamburger-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 4px);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--duration, 180ms) var(--ease);
    flex-shrink: 0;
  }

  .mobile-topbar .hamburger-btn:hover {
    background: var(--earth-soft);
    color: var(--gold);
    border-color: var(--border-accent);
  }

  .mobile-topbar .page-title {
    flex: 1;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
    color: var(--text-heading);
    letter-spacing: 0.03em;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-topbar .notification-bell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 4px);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    transition: all var(--duration, 180ms) var(--ease);
    flex-shrink: 0;
  }

  .mobile-topbar .notification-bell:hover {
    background: var(--earth-soft);
    color: var(--gold);
  }

  .mobile-topbar .notification-bell .bell-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--red, #e04040);
    border-radius: 0;
    border: 1px solid var(--panel);
    image-rendering: pixelated;
  }

  /* Mobile Bottom Navigation */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--panel, #1e1914);
    border-top: 2px solid var(--wood, #6b4423);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 150;
    height: var(--mobile-nav-h, 60px);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    color: var(--muted);
    font-family: var(--font-pixel);
    font-size: 0.42rem;
    font-weight: 400;
    transition: all 150ms var(--ease);
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    border: none;
    background: none;
  }

  .mobile-nav-item .mnav-icon {
    font-size: 1.1rem;
    image-rendering: pixelated;
  }

  .mobile-nav-item.active {
    color: var(--gold, #daa520);
  }

  .mobile-nav-item:hover {
    color: var(--gold-bright, #f0c040);
    background: var(--earth-soft);
  }

  /* Adjust main content for mobile topbar and bottom nav */
  .app-layout {
    flex-direction: column;
  }

  .main-content {
    padding-bottom: var(--mobile-nav-h, 60px);
  }

  .section {
    padding: 16px 14px 30px;
  }

  .section-header h2 {
    font-size: 0.72rem;
  }
}


/* ============================================================
   Hidden helpers for non-mobile breakpoints
   ============================================================ */
@media (min-width: 641px) {
  .mobile-topbar {
    display: none !important;
  }

  .mobile-nav {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}
