/* ==========================================================================
   Geoje Swimmers - Collapsible Sidebar Navigation Styles
   카테고리별 사이드바 네비게이션: 명부, 훈련일지, 대회기록, 관리자 설정
   ========================================================================== */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 64px;
  --sidebar-bg: #0f172a; /* Slate 900 */
  --sidebar-bg-hover: #1e293b; /* Slate 800 */
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;
  --sidebar-accent: #0284c7;
  --sidebar-accent-light: #38bdf8;
  --sidebar-border: #1e293b;
  --sidebar-transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Body Layout Adjustments for Sidebar ───────────────────────────────── */
body.with-sidebar {
  padding-left: var(--sidebar-width);
  transition: var(--sidebar-transition);
  margin: 0;
}

body.with-sidebar.sidebar-collapsed {
  padding-left: var(--sidebar-collapsed-width);
}

body.with-sidebar .app-container {
  max-width: calc(100vw - var(--sidebar-width) - 48px);
  margin: 0 auto;
  box-sizing: border-box;
}

body.with-sidebar.sidebar-collapsed .app-container {
  max-width: calc(100vw - var(--sidebar-collapsed-width) - 48px);
}

/* ─── Sidebar Container ────────────────────────────────────────────────── */
.gmdc-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
  transition: var(--sidebar-transition);
  overflow: hidden;
  user-select: none;
}

body.with-sidebar.sidebar-collapsed .gmdc-sidebar {
  width: var(--sidebar-collapsed-width);
}

/* ─── Sidebar Header (Logo & Collapse Toggle) ─────────────────────────── */
.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  background: rgba(15, 23, 42, 0.95);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #ffffff;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s;
}

.brand-title {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-accent-light);
}

body.with-sidebar.sidebar-collapsed .sidebar-brand-text {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

.btn-sidebar-collapse {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--sidebar-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-sidebar-collapse:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.btn-sidebar-collapse svg {
  transition: transform 0.28s ease;
}

body.with-sidebar.sidebar-collapsed .btn-sidebar-collapse svg {
  transform: rotate(180deg);
}

/* ─── Sidebar Menu Navigation ─────────────────────────────────────────── */
.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Category Block */
.sidebar-category {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  transition: background 0.15s;
}

.sidebar-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 700;
  transition: all 0.15s;
}

.sidebar-cat-header:hover {
  background: var(--sidebar-bg-hover);
  color: #ffffff;
}

.cat-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

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

.cat-arrow {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  transition: transform 0.2s ease;
}

.sidebar-category.collapsed .cat-arrow {
  transform: rotate(-90deg);
}

/* Category Submenu Items */
.sidebar-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 6px 16px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.sidebar-category.collapsed .sidebar-submenu {
  display: none;
}

.sidebar-item-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}

.sidebar-item-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  transform: translateX(2px);
}

