﻿/* ==========================================================================
   Sabah Diabolo — Back-Office Shell (AdminShell.cs)
   --------------------------------------------------------------------------
   ONLY the chrome that is unique to the office workspace lives here.
   The sidebar, drawer, nav, layout wrapper and all components now come from
   theme.css + app.css — the same ones the public/contingent/judge pages use —
   so the two shells cannot silently drift apart again.

   Unique to admin = the Tier-2 tournament workspace bar (Rule R1), the master
   results switch, the tournament menu dropdown, and the sidebar user footer.
   ========================================================================== */

/* --- Tier 2: tournament workspace bar ------------------------------------ */
/* Sticky rather than fixed: the old `position: fixed; left: 220px` baked the
   sidebar width into the header and broke at every viewport below it. */
.sd-top-header {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: 60px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
}

.sd-top-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.sd-top-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sd-top-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.sd-top-actions {
  position: relative; /* anchors .sd-tourn-dropdown */
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 1100;
}

/* --- Master public-results switch ---------------------------------------- */
.sd-master-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sd-master-switch.off {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.sd-master-switch.on {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

/* --- Tournament menu & Right Slide-in Drawer ----------------------------- */
.sd-tourn-menu-btn {
  background: var(--bg-surface-1);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.sd-tourn-menu-btn:hover {
  background: var(--bg-surface-3);
  border-color: var(--border-subtle);
  color: var(--primary);
}

.sd-tourn-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-normal);
}

.sd-tourn-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sd-tourn-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--bg-surface-1);
  border-left: 1px solid var(--border-medium);
  z-index: 9999;
  transform: translateX(100%);
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.5);
}

.sd-tourn-drawer.open {
  transform: translateX(0);
}

.sd-tourn-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 2rem 0;
}

.sd-tourn-drawer-body::-webkit-scrollbar {
  width: 5px;
}
.sd-tourn-drawer-body::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

/* --- Sidebar footer (admin only; the public shell has no signed-in footer) - */
.sd-sidebar-user {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
}

.sd-sidebar-user .u-name {
  display: block;
  font-weight: 600;
  color: var(--text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Body container ------------------------------------------------------- */
.sd-content-container {
  flex: 1;
  padding: 20px;
  min-width: 0;
}

/* --- Mobile & Collapsed Sidebar (<=1601px) -------------------------------- */
/* Matches theme.css's 1601px breakpoint. The sidebar/drawer behaviour itself is
   inherited from theme.css; only the Tier-2 bar needs reflowing here. */
.sd-tourn-btn-collapsed {
  display: inline-flex;
}

.sd-tourn-btn-expanded {
  display: inline-flex;
}

@media (max-width: 1601px) {
  /* When sidebar is collapsed (<=1601px): show the 1st button in top mobile header, hide the 2nd button */
  .sd-tourn-btn-collapsed {
    display: inline-flex !important;
  }
  .sd-tourn-btn-expanded {
    display: none !important;
  }

  /* .mobile-header is already sticky at top:0; workspace bar reflows cleanly. */
  .sd-top-header {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
  }

  .sd-top-actions {
    display: none !important;
  }

  .sd-content-container { padding: 16px; }
}

@media (min-width: 1602px) {
  /* When sidebar is expanded (>1601px): hide the 1st button (mobile-header is also hidden), show the 2nd button */
  .sd-tourn-btn-collapsed {
    display: none !important;
  }
  .sd-tourn-btn-expanded {
    display: inline-flex !important;
  }
}
