/* ============================================================
   sidebar.css — 좌측 사이드바 레이아웃
   ============================================================ */

:root {
  --sb-width: 220px;
  --sb-mini:  64px;
  --sb-bg:    #1e293b;
  --sb-border: rgba(255,255,255,.07);
  --sb-text:   #94a3b8;
  --sb-text-hover: #f1f5f9;
  --sb-hover-bg:   rgba(255,255,255,.06);
  --sb-active-bg:  rgba(59,130,246,.12);
  --sb-active-text: #60a5fa;
  --sb-active-bar:  #3b82f6;
  --sb-topbar-h: 56px;
}

/* ── Sidebar ── */
.app-sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sb-width);
  height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
body.sb-mini .app-sidebar {
  width: var(--sb-mini);
}
/* 접힌 상태에서 hover → 임시 확장 (overlay) */
body.sb-mini .app-sidebar:hover {
  width: var(--sb-width);
  box-shadow: 4px 0 24px rgba(0,0,0,.4);
}

/* ── Header ── */
.sb-header {
  display: flex;
  align-items: center;
  padding: 0 12px 0 16px;
  height: 64px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  gap: 8px;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sb-brand img {
  width: 30px; height: 30px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
}
.sb-brand-text {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  transition: opacity .15s;
}
body.sb-mini .app-sidebar:not(:hover) .sb-brand-text { opacity: 0; }

.sb-toggle {
  background: none;
  border: none;
  color: var(--sb-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: all .15s;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.sb-toggle:hover { background: var(--sb-hover-bg); color: var(--sb-text-hover); }
.sb-toggle i { font-size: 11px; transition: transform .25s; }
body.sb-mini .sb-toggle i { transform: rotate(180deg); }
body.sb-mini .app-sidebar:not(:hover) .sb-toggle { display: none; }

/* ── User ── */
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  overflow: hidden;
}
.sb-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.sb-uname {
  font-size: 13px; font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: opacity .15s;
}
body.sb-mini .app-sidebar:not(:hover) .sb-uname { opacity: 0; }

/* ── Nav ── */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin: 2px 8px;
  width: calc(100% - 16px);
  border-radius: 8px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  border: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  cursor: pointer;
  text-align: left;
  background: none;
}
.sb-nav-item i {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.sb-nav-item span { flex: 1; transition: opacity .15s; }
.sb-nav-item:hover { background: var(--sb-hover-bg); color: var(--sb-text-hover); }
.sb-nav-item.active {
  background: rgba(59,130,246,.28);
  color: var(--sb-active-text);
  font-weight: 600;
}
body.sb-mini .app-sidebar:not(:hover) .sb-nav-item span { opacity: 0; }

.sb-logout { color: #f87171 !important; border: none !important; }
.sb-logout:hover { background: rgba(239,68,68,.12) !important; color: #fca5a5 !important; }

.sb-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 4px 0;
}
.sb-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: #475569;
  padding: 8px 20px 2px;
  white-space: nowrap;
  transition: opacity .15s;
}
body.sb-mini .app-sidebar:not(:hover) .sb-section-label { opacity: 0; }

/* ── Mobile backdrop ── */
.sb-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  z-index: 1039;
}
.sb-backdrop.show { display: block; }

/* ── Mobile topbar ── */
.sb-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--sb-topbar-h);
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e2e8f0;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 1038;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sb-topbar-toggle {
  background: none; border: none;
  font-size: 18px; color: #374151;
  cursor: pointer; padding: 4px;
  line-height: 1; display: flex; align-items: center;
}
.sb-topbar-brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
  color: #1e293b; font-weight: 700; font-size: 15px;
}

/* ── Main wrapper ── */
.main-wrapper {
  margin-left: var(--sb-width);
  min-height: 100vh;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}
body.sb-mini .main-wrapper { margin-left: var(--sb-mini); }

.content-wrapper {
  padding: 24px;
  padding-bottom: 40px;
}

/* ── Mobile ── */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: var(--sb-width) !important;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sb-topbar { display: flex; }
  .main-wrapper { margin-left: 0 !important; }
  .content-wrapper {
    padding: 16px;
    padding-top: calc(var(--sb-topbar-h) + 16px);
    padding-bottom: 32px;
  }
  /* 모바일: 텍스트 항상 표시 */
  .sb-nav-item span,
  .sb-brand-text,
  .sb-uname,
  .sb-section-label { opacity: 1 !important; }
}