.sidebar-item-link.active {
  background: var(--sidebar-accent);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.sidebar-item-link .item-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

/* Collapsed Sidebar Hover Flyout Tooltip Support */
body.with-sidebar.sidebar-collapsed .cat-title-wrap span:not(.cat-icon),
body.with-sidebar.sidebar-collapsed .cat-arrow,
body.with-sidebar.sidebar-collapsed .sidebar-submenu {
  display: none !important;
}

body.with-sidebar.sidebar-collapsed .sidebar-cat-header {
  justify-content: center;
  padding: 12px 0;
}

/* ─── Sidebar Footer: User Profile & Login ────────────────────────────── */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  background: rgba(15, 23, 42, 0.95);
  font-size: 12px;
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

body.with-sidebar.sidebar-collapsed .sidebar-footer {
  display: none;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 10px;
  border-radius: 8px;
}

.user-info-area {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.user-avatar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.user-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-name-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-display-name {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 10px;
  color: #38bdf8;
  font-weight: 600;
}

.btn-sidebar-login {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  background: #ffffff;
  border: none;
  border-radius: 8px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sidebar-login:hover {
  background: #f1f5f9;
}

.btn-sidebar-logout {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #cbd5e1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-sidebar-logout:hover {
  background: #ef4444;
  color: #ffffff;
}

/* ─── Mobile Sidebar Hamburger Button & Drawer ────────────────────────── */
.btn-mobile-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  margin-right: 4px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ─── Mobile & Tablet Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  body.with-sidebar,
  body.with-sidebar.sidebar-collapsed {
    padding-left: 0 !important;
  }

  .gmdc-sidebar {
    transform: translateX(-100%);
    width: 270px !important;
  }

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

  .btn-mobile-sidebar-toggle {
    display: inline-flex;
  }

  .btn-sidebar-collapse {
    display: none;
  }

  .btn-mobile-sidebar-close {
    display: inline-flex !important;
  }
}

.btn-mobile-sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ─── SPA Embedded Viewport Styles ────────────────────────────────────── */
.spa-shell-container {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.spa-embedded-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #f8fafc;
  display: block;
}

/* ─── Common Sidebar Dialog / Modal Styles ────────────────────────────── */
.sidebar-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.sidebar-modal-box {
  background: #ffffff;
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  color: #1e293b;
  animation: scaleUp 0.2s ease;
}

.sidebar-modal-box h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-modal-box p {
  font-size: 14px;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 16px;
}

.sidebar-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-sidebar-modal-close {
  padding: 8px 18px;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}


/* Nested Tree for 대회결과 > 학생부/성인부 > 접수 분석 · 진행 요약 · 결과 분석 */
.sidebar-tree-group {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-tree-root-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 2px 12px;
  font-size: 12.8px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.sidebar-tree-division {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
}

.sidebar-tree-div-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 2px 10px;
  font-size: 11.8px;
  font-weight: 800;
  color: #38bdf8;
}

.sidebar-tree-div-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
  border-left: 1.5px solid rgba(56, 189, 248, 0.25);
  margin-left: 14px;
}

.sidebar-item-link.is-sub-leaf {
  padding: 6px 10px;
  font-size: 12.2px;
  gap: 7px;
}

.sidebar-item-link.is-sub-leaf .item-icon {
  font-size: 12.5px;
  width: 16px;
}


/* ==========================================================================
   Swimmers Multi-Competition Switcher & Competition List Modal
   ========================================================================== */
.sidebar-comp-switcher {
  background: transparent;
  border: none;
  padding: 4px 6px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  transition: background 0.16s ease;
}
.sidebar-comp-switcher:hover {
  background: rgba(255, 255, 255, 0.08);
}
.brand-caret {
  font-size: 11px;
  opacity: 0.78;
  margin-left: 2px;
}
.sidebar-top-direct-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.sidebar-top-link {
  padding-left: 14px !important;
  font-weight: 700 !important;
}
.sidebar-version-meta {
  margin-top: 8px;
  text-align: center;
  font-size: 10.5px;
  color: rgba(148, 163, 184, 0.75);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.comp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.comp-modal-box {
  width: 100%;
  max-width: 480px !important;
  background: #ffffff;
  border-radius: 20px;
  padding: 22px !important;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
  border: 1px solid #e2e8f0;
}
.comp-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.comp-modal-header h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 900;
  color: #0f172a;
}
.comp-modal-header p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}
.comp-modal-close-x {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.comp-modal-close-x:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.comp-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comp-select-card {
  width: 100%;
  text-align: left;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.16s ease;
  font-family: inherit;
}
.comp-select-card:hover {
  background: #f0f9ff;
  border-color: #7dd3fc;
  transform: translateY(-1px);
}
.comp-select-card.is-current {
  background: #eff6ff;
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}
.comp-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.comp-card-title {
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
}
.comp-current-badge {
  font-size: 11px;
  font-weight: 800;
  background: #0284c7;
  color: #ffffff;
  padding: 3px 9px;
  border-radius: 999px;
}
.comp-open-badge {
  font-size: 11.5px;
  font-weight: 800;
  color: #0284c7;
}
.comp-card-full {
  font-size: 12.5px;
  color: #475569;
  font-weight: 600;
  margin-bottom: 8px;
}
.comp-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}
.comp-team-pill {
  color: #c2410c;
  background: #ffedd5;
  padding: 1px 8px;
  border-radius: 999px;
}
