/**
 * SimpleMoney Platform - Layout System
 * Responsive Grid and Container Layout
 */

/* =================== LAYOUT CONTAINER =================== */

.layout-container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "navbar navbar navbar"
    "sidebar main-content right-sidebar"
    "footer footer footer";

  min-height: 100vh;
  margin-top: 60px; /* Top navbar height */
  gap: 0;
}

/* =================== NAVBAR =================== */

.navbar {
  grid-area: navbar;
  height: 60px;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* =================== SIDEBAR =================== */

.sidebar {
  grid-area: sidebar;
  width: 250px;
  padding: 1.5rem 1rem;
  background: var(--bg-secondary);
  overflow-y: auto;
  border-right: 1px solid var(--card-border);
  transition: width var(--transition);
}

.sidebar-nav {
  list-style: none;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: all var(--transition);
  position: relative;
}

.nav-link:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--accent-purple);
  color: white;
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 70%;
  background: var(--accent-gold);
  border-radius: 0 2px 2px 0;
}

.nav-divider {
  height: 1px;
  background: var(--card-border);
  margin: 1rem 0;
}

/* =================== SITE NAV MENU (lightweight) ===================
   For focused single-page views (game pages) that don't use the full
   dashboard .sidebar system above — just "how do I get around the site"
   links, shown inline on desktop and in a slide-in drawer on mobile.
   Wired up by assets/js/layout.js. Distinct class names from .nav-link
   above (and from Bootstrap's own .nav-link) so the two systems and the
   navbar's Bootstrap components never collide. */

.site-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.site-nav-link:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
}

.site-nav-link.active {
  background: var(--accent-purple);
  color: white;
}

.menu-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1.1rem;
}

.menu-toggle-btn:hover {
  background: var(--glass-bg);
}

.site-menu-drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  padding: 5rem 1rem 1.5rem;
  background: var(--bg-secondary);
  border-right: 1px solid var(--card-border);
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
  z-index: 1050;
  transition: left var(--transition);
  overflow-y: auto;
}

.site-menu-drawer.active {
  left: 0;
}

.site-menu-drawer .site-nav-link {
  display: block;
  padding: 0.85rem 1rem;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

@media (max-width: 768px) {
  .site-nav-links {
    display: none;
  }

  .menu-toggle-btn {
    display: flex;
  }
}

/* =================== MAIN CONTENT =================== */

.main-content {
  grid-area: main-content;
  flex: 1;
  padding: 2rem;
  padding-top: 70px;
  padding-bottom: 20px;
  background: var(--bg-primary);
  overflow-y: auto;
}

.game-area {
  width: 100%;
  height: 100%;
}

/* =================== RIGHT SIDEBAR =================== */

.right-sidebar {
  grid-area: right-sidebar;
  width: 300px;
  padding: 1.5rem 1rem;
  background: var(--bg-secondary);
  overflow-y: auto;
  border-left: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
}

#widgetsContainer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.widget {
  animation: slideInRight 0.5s ease-out;
}

/* =================== FOOTER =================== */

footer {
  grid-area: footer;
  background: var(--bg-secondary);
  border-top: 1px solid var(--card-border);
}

/* =================== RESPONSIVE DESIGN =================== */

/* Tablet (1024px and below) */
@media (max-width: 1024px) {
  .layout-container {
    grid-template-columns: 60px 1fr auto;
  }

  .sidebar {
    width: 60px;
    padding: 1rem 0.5rem;
  }

  .nav-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
  }

  .nav-label {
    display: none;
  }

  .right-sidebar {
    width: 250px;
  }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
  .layout-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "navbar"
      "main-content"
      "footer";
  }

  .sidebar {
    position: fixed;
    left: -250px;
    top: 60px;
    height: calc(100vh - 60px);
    width: 250px;
    z-index: 999;
    transition: left var(--transition);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
  }

  .sidebar.active {
    left: 0;
  }

  /* Tap-outside-to-close backdrop for the mobile nav drawer (element is
     created in assets/js/app.js — this file previously had no rules for
     it, so it had no size/position and could never intercept a tap). */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity var(--transition);
  }

  .mobile-overlay.active {
    display: block;
    opacity: 1;
  }

  .right-sidebar {
    display: none;
  }

  .main-content {
    padding: 1rem;
  }

  .navbar-nav {
    gap: 0.5rem !important;
  }

  .search-container {
    display: none !important;
  }
}

/* Extra Small (480px and below) */
@media (max-width: 480px) {
  .main-content {
    padding: 0.5rem;
  }

  .navbar {
    padding: 0.25rem 0.5rem;
  }

  .navbar-brand {
    font-size: 1.2rem;
  }
}

/* =================== SCROLLBAR STYLING =================== */

.sidebar::-webkit-scrollbar,
.right-sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.right-sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.right-sidebar::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
  background: var(--card-bg);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.right-sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =================== GRID UTILITIES =================== */

.container-fluid {
  max-width: 100%;
}

.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.grid-auto-fill {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* =================== FLEX UTILITIES =================== */

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.gap-5 { gap: 2rem; }

/**
 * SimpleMoney Layout & Responsive Grid
 */

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding-top: 70px;
  padding-bottom: 20px;
}

.container-fluid {
  padding-left: 1rem;
  padding-right: 1rem;
}

.navbar {
  z-index: 1030;
}

.fixed-top {
  top: 0;
  position: fixed;
  width: 100%;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.col {
  display: flex;
  flex-direction: column;
}

.d-flex {
  display: flex;
}

.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.gap-2 { gap: 1rem; }

.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.me-2 { margin-right: 1rem; }
.me-3 { margin-right: 1.5rem; }
.ms-2 { margin-left: 1rem; }
.ms-auto { margin-left: auto; }

.text-center { text-align: center; }
/* Was #64748B (the darker --gray token, meant for borders/placeholders) —
   too low-contrast for actual body copy on the dark theme (How to Play list,
   leaderboard rows, FUN Rewards card all inherit this). --gray-light is the
   token theme.css already defines for readable secondary text. */
.text-muted { color: var(--gray-light, #CBD5E1); }
.text-warning { color: #FFD700; }
.text-success { color: #10B981; }
.text-danger { color: #EF4444; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.small { font-size: 0.875rem; }
.w-100 { width: 100%; }

.d-none { display: none; }
.d-block { display: block; }
.d-md-none { display: none; }
.d-lg-flex { display: flex; }

@media (max-width: 768px) {
  .d-md-none { display: block !important; }
  .d-md-block { display: none !important; }
  .d-lg-flex { display: none !important; }
  
  .row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .row {
    gap: 1rem;
  }
}