/* SmartSelling Super Admin — 레이아웃 보조 CSS
   common.css 를 기반으로 사용하며, 여기서는 좌측 사이드바 레이아웃과
   어드민 전용 컴포넌트를 정의합니다. */

/* ── CSS 변수 (프로토타입 토큰) ── */
:root {
    --sa-accent: #6366f1;
    --sa-accent-hover: #4f52e8;
    --sa-text: #111118;
    --sa-text-2: #333340;
    --sa-text-muted: #6e6e80;
    --sa-border: #e5e5ea;
    --sa-border-light: #f0f0f5;
    --sa-green: #22c55e;
    --sa-red: #ef4444;
    --sa-orange: #f59e0b;
    --sa-blue: #3b82f6;
    --sa-purple: #8b5cf6;
}

/* ── 페이지 헤더 (ph) ── */
.ph { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:20px; gap:12px; }
.ph-title { font-size:19px; font-weight:700; color:var(--sa-text); }
.ph-sub   { font-size:12.5px; color:var(--sa-text-muted); margin-top:3px; }
.ph-actions { display:flex; gap:8px; flex-shrink:0; align-items:center; }

/* ── 지표 카드 ── */
.stat-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(175px,1fr)); gap:14px; margin-bottom:20px; }
.stat-card { background:#fff; border:1px solid #d2d6de; border-radius:12px; padding:16px 18px; box-shadow:0 3px 14px rgba(0,0,0,.09); }
.stat-card[style*="cursor"] { transition:box-shadow .15s; }
.stat-card[style*="cursor"]:hover { box-shadow:0 6px 20px rgba(0,0,0,.13); }
.stat-ico { font-size:20px; margin-bottom:8px; }
.stat-lbl { font-size:13px; color:var(--sa-text-muted); font-weight:500; margin-bottom:6px; }
.stat-val { font-size:25px; font-weight:700; color:var(--sa-text); }
.stat-bar { height:3px; border-radius:2px; margin:6px 0 4px; width:28px; }
.stat-chg { font-size:11.5px; margin-top:5px; display:flex; align-items:center; gap:3px; }
.up      { color:var(--sa-green); }
.down    { color:var(--sa-red); }
.neutral { color:var(--sa-text-muted); }

/* ── 2컬럼 레이아웃 ── */
.two-col { display:grid; grid-template-columns:2fr 1fr; gap:16px; }
@media(max-width:900px) { .two-col { grid-template-columns:1fr; } }

/* ── 콘텐츠 카드 ── */
.card { background:#fff; border:1px solid var(--sa-border); border-radius:11px; padding:18px; }
.card table { width:100%; border-collapse:collapse; }
.card table th { padding:8px 12px; text-align:left; font-size:11.5px; font-weight:600; color:var(--sa-text-muted); background:#fafafa; border-bottom:1px solid var(--sa-border-light); white-space:nowrap; }
.card table td { padding:10px 12px; font-size:13.5px; color:var(--sa-text-2); border-bottom:1px solid #f7f7f9; }
.card table tr:last-child td { border-bottom:none; }
.card table tr:hover td { background:#fafafa; }
.sec-title { font-size:14px; font-weight:600; color:var(--sa-text); margin-bottom:13px; }

/* ── 프로그레스 바 ── */
.prog-wrap { margin:11px 0; }
.prog-row  { display:flex; justify-content:space-between; margin-bottom:5px; font-size:12.5px; }
.prog-name { color:var(--sa-text-2); font-weight:500; }
.prog-cnt  { color:var(--sa-text-muted); font-size:12px; }
.prog-bar  { height:5px; background:#f0f0f5; border-radius:3px; overflow:hidden; }
.prog-fill { height:100%; border-radius:3px; }

/* ── 배지 (프로토타입 b-* 컬러 체계) ── */
.b-green  { background:#f0fdf4; color:#15803d; }
.b-blue   { background:#eff6ff; color:#1d4ed8; }
.b-orange { background:#fff7ed; color:#c2410c; }
.b-gray   { background:#f5f5f8; color:#6e6e80; }
.b-red    { background:#fef2f2; color:#dc2626; }
.b-purple { background:#faf5ff; color:#7c3aed; }
.b-indigo { background:#eef2ff; color:#4338ca; }

/* ── 버튼 ghost ── */
.btn-ghost { background:#fff; border:1px solid var(--sa-border); color:var(--sa-text-2); }
.btn-ghost:hover { background:#f5f5f8; }

/* ── 어드민 상단바 — common.css 다크 오버라이드 ── */
.top-header {
    background: #fff !important;
    border-bottom: 1px solid #e5e5ea;
    height: 52px;
}
/* 사이드바 토글 버튼 */
.sb-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border: none; background: transparent; cursor: pointer;
    border-radius: 8px; color: #666; font-size: 20px;
    transition: background .13s, color .13s; flex-shrink: 0; font-family: inherit;
}
.sb-toggle:hover { background: #f0f0f5; color: #333; }
/* 로고 텍스트 */
.sa-admin-logo {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: -.3px;
    white-space: nowrap;
    flex-shrink: 0;
}
.header-spacer { flex: 1; }
/* 우측 헤더 액션 */
.header-actions { display: flex; align-items: center; gap: 8px; }
.admin-user-chip {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 12px 5px 7px;
    background: #f4f5f8; border: 1px solid #e0e0e5;
    border-radius: 9px; cursor: default;
}
.admin-user-avatar {
    width: 26px; height: 26px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 6px; display: flex; align-items: center;
    justify-content: center; font-size: 13px; color: #fff;
    font-weight: 700; flex-shrink: 0;
}
.admin-user-name { font-size: 12.5px; color: #333; font-weight: 500; }
.logout-link {
    font-size: 12.5px; color: #666; cursor: pointer;
    padding: 5px 10px; border: 1px solid #ddd; border-radius: 7px;
    background: transparent; font-family: inherit;
    transition: color .13s, background .13s;
}
.logout-link:hover { color: #333; background: #eee; }

/* ── 좌측 사이드바 ── */
.admin-sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    width: 230px;
    height: calc(100vh - 52px);
    background: #1e1e2f;
    overflow: hidden;
    z-index: 900;
    padding: 0;
    box-shadow: 2px 0 8px rgba(0,0,0,.18);
    transition: width .22s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
}
/* 메뉴 스크롤 영역 — sb-bottom 은 이 밖에 위치 */
.sb-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.sb-scroll-area::-webkit-scrollbar { width: 3px; }
.sb-scroll-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }
/* 접힌 상태 */
.admin-sidebar.sb-collapsed { width: 52px; }
.admin-sidebar.sb-collapsed .nav-label,
.admin-sidebar.sb-collapsed .sb-sec-hd,
.admin-sidebar.sb-collapsed .sb-admin-info,
.admin-sidebar.sb-collapsed .zoom-ctrl { display: none !important; }
.admin-sidebar.sb-collapsed .sb-sec-body { max-height: 300px !important; }
.admin-sidebar.sb-collapsed .nav-btn { justify-content: center; padding: 9px 0; }
.admin-sidebar.sb-collapsed .nav-icon { font-size: 18px; width: auto; }
.admin-sidebar.sb-collapsed .sb-bottom { padding: 8px 5px 12px; }
/* 대메뉴 헤더 (클릭 가능) */
.sb-sec-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 14px 6px 16px;
    cursor: pointer;
    user-select: none;
}
.sb-sec-hd:hover .sb-sec-title { color: #c8c8f0; }
.sb-sec-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #fff;
}
.sb-sec-arrow {
    font-size: 18px;
    color: rgba(255,255,255,.6);
    transition: transform 0.2s;
    transform: rotate(90deg);
    display: inline-block;
}
.sb-sec-hd:not(.sb-open) .sb-sec-arrow { transform: rotate(0deg); }

/* 소메뉴 그룹 */
.sb-sec-body {
    overflow: hidden;
    max-height: 300px;
    transition: max-height 0.22s ease;
}
.sb-sec-body.sb-collapsed { max-height: 0; }

/* 섹션 구분 */
.sb-section { padding: 4px 0; }
.sb-section.sb-section-first { padding: 14px 0 10px; }
.sb-section + .sb-section { border-top: 1px solid #2c2c42; }

/* 네비 아이템 */
.nav-item { margin: 1px 6px; }
.nav-btn {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 8px 10px;
    border: none; background: transparent; cursor: pointer;
    border-radius: 7px; color: #eeeeff; font-size: 13.5px;
    font-weight: 500; transition: background .13s, color .13s;
    text-align: left; font-family: inherit; text-decoration: none;
}
.nav-btn:hover { background: rgba(99,102,241,.20); color: #fff; }
.nav-btn.active {
    background: rgba(99,102,241,.32); color: #fff; font-weight: 600;
    border-left: 2px solid #6366f1; margin-left: -2px; padding-left: 12px;
}
.nav-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; line-height: 1; }
.nav-dot  { font-size: 13px; opacity: .7; }
.nav-label { flex: 1; }

/* ── 관리자 페이지 레이아웃 (사이드바 포함) ── */
.admin-wrap {
    padding-top: 52px;
    padding-left: 230px;
    min-height: 100vh;
    background: #f5f6fa;
    transition: padding-left .22s cubic-bezier(.4,0,.2,1);
}
.admin-wrap.sb-wrap-collapsed { padding-left: 52px; }
.admin-content {
    max-width: 1380px;
    margin: 0 auto;
    padding: 28px 28px;
}
.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.admin-page-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}
/* 헤더 'ADMIN' 라벨 (구형 인라인 방식) */
.logo .admin-label {
    font-size: 11px;
    color: #a5b4fc;
    font-weight: 600;
    letter-spacing: 0.12em;
    margin-left: 6px;
    vertical-align: middle;
    background: rgba(99,102,241,.2);
    padding: 2px 6px;
    border-radius: 4px;
}
/* 로고 (SA 어드민 전용) — S마크 + SmartSelling + ADMIN 배지 */
.sa-logo { display: flex; align-items: center; gap: 10px; }
.sa-logo-mark {
    width: 28px; height: 28px;
    background: rgba(99,102,241,.35);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 900; color: #a5b4fc;
    flex-shrink: 0;
}
.sa-logo-brand {
    font-size: 16px; font-weight: 700; color: #fff;
    letter-spacing: -0.01em; line-height: 1;
}
.sa-logo-admin {
    display: inline-block;
    font-size: 10px; font-weight: 700;
    color: #a5b4fc; letter-spacing: .10em; text-transform: uppercase;
    background: rgba(99,102,241,.25);
    padding: 2px 6px; border-radius: 4px;
    margin-left: 7px; vertical-align: middle;
}

/* ── 필터 바 ── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.filter-bar input, .filter-bar select {
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #d0d5dd;
    border-radius: 7px;
    background: #fafbfc;
    font-family: inherit;
}
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar input:focus, .filter-bar select:focus {
    outline: none;
    border-color: #6366F1;
    background: #fff;
}
.count-bar { font-size: 13px; color: #888; margin-bottom: 10px; }
.count-bar strong { color: #333; }

/* ── 요약 카드 행 ── */
.summary-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.summary-card {
    background: #fff;
    border: 1.5px solid #e8e8f0;
    border-radius: 10px;
    padding: 14px 22px;
    cursor: pointer;
    transition: border-color 0.15s;
    min-width: 130px;
}
.summary-card:hover { border-color: #6366F1; }
.summary-card.active { border-color: #6366F1; background: #f5f5ff; }
.summary-card .s-label { font-size: 12px; color: #888; margin-bottom: 4px; }
.summary-card .s-value { font-size: 24px; font-weight: 700; color: #1a1a2e; }

/* ── 패널 (collection_list 스타일) ── */
.admin-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    overflow: hidden;
    margin-bottom: 20px;
}
.admin-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.admin-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
}

/* ── 탭 ── */
.tab-bar {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.12s;
    font-family: inherit;
}
.tab-btn.active { color: #6366F1; border-bottom-color: #6366F1; }
.tab-btn:hover:not(.active) { color: #444; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── KV 테이블 ── */
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table tr { border-bottom: 1px solid #f0f0f0; }
.kv-table tr:last-child { border-bottom: none; }
.kv-table th {
    width: 140px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    text-align: left;
    background: #fafafa;
}
.kv-table td { padding: 10px 16px; font-size: 13px; color: #333; }

/* ── 액션 폼 ── */
.action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: #fafafa;
    border-radius: 8px;
    margin-bottom: 12px;
}
.action-row label { font-size: 13px; font-weight: 600; color: #555; white-space: nowrap; }
.action-row select, .action-row input[type=date] {
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-family: inherit;
}

/* ── 알림 메시지 ── */
.msg-box {
    display: none;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}
.msg-box.ok  { display: block; background: #e6fff7; color: #00b894; }
.msg-box.err { display: block; background: #ffe6e6; color: #d63031; }

/* ── 사이드바 하단 (화면크기 + 어드민 카드) ── */
.sb-bottom {
    background: #1e1e2f;
    padding: 10px 6px 14px;
    border-top: 1px solid #2c2c42;
    flex-shrink: 0;
}
.zoom-ctrl {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 10px 6px; margin-bottom: 4px;
}
.zoom-ctrl-label { font-size: 11px; color: #9090b8; font-weight: 500; flex: 1; white-space: nowrap; }
.zoom-ctrl-btn {
    height: 23px; padding: 0 8px;
    border: 1px solid #3a3a56; border-radius: 6px;
    background: rgba(255,255,255,.07); cursor: pointer;
    font-weight: 700; color: #9090b8;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .13s; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.zoom-ctrl-btn:hover:not(:disabled) { background: rgba(99,102,241,.25); border-color: #6366f1; color: #a5b4fc; }
.zoom-ctrl-btn:disabled { opacity: .3; cursor: default; }
.sb-admin-info {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 12px;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
    border-radius: 9px;
}
.sb-admin-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 8px; display: flex; align-items: center;
    justify-content: center; font-size: 15px; color: #fff;
    font-weight: 700; flex-shrink: 0;
}
.sb-admin-name { font-size: 13px; font-weight: 600; color: #dde0ff; word-break: break-all; }
.sb-admin-role { font-size: 11px; color: #9090b8; margin-top: 1px; }

/* ── 기타 ── */
.empty-msg { text-align: center; padding: 40px; color: #aaa; font-size: 14px; }
.usage-bar {
    display: inline-block;
    height: 6px;
    border-radius: 3px;
    background: #6366F1;
    vertical-align: middle;
    margin-left: 6px;
}
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-grid  { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 20px; }
.info-card  {
    background: #fff;
    border: 1px solid #e8e8f0;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.info-card .ic-label { font-size: 12px; color: #888; margin-bottom: 5px; }
.info-card .ic-value { font-size: 18px; font-weight: 700; color: #1a1a2e; }

/* ── data-table 보조 (center 정렬 컬럼) ── */
.data-table td.center, .data-table th.center { text-align: center; }

/* 로그인 페이지 */
.admin-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d3561 100%);
}
.admin-login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.admin-login-logo { text-align: center; margin-bottom: 28px; }
.admin-login-logo .brand { font-size: 22px; font-weight: 800; color: #1a1a2e; }
.admin-login-logo .brand span { color: #6366F1; }
.admin-login-logo .sub {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
.admin-login-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 12px;
    font-family: inherit;
    transition: border-color 0.12s;
}
.admin-login-input:focus { outline: none; border-color: #6366F1; }
.admin-login-btn {
    width: 100%;
    padding: 13px;
    font-size: 15px;
    font-weight: 700;
    background: #6366F1;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 4px;
    font-family: inherit;
    transition: background 0.15s;
}
.admin-login-btn:hover { background: #5558E3; }
.admin-login-btn:disabled { background: #aaa; cursor: not-allowed; }
.admin-login-error {
    color: #d63031;
    font-size: 13px;
    text-align: center;
    margin-top: 10px;
    min-height: 18px;
}

@media (max-width: 1100px) {
    .charts-row, .bottom-row { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
    .stats-grid { grid-template-columns: repeat(2,1fr) !important; }
}
