/* ============================================================
   SEDMS Ribbon — SEcMS color-bold 스타일 (2026-06-01)
   SEcMS TopNavBar 레퍼런스: 3D-Tool / Windows 데스크탑 스타일
   - Row 1 (탭바 30px): Windows 타이틀바 그라디언트
   - Row 2 (리본 58px): #f8f8f8 + 파란 하단 보더
   - 그룹: 양쪽 컬러 보더 + 상단 컬러 라벨 (color-bold)
   - 버튼 활성: 그룹 색상 테두리 + 그라디언트 + 인셋 쉐도우
   ============================================================ */

:root {
  --xr-bg:           #f3f3f3;
  --xr-tabbar-bg:    linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%);
  --xr-tabbar-bd:    #b8b8b8;
  --xr-tab-active:   #cce4ff;
  --xr-tab-hover:    rgba(0,0,0,0.06);
  --xr-tab-text:     #374151;
  --xr-tab-active-bd:#0055cc;
  --xr-ribbon-bg:    #f8f8f8;
  --xr-ribbon-bd:    #b0c4d8;
  --xr-group-bg:     transparent;
  --xr-group-bd:     #d4d8de;
  --xr-group-label:  #ffffff;
  --xr-btn-hover:    rgba(0,0,0,0.05);
  --xr-btn-active:   #cce4ff;
  --xr-btn-text:     #1a1a1a;
  --xr-btn-bd:       transparent;
  --xr-accent:       #2F5BAA;
  --xr-shadow:       0 1px 2px rgba(0,0,0,.04);
  --xr-key-bg:       #2F5BAA;
  --xr-key-text:     #ffffff;
  --grp-color:       #445566;
}

@media (prefers-color-scheme: dark) {
  :root.theme-dark {
    --xr-bg:           #0f172a;
    --xr-tabbar-bg:    #111827;
    --xr-tabbar-bd:    #1f2937;
    --xr-tab-text:     #e5e7eb;
    --xr-tab-active:   #1f2937;
    --xr-ribbon-bg:    #111827;
    --xr-ribbon-bd:    #1f2937;
    --xr-group-bg:     #1f2937;
    --xr-group-bd:     #374151;
    --xr-group-label:  #9ca3af;
    --xr-btn-text:     #e5e7eb;
    --xr-btn-hover:    #374151;
    --xr-btn-active:   #2F5BAA;
  }
}

/* ── 전체 컨테이너 ── */
.xr {
  display: flex;
  flex-direction: column;
  background: var(--xr-bg);
  border-bottom: 1px solid var(--xr-tabbar-bd);
  position: relative;
  user-select: none;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, system-ui, sans-serif;
  font-size: 13px;
}

/* ── Row 1: 타이틀바 스타일 탭바 (SEcMS 30px Windows 스타일) ── */
.xr-tabbar {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%);
  border-bottom: 1px solid #b8b8b8;
  height: 30px;
  padding: 0 6px;
  gap: 1px;
  position: relative;
  z-index: 2;
  user-select: none;
}

.xr-tab {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .1s, border-color .1s;
  position: relative;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.xr-tab:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.1);
}

.xr-tab[aria-selected="true"],
.xr-tab.xr-tab--active {
  background: #cce4ff;
  border-color: #0055cc;
  color: #003380;
  font-weight: 700;
}

.xr-tab:focus-visible {
  outline: 2px solid var(--xr-accent);
  outline-offset: -2px;
}

/* Alt 활성화 시 단축키 힌트 표시 */
.xr-tab .xr-key {
  display: none;
  position: absolute;
  bottom: 1px;
  right: 4px;
  background: var(--xr-key-bg);
  color: var(--xr-key-text);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  line-height: 1;
  pointer-events: none;
}

.xr.xr--alt-active .xr-tab .xr-key {
  display: inline-block;
  animation: xr-key-pop .12s ease-out;
}

