/*
 * Woodle 관리자 콘솔 스타일 — 부트스트랩/jQuery 없이 이 파일 하나로 관리자 화면 전체를 그린다.
 * 색·간격·라운드는 아래 토큰(CSS 변수)만 고치면 전 화면에 반영된다. 팔레트는 부모앱(woodleKidWatch)
 * 값을 따랐다: 어두운 배경(#0C0C0C 계열), admin_blue(#7BA0FF), 금색(#FFD700), red(#FF5757).
 * 밝은 화면을 쓰려면 <html data-theme="light"> 로 바꾼다(아래 오버라이드 참고).
 */

:root {
    /* 표면 — 뒤로 갈수록 위에 올라오는 층 */
    --bg: #0d0f13;
    --surface: #15181f;
    --surface-2: #1b1f28;
    --surface-hover: #212734;
    --line: #262c38;
    --line-strong: #333b4a;

    /* 글자 */
    --text: #e7eaf0;
    --text-dim: #98a1b2;
    --text-faint: #6c7689;

    /* 강조 */
    --accent: #7ba0ff;
    --accent-strong: #5b86f5;
    --accent-soft: rgba(123, 160, 255, .14);
    --gold: #ffd700;
    --gold-soft: rgba(255, 215, 0, .14);
    --ok: #3ddc97;
    --ok-soft: rgba(61, 220, 151, .14);
    --danger: #ff5757;
    --danger-soft: rgba(255, 87, 87, .14);

    --radius: 10px;
    --radius-sm: 7px;
    --sans: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

/* 밝은 화면 — 토큰만 덮어쓴다. 컴포넌트 규칙은 그대로 재사용된다. */
:root[data-theme="light"] {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-hover: #eef1f6;
    --line: #e2e6ee;
    --line-strong: #cfd5e1;
    --text: #1b1f28;
    --text-dim: #5b6474;
    --text-faint: #8b93a3;
    --accent: #3f6fe0;
    --accent-strong: #2f5bc7;
    --accent-soft: rgba(63, 111, 224, .1);
    --gold: #b07d00;
    --gold-soft: rgba(176, 125, 0, .12);
    --ok: #12996b;
    --ok-soft: rgba(18, 153, 107, .12);
    --danger: #d63a3a;
    --danger-soft: rgba(214, 58, 58, .1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--mono); font-size: .92em; }
code { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: .5px 5px; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.breakable { word-break: break-all; }
.hidden { display: none !important; }

/* ── 셸(사이드바 + 본문) ───────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; align-items: stretch; }

.side {
    width: 244px; flex: 0 0 244px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: 20px 0 16px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 18px 18px; }
.brand-mark {
    width: 32px; height: 32px; flex: none; border-radius: 9px;
    background: linear-gradient(140deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #0d0f13; font-weight: 800; font-size: 15px;
    display: flex; align-items: center; justify-content: center; letter-spacing: -.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 700; letter-spacing: -.2px; }
.brand-text span { font-size: 11.5px; color: var(--text-faint); }

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; border-top: 1px solid var(--line); }

.nav-item {
    display: block; padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text-dim); text-decoration: none; line-height: 1.3;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item .label { display: block; font-size: 13.5px; font-weight: 600; }
.nav-item .desc { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.nav-item.is-active { background: var(--accent-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.is-active .label { color: var(--accent); }

.side-foot { margin-top: auto; padding: 14px 16px 0; border-top: 1px solid var(--line); }
.side-foot .who { font-size: 11.5px; color: var(--text-faint); margin-bottom: 8px; }

.main { flex: 1 1 auto; min-width: 0; padding: 26px 30px 72px; }
.main > .wrap { max-width: 1180px; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; margin: 0 0 6px; }
.page-head p { margin: 0; color: var(--text-dim); max-width: 78ch; font-size: 13px; }
.page-head p + p { margin-top: 5px; }

h2.section { font-size: 15px; font-weight: 700; margin: 28px 0 10px; letter-spacing: -.2px; }
h2.section .count { color: var(--text-faint); font-weight: 500; }

/* ── 패널 ─────────────────────────────────────────────────────────── */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel + .panel, .panel + .table-wrap, .table-wrap + .panel { margin-top: 16px; }
.panel-head {
    padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
    font-size: 13px; font-weight: 700; letter-spacing: -.1px;
}
.panel-body { padding: 16px; }
.panel-narrow { max-width: 780px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-fill { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid .span-all { grid-column: 1 / -1; }

/* ── 폼 ───────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.hint { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }

.input, .select, textarea.input {
    width: 100%; padding: 8px 11px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13.5px; line-height: 1.45;
}
textarea.input { resize: vertical; min-height: 76px; }
.input::placeholder, textarea.input::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, textarea.input:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input[type="file"] { padding: 7px 10px; }
.input[type="file"]::file-selector-button {
    margin-right: 10px; padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 6px;
    background: var(--surface-hover); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
}
.select {
    appearance: none; padding-right: 32px; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 17px) 51%, calc(100% - 12px) 51%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

/* 라디오·체크박스 한 줄 */
.choice { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.choice input { margin: 3px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.choice label { cursor: pointer; }
.choice-group { margin-bottom: 12px; }

details > summary { cursor: pointer; color: var(--text-dim); font-size: 12.5px; }
details[open] > summary { margin-bottom: 4px; }

/* ── 버튼 ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 15px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong); background: var(--surface-hover); color: var(--text);
    font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.2;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--text-faint); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #0d0f13; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-gold { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.actions .hint { margin: 0; }
.inline-form { display: inline-block; }
.row-actions { display: flex; gap: 6px; }

/* ── 표 ───────────────────────────────────────────────────────────── */

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table thead th {
    background: var(--surface-2); color: var(--text-dim);
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .empty { text-align: center; color: var(--text-faint); padding: 26px 12px; }

/* ── 태그(상태 배지) ──────────────────────────────────────────────── */

.tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700; letter-spacing: -.1px;
    border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-dim);
}
.tag-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag-info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tag-gold { background: var(--gold-soft); border-color: transparent; color: var(--gold); }
.tag-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

/* ── 알림 ─────────────────────────────────────────────────────────── */

.notice {
    padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
    border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
    font-size: 13px;
}
.notice:last-child { margin-bottom: 0; }
.notice-ok { border-color: transparent; background: var(--ok-soft); }
.notice-info { border-color: transparent; background: var(--accent-soft); }
.notice-warn { border-color: transparent; background: var(--gold-soft); }
.notice-err { border-color: transparent; background: var(--danger-soft); }
.notice strong { font-weight: 700; }

/* ── 진행률(업로드) ───────────────────────────────────────────────── */

.bar { height: 8px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.bar-fill {
    height: 100%; width: 0; border-radius: 999px; background: var(--accent);
    transition: width .18s ease-out;
}
.bar-fill.is-busy {
    background-image: linear-gradient(90deg, rgba(255, 255, 255, .25) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .25) 50%, rgba(255, 255, 255, .25) 75%, transparent 75%);
    background-size: 14px 14px;
    animation: bar-move .7s linear infinite;
}
.bar-fill.is-ok { background: var(--ok); }
.bar-fill.is-err { background: var(--danger); }
@keyframes bar-move { from { background-position: 0 0; } to { background-position: 14px 0; } }
.bar-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.progress-box { margin-top: 16px; }

/* ── 로그인 화면 ──────────────────────────────────────────────────── */

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 372px; }
.auth-card .brand { justify-content: center; padding: 0 0 20px; }
.auth-card .panel-body { padding: 22px; }
.auth-lead { color: var(--text-dim); font-size: 12.5px; margin: 0 0 18px; }
.auth-foot { text-align: center; color: var(--text-faint); font-size: 11.5px; margin-top: 16px; }

/* ── 좁은 화면 — 사이드바를 상단 가로 메뉴로 접는다 ───────────────── */

@media (max-width: 880px) {
    .shell { display: block; }
    .side {
        width: auto; flex: none; border-right: 0; border-bottom: 1px solid var(--line);
        padding: 12px 14px;
    }
    .brand { padding: 0 0 10px; }
    .side-nav { flex-direction: row; overflow-x: auto; padding: 8px 0 0; gap: 6px; }
    .nav-item { white-space: nowrap; }
    .nav-item .desc { display: none; }
    .nav-item.is-active { box-shadow: inset 0 -2px 0 var(--accent); }
    .side-foot { margin: 10px 0 0; padding: 10px 0 0; }
    .side-foot .who { display: inline-block; margin: 0 10px 0 0; }
    .side-foot form { display: inline-block; }
    .side-foot .btn { width: auto; }
    .main { padding: 20px 16px 56px; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* 유효성 요약(asp-validation-summary)은 오류가 없을 때도 빈 div 가 렌더된다 — 그때는 감춘다. */
.validation-summary-valid, .notice:empty { display: none; }

/* 유효성 요약은 <ul><li> 로 렌더된다 — 기본 불릿·여백을 알림 박스에 맞게 정리한다.
   항목이 하나뿐인 흔한 경우(로그인 실패 등)는 불릿을 지워 한 줄 문장처럼 보이게 한다. */
.notice ul { margin: 0; padding-left: 17px; }
.notice li { margin: 0; }
.notice ul li:only-child { list-style: none; margin-left: -17px; }

/* ── 테마 제작(AdminThemes) ─────────────────────────────────────────
   목록 하단 고정 [+ 새 테마] 바, 페이지 사이드 목록, 요소 행(썸네일+이름+설명+변경). */

.theme-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 74px; }
.theme-card-body { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.theme-card-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 스크롤과 무관하게 화면 하단에 고정되는 추가 버튼 바 — 사이드바 폭만큼 비켜 앉는다. */
.theme-add-bar {
    position: fixed; left: 240px; right: 0; bottom: 0; z-index: 30;
    padding: 12px 24px; background: linear-gradient(transparent, var(--bg) 40%);
}
.theme-add-bar .btn { max-width: 1100px; margin: 0 auto; display: block; }
@media (max-width: 900px) { .theme-add-bar { left: 0; } }

.theme-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.theme-editor { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .theme-editor { grid-template-columns: minmax(0, 1fr); } }

.theme-pages { display: flex; flex-direction: column; gap: 6px; }
.theme-page-item {
    display: block; padding: 9px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--text);
}
.theme-page-item:hover { background: var(--surface-hover); }
.theme-page-item.is-active { border-color: var(--accent-strong); background: var(--accent-soft); }
.theme-page-item .label { display: block; font-weight: 600; font-size: 13.5px; }
.theme-page-item .desc { display: block; color: var(--text-dim); font-size: 12px; }

.theme-element {
    display: flex; align-items: center; gap: 14px; padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.theme-element:last-child { border-bottom: none; }
.theme-element-info { flex: 1; min-width: 0; }
.theme-element-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.theme-element-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* 현재 적용 이미지 썸네일 — 워치 화면이 어두워 어두운 판 위에 올려 실제 느낌에 가깝게 본다. */
.theme-thumb {
    width: 64px; height: 64px; flex-shrink: 0; border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong); background: #0a0c10;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.theme-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.theme-thumb.is-changed { border-color: var(--accent-strong); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-thumb-empty { color: var(--text-faint); font-size: 11px; text-align: center; line-height: 1.35; }

/* [변경] 버튼 = label 로 감싼 파일 입력(즉시 제출) — 버튼 룩을 그대로 쓴다. */
.theme-file-btn { cursor: pointer; }
.theme-file-btn input[type="file"] { display: none; }

/* 화면(섹션) 카드 — 통이미지(실기기 캡처) + 누르면 요소 펼침(<details> 네이티브). */
.theme-sections { display: flex; flex-direction: column; gap: 10px; }
.theme-section {
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); overflow: hidden;
}
.theme-section[open] { border-color: var(--accent-strong); }
.theme-section-head {
    cursor: pointer; padding: 10px 12px; list-style: none;
    display: flex; gap: 14px; align-items: center;
}
.theme-section-head::-webkit-details-marker { display: none; }
.theme-section-head:hover { background: var(--surface-hover); }
.theme-shot {
    width: 96px; height: 96px; flex-shrink: 0; border-radius: 12px;
    border: 1px solid var(--line-strong); background: #0a0c10; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.theme-shot img { width: 100%; height: 100%; object-fit: cover; }
.theme-shot-empty { color: var(--text-faint); font-size: 10.5px; text-align: center; line-height: 1.4; }
.theme-section-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.theme-section-name { font-weight: 700; font-size: 14.5px; }
.theme-section-meta { color: var(--text-dim); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.theme-section-desc { color: var(--text-dim); font-size: 12px; }
.theme-section-hint { color: var(--text-faint); font-size: 11.5px; }
.theme-section[open] .theme-section-hint { display: none; }
.theme-section-body { padding: 2px 12px 8px; border-top: 1px solid var(--line-strong); }

/* 색 요소 — 현재 적용 색 스와치 + 컬러피커. */
.theme-swatch {
    display: block; width: 44px; height: 44px; border-radius: 8px;
    border: 1px solid var(--line-strong);
}
.theme-color-form { display: flex; align-items: center; gap: 6px; }
.theme-color-input {
    width: 40px; height: 30px; padding: 0; border: 1px solid var(--line-strong);
    border-radius: 6px; background: none; cursor: pointer;
}

/* 워치 미리보기(AdminPreview) — 도우미 진행바. 배지·버튼은 기존 .tag/.btn 재사용. */
.preview-progress-wrap { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.preview-progress {
    height: 10px; border-radius: 999px; overflow: hidden;
    background: var(--surface-hover); border: 1px solid var(--line-strong);
}
.preview-progress-fill {
    height: 100%; width: 0; border-radius: 999px;
    background: var(--accent); transition: width .4s ease;
}
.preview-progress-text { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; }

/* 워치 미리보기 — 실시간 화면(240x240, 360px 확대 표시). 클릭/드래그가 터치로 전달된다. */
.preview-screen-wrap { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.preview-screen-bezel {
    padding: 14px; border-radius: 28px;
    background: #16181d; border: 1px solid var(--line-strong);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.preview-screen {
    display: block; width: 360px; height: 360px;
    border-radius: 14px; background: #000;
    cursor: crosshair; touch-action: none; user-select: none;
}

/* 테마 편집 화면 우측(sticky aside, 400~520px 컬럼) 임베드 — 컬럼 폭에 맞춰 축소 표시 */
.theme-sim-panel .preview-screen-wrap { margin-top: 10px; }
.theme-sim-panel .preview-screen { width: 240px; height: 240px; }
.theme-sim-panel .preview-screen-bezel { padding: 10px; border-radius: 20px; }
.theme-sim-panel .panel + .panel { margin-top: 12px; }
