/**
 * Racket365 - Sports Management Platform
 * Copyright (c) 2026 iGEN Service LLC. All rights reserved.
 *
 * This source code is proprietary and confidential.
 * Unauthorized copying, modification, or distribution is strictly prohibited.
 */
/* ─── APP LAYOUT ──────────────────────────────────────────────────────────── */

/* ── App Shell ── */
#app {
  min-height: 100vh;
}

/* ── Auth Layout (login/register) ── */
.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--color-bg);
}

@media (min-width: 768px) {
  .auth-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.auth-brand {
  display: none;
  background: var(--color-sidebar);
  padding: var(--space-12);
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(16,185,129,0.15) 0%, transparent 70%);
}

@media (min-width: 768px) {
  .auth-brand { display: flex; }
}

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--clr-white);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  position: relative;
  z-index: 1;
}

.auth-brand-icon {
  width: 40px;
  height: 40px;
  background: var(--clr-primary-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.auth-brand-tagline {
  position: relative;
  z-index: 1;
}

.auth-brand-tagline h2 {
  font-size: var(--text-3xl);
  color: var(--clr-white);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-4);
}

.auth-brand-tagline p {
  color: var(--clr-gray-400);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.auth-brand-stats {
  display: flex;
  gap: var(--space-8);
  position: relative;
  z-index: 1;
}

.auth-brand-stat strong {
  display: block;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--clr-primary-400);
}

.auth-brand-stat span {
  font-size: var(--text-sm);
  color: var(--clr-gray-400);
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
}

.auth-form-box {
  width: 100%;
  max-width: 420px;
}

/* ── App Layout (authenticated) ── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--color-sidebar);
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--duration-slow) var(--ease-in-out),
              width var(--duration-slow) var(--ease-in-out);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--clr-primary-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand {
  font-weight: var(--font-bold);
  font-size: var(--text-base);
  color: var(--clr-white);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand span {
  color: var(--clr-primary-400);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4) var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-section {
  margin-bottom: var(--space-6);
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--clr-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--clr-gray-400);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);
  white-space: nowrap;
  overflow: hidden;
  min-height: 40px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--clr-white);
  transform: translateX(2px);
}

.nav-item.active {
  background: rgba(16,185,129,0.18);
  color: var(--clr-primary-300);           /* lighter green — better on dark bg */
  border-left: 2px solid var(--clr-primary-400);
  padding-left: calc(var(--space-3) - 2px);
}

.nav-item.active .nav-icon {
  color: var(--clr-primary-300);
}

.nav-item:focus-visible {
  outline: 2px solid var(--clr-primary-400);
  outline-offset: -2px;
}

.nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--clr-rose-500);
  color: white;
  font-size: 10px;
  font-weight: var(--font-bold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.sidebar-user:hover { background: rgba(255,255,255,0.07); }

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--clr-primary-600);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.sidebar-user-info {
  overflow: hidden;
  flex: 1;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--clr-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--clr-gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: 30;
  gap: var(--space-4);
  transition: left var(--duration-slow) var(--ease-in-out);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
}

.topbar-page-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--clr-gray-600);              /* darker than muted for better visibility */
  transition: background var(--duration-fast), color var(--duration-fast);
  position: relative;
  border: none;
  background: none;
  cursor: pointer;
}

.topbar-btn:hover  { background: var(--clr-gray-100); color: var(--color-text); }
.topbar-btn:active { background: var(--clr-gray-200); color: var(--color-text); }

.topbar-notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--clr-rose-500);
  border: 2px solid var(--color-bg-elevated);
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: var(--space-8) var(--space-6);
  transition: margin-left var(--duration-slow) var(--ease-in-out);
}

.page-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
}

.page-header-left p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

.page-header-right {
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ── Stat Cards Row ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

/* ── Content Grid ── */
.content-grid-2 {
  display: grid;
  /* minmax(0, …) lets columns shrink below their content's width on phones. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .content-grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.content-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
}

/* ── Mobile sidebar overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 35;
}

/* ── Mobile responsive ── */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .topbar {
    left: 0;
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-5) var(--space-4);
  }

  .topbar-user-name {
    display: none !important;
  }
}

/* ── Mobile menu toggle ── */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-text);
  cursor: pointer;
  border: none;
  background: none;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.menu-toggle:hover  { background: var(--clr-gray-100); }
.menu-toggle:active { background: var(--clr-gray-200); }

@media (max-width: 767px) {
  .menu-toggle { display: flex; }
}

/* ── Org Context Banner (super admin impersonation) ── */
/* ── Org Context Banner ── */
.org-context-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 var(--space-3) var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
}

.org-context-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
}

.org-context-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(148, 163, 184, 0.9);
  line-height: 1;
  margin-bottom: 2px;
}

.org-context-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--clr-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.org-context-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.org-context-toggle {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08);
  color: rgba(148, 163, 184, 0.9);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.org-context-toggle:hover {
  background: rgba(255,255,255,0.15);
  color: var(--clr-white);
}

.org-context-exit {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08);
  color: rgba(148, 163, 184, 0.9);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.org-context-exit:hover {
  background: rgba(239, 68, 68, 0.3);
  color: var(--clr-white);
}

/* ── Org Switcher Dropdown ── */
.org-switcher-dropdown {
  display: none;
  margin: 0 var(--space-3) var(--space-3);
  padding: var(--space-2);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
}

.org-switcher-dropdown.open {
  display: block;
  max-height: 300px;
  overflow-y: auto;
}

.org-switcher-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(148, 163, 184, 0.7);
  padding: var(--space-1) var(--space-2) var(--space-2);
}

.org-switcher-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
  margin-bottom: 1px;
}

.org-switcher-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.org-switcher-option.active {
  background: rgba(59, 130, 246, 0.2);
}

.org-switcher-dot {
  flex-shrink: 0;
  font-size: 8px;
  width: 16px;
  text-align: center;
  color: rgba(148, 163, 184, 0.6);
}

.org-switcher-option.active .org-switcher-dot {
  color: rgba(96, 165, 250, 1);
}

.org-switcher-name {
  flex: 1;
  font-size: var(--text-sm);
  color: rgba(226, 232, 240, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.org-switcher-option.active .org-switcher-name {
  color: var(--clr-white);
  font-weight: var(--font-medium);
}

.org-switcher-role {
  flex-shrink: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: rgba(148, 163, 184, 0.6);
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
}

/* ── App Footer (copyright) ── */
.app-footer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-8) var(--space-4) var(--space-4);
  opacity: 0.7;
}

.auth-layout .app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-3);
  background: transparent;
}