@keyframes xr-key-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* 파일 탭 — SEcMS 스타일: 진한 파란 배지 */
.xr-tab[data-tab="file"] {
  background: #2F5BAA;
  color: #fff;
  border-color: #1e3f7e;
  border-radius: 2px;
  margin-right: 6px;
}
.xr-tab[data-tab="file"]:hover { background: #1e3f7e; }

/* 우측 영역 (사용자 / 최소화 등) */
.xr-tabbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
  color: var(--xr-tab-text);
  font-size: 12px;
}

.xr-tabbar-right .xr-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--xr-group-bd);
}
.xr-tabbar-right .xr-user .xr-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--xr-accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

/* ── Row 2: 리본 (SEcMS #f8f8f8 + 파란 하단 보더 2px) ── */
.xr-ribbon {
  display: flex;
  align-items: stretch;
  background: #f8f8f8;
  border-bottom: 2px solid #b0c4d8;
  height: 80px;       /* SEcMS: 상단라벨(22px) + 버튼영역(50px) + 하단보더 */
  padding: 0 4px;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #c0c8d4 transparent;
}

/* ── 그룹 (SEcMS color-bold: 컬러 보더는 JS 인라인, CSS는 구조만) ── */
.xr-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
  position: relative;
  /* 컬러 보더·배경은 buildPanel에서 --grp-color 기반 인라인 style로 주입 */
}

.xr-group-body {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 4px 4px;
}

/* ── 상단 라벨 (SEcMS 최신 확정: 단색 slate 절제, 활성 그룹만 파랑) ── */
.xr-group-label {
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 3px 10px 4px;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
  user-select: none;
  /* SEcMS TopNavBar 2026-06-04 확정: 비활성 그룹 = slate */
  background: #475569;
  border-bottom: 2px solid #334155;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
/* SEcMS: 활성 그룹(활성 버튼 포함)만 파랑 + 상단 인셋 하이라이트 */
.xr-group:has(.xr-btn--active) > .xr-group-label {
  background: #2563eb;
  border-bottom-color: #1d4ed8;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,0.5);
}

/* 아이콘 박스 버튼 (큰 / 중 / 작은 사이즈) */
.xr-btn {
  display: flex;
  /* SEcMS RibbonButton 완벽 이식 */
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 4px 8px 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #1a1a1a;
  cursor: pointer;
  position: relative;
  min-width: 58px;
  transition: all 100ms;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  user-select: none;
}

.xr-btn:hover {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.15);
}

/* 활성 버튼 — SEcMS: 그룹 색상 테두리 + 그라디언트 + 하단 인셋 쉐도우 */
.xr-btn:active,
.xr-btn.xr-btn--active {
  border: 1.5px solid var(--grp-color, #2F5BAA);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--grp-color, #2F5BAA) 22%, transparent) 0%,
    color-mix(in srgb, var(--grp-color, #2F5BAA) 11%, transparent) 100%);
  color: var(--grp-color, #2F5BAA);
  font-weight: 800;
  box-shadow: inset 0 -2px 0 var(--grp-color, #2F5BAA);
}

.xr-btn:focus-visible {
  outline: 2px solid var(--grp-color, #2F5BAA);
  outline-offset: -2px;
}

/* ── 큰 버튼 (SEcMS: 아이콘 28x28 컨테이너 + 라벨 아래) ── */
.xr-btn--lg {
  min-width: 58px;
  padding: 4px 8px 3px;
}
.xr-btn--lg iconify-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 16px;
  color: #374151;
  background: transparent;
  border-radius: 4px;
  border: 1px solid transparent;
  margin-bottom: 1px;
}
.xr-btn--lg.xr-btn--active iconify-icon,
.xr-btn--lg:active iconify-icon {
  background: #fff;
  border-color: color-mix(in srgb, var(--grp-color, #2F5BAA) 33%, transparent);
  color: var(--grp-color, #2F5BAA);
}
.xr-btn--lg .xr-btn-label {
  font-size: 11px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

/* ── 작은 버튼 (스택용: 아이콘 + 라벨 행방향, 컴팩트) ── */
.xr-btn--sm {
  flex-direction: row;
  min-width: auto;
  padding: 3px 7px;
  gap: 4px;
  font-size: 12px;
}
.xr-btn--sm iconify-icon {
  font-size: 14px;
  color: #374151;
}
.xr-btn--sm.xr-btn--active iconify-icon,
.xr-btn--sm:active iconify-icon {
  color: var(--grp-color, #2F5BAA);
}
.xr-btn--sm .xr-btn-label { font-size: 11px; }

/* 기본 아이콘 색상 */
.xr-btn iconify-icon {
  font-size: 18px;
  color: #374151;
  transition: color 100ms;
}
.xr-btn.xr-btn--active iconify-icon {
  color: var(--grp-color, #2F5BAA);
}

.xr-btn-label {
  white-space: nowrap;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

/* Alt 단축키 표시 */
.xr-btn .xr-key {
  display: none;
  position: absolute;
  top: 0;
  right: 1px;
  background: var(--xr-key-bg);
  color: var(--xr-key-text);
  font-size: 9px;
  font-weight: 700;
  padding: 0 3px;
  border-radius: 2px;
  pointer-events: none;
}

.xr.xr--alt-active .xr-btn .xr-key {
  display: inline-block;
  animation: xr-key-pop .12s ease-out;
}

.xr-btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* 작은 버튼 세로 스택 (3개 1조) */
.xr-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* 패널 (탭별 그룹 컨테이너) */
.xr-panel {
  display: none;
  width: 100%;
}
.xr-panel.xr-panel--active {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

/* ── 파일 메뉴 (Backstage) ── */
.xr-backstage {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--xr-accent);
  color: #fff;
  z-index: 10000;
  display: none;
  flex-direction: column;
}
.xr-backstage.xr-backstage--open { display: flex; }
.xr-backstage-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  gap: 12px;
}
.xr-backstage-back {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.xr-backstage-back:hover { background: rgba(255,255,255,.1); }
.xr-backstage-title { font-size: 16px; font-weight: 600; }
.xr-backstage-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  overflow: hidden;
}
.xr-backstage-nav {
  background: rgba(0,0,0,.15);
  padding: 12px 0;
  overflow-y: auto;
}
.xr-backstage-nav button {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  padding: 10px 20px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.xr-backstage-nav button:hover { background: rgba(255,255,255,.08); }
.xr-backstage-nav button.xr-bs-active { background: rgba(255,255,255,.2); font-weight: 600; }
.xr-backstage-content {
  padding: 24px;
  overflow-y: auto;
  background: rgba(0,0,0,.05);
}

/* ── 그리드 영역과 통합되는 quick access ── */
.xr-quickaccess {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 8px;
  background: var(--xr-tabbar-bg);
  border-bottom: 1px solid var(--xr-tabbar-bd);
  font-size: 12px;
}
.xr-qa-btn {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  color: var(--xr-tab-text);
}
.xr-qa-btn:hover { background: var(--xr-btn-hover); border-color: var(--xr-group-bd); }
.xr-qa-btn iconify-icon { font-size: 14px; }
.xr-qa-sep {
  width: 1px;
  height: 16px;
  background: var(--xr-tabbar-bd);
  margin: 0 4px;
}

/* ── Status bar (엑셀 하단) ── */
.xr-statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 24px;
  background: var(--xr-accent);
  color: #fff;
  font-size: 11px;
  border-top: 1px solid #1f3f7e;
}
.xr-statusbar .xr-status-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 6px;
  border-right: 1px solid rgba(255,255,255,.15);
}
.xr-statusbar .xr-status-item:last-child { border-right: none; }
.xr-statusbar .xr-status-spacer { flex: 1; }

/* ============================================================
   ✨ Supa-Style Minimal UI Theme (Supanova Luxe Edition)
   ============================================================ */
body.layout-supa .xr {
  background: rgba(13, 27, 47, 0.75) !important;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2) !important;
  backdrop-filter: blur(24px) !important;
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 12px 40px -10px rgba(0, 0, 0, 0.6) !important;
  margin: 12px 16px !important;
  border-radius: 14px !important;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body.layout-supa .xr-quickaccess {
  background: rgba(13, 27, 47, 0.5) !important;
  border-bottom: 1px solid rgba(255,255,255,0.03) !important;
  color: #9ca3af !important;
}

body.layout-supa .xr-tabbar {
  background: transparent !important;
  border-bottom: 1px solid rgba(255,255,255,0.03) !important;
  height: 40px !important;
  align-items: center !important;
  padding: 0 12px !important;
}

body.layout-supa .xr-tab {
  color: #9ca3af !important;
  border-radius: 9999px !important;
  margin: 4px 2px !important;
  padding: 4px 14px !important;
  height: 28px !important;
  font-weight: 700 !important;
  font-size: 11.5px !important;
  border: none !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

body.layout-supa .xr-tab:hover {
  color: #fff !important;
  background: rgba(255,255,255,0.06) !important;
}

body.layout-supa .xr-tab.xr-tab--active,
body.layout-supa .xr-tab[aria-selected="true"] {
  background: #38bdf8 !important; /* var(--primary) */
  color: #030712 !important;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35) !important;
}

/* 파일 탭은 미니멀 룩과 매치 */
body.layout-supa .xr-tab[data-tab="file"] {
  background: rgba(56, 189, 248, 0.15) !important;
  border: 1px solid rgba(56, 189, 248, 0.3) !important;
  color: #38bdf8 !important;
  margin-right: 6px !important;
}
body.layout-supa .xr-tab[data-tab="file"]:hover {
  background: rgba(56, 189, 248, 0.25) !important;
}

body.layout-supa .xr-tabbar-right {
  color: #f3f4f6 !important;
}

body.layout-supa .xr-tabbar-right .xr-user {
  background: rgba(255,255,255,0.03) !important;
  border-color: rgba(255,255,255,0.05) !important;
}

body.layout-supa .xr-ribbon {
  background: rgba(8, 15, 30, 0.85) !important;
  border-bottom: none !important;
  height: 94px !important;
  padding: 6px 12px !important;
}

/* Double-Bezel Card 구현 */
body.layout-supa .xr-group {
  background: rgba(17, 24, 39, 0.45) !important;
  border: 1px solid rgba(56, 189, 248, 0.08) !important;
  border-radius: 8px !important;
  margin: 1px 4px 3px !important;
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.03),
    0 4px 12px rgba(0,0,0,0.3) !important;
  padding: 3px 8px 4px !important;
}

body.layout-supa .xr-group-label {
  color: #38bdf8 !important; /* var(--primary) */
  font-weight: 700 !important;
  font-size: 9.5px !important;
  opacity: 0.8;
  margin-top: 1px !important;
}

body.layout-supa .xr-btn {
  color: #d1d5db !important;
  border-radius: 4px !important;
}

body.layout-supa .xr-btn:hover {
  background: rgba(56, 189, 248, 0.06) !important;
  border-color: rgba(56, 189, 248, 0.15) !important;
}

body.layout-supa .xr-btn:active,
body.layout-supa .xr-btn.xr-btn--active {
  background: rgba(56, 189, 248, 0.15) !important;
  border-color: #38bdf8 !important;
  color: #fff !important;
}

body.layout-supa .xr-btn iconify-icon {
  color: #38bdf8 !important;
  filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.25)) !important;
}

body.layout-supa .xr-statusbar {
  background: rgba(13, 27, 47, 0.95) !important;
  border-top: 1px solid rgba(255,255,255,0.03) !important;
}

