/* =========================================================
   가방 현장용어 사전 - 관리자·로그인 화면 스타일
   공통 기준(색·글꼴·헤더·버튼)은 base.css 에 있습니다.
   ========================================================= */

/* ---------- 입력 요소 (관리자·로그인 공용) ---------- */

.btn-sm {
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    justify-content: center;
    height: 46px;
    font-size: 15px;
}

.field {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}

.field + .field {
    margin-top: 22px;
}

.field-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.req,
.opt {
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.req {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.opt {
    background: var(--surface-2);
    color: var(--text-muted);
}

.input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-ctl);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.input[aria-invalid="true"] {
    border-color: var(--danger);
}

.input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgb(180 35 24 / 0.2);
}

textarea.input {
    min-height: 150px;
    resize: vertical;
}

input[type="search"].input::-webkit-search-cancel-button {
    cursor: pointer;
}

.field-help {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-muted);
}

.field-error {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--danger);
}

.field-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.field-note .icon {
    margin-top: 1px;
    color: var(--text-muted);
}

/* ---------- 로그인 ---------- */

.login {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.login-card {
    width: min(100%, 400px);
    padding: 32px 28px 24px;
    border: 1px solid var(--line);
    border-radius: var(--r-box);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.login-title {
    margin-top: 28px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-sub {
    margin-top: 6px;
    font-size: 15px;
    color: var(--text-muted);
}

.login-notice {
    margin-top: 18px;
    padding: 10px 12px;
    border-radius: var(--r-ctl);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 14px;
    font-weight: 600;
}

#loginForm {
    margin-top: 24px;
}

#loginForm .btn-block {
    margin-top: 20px;
}

.password-wrap {
    position: relative;
}

.password-wrap .input {
    padding-right: 48px;
}

.pw-toggle {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.back-link {
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    border-radius: var(--r-ctl);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover {
    color: var(--text);
}

/* ---------- 관리자 레이아웃 ---------- */

.brand-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

/* 헤더 폭을 아래 작업 영역과 맞춥니다 */
.admin-page .topbar-inner {
    max-width: 1440px;
}

/* 로그인 확인 전에는 내용을 보이지 않게 합니다 */
.is-auth-pending .admin-layout {
    visibility: hidden;
}

.admin-layout {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px 40px;
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.admin-alert {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r-ctl);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.55;
}

.admin-alert .icon {
    margin-top: 1px;
}

.admin-alert code {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
}

.pane-title {
    font-size: 17px;
    font-weight: 700;
}

/* ---------- 목록 ---------- */

.list-pane {
    position: sticky;
    top: calc(var(--header-h) + 20px);
    max-height: calc(100dvh - var(--header-h) - 40px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--r-box);
    background: var(--surface);
    overflow: hidden;
}

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px 20px;
}

.list-search {
    position: relative;
    margin: 0 16px;
}

.list-search .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.list-search .input {
    min-height: 42px;
    padding-left: 40px;
    font-size: 15px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.filter-chip:hover {
    border-color: var(--line-strong);
}

.filter-chip .c {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.filter-chip[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.filter-chip[aria-pressed="true"] .c {
    color: var(--accent-text);
}

.list-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 8px 16px;
}

.list-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 12px 12px 6px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.row {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--r-ctl);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s;
}

.row:hover {
    background: var(--surface-2);
}

.row[aria-current="true"] {
    background: var(--accent-soft);
}

.row[aria-current="true"] .row-term {
    color: var(--accent-text);
}

.num-badge.is-none {
    background: transparent;
    border: 1.5px dashed var(--line-strong);
}

.row-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.row-term,
.row-std {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-term {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
}

.row-std {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted);
}

.row-flag {
    flex: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.row-thumb {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: calc(var(--r-ctl) - 4px);
    object-fit: cover;
    background: var(--surface-2);
}

.list-empty {
    padding: 20px 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.list-empty strong {
    display: block;
    margin-bottom: 2px;
    color: var(--text);
    font-size: 15px;
}

.list-empty .btn {
    margin-top: 12px;
}

.state-error {
    margin: 12px 4px;
    padding: 16px;
    border-radius: var(--r-ctl);
    background: var(--danger-soft);
    color: var(--danger);
}

.state-error-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.state-error p {
    margin: 4px 0 14px;
    font-size: 14px;
}

/* ---------- 편집 영역 ---------- */

.editor {
    border: 1px solid var(--line);
    border-radius: var(--r-box);
    background: var(--surface);
}

.editor:focus {
    outline: none;
}

.editor.is-editing {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.editor-head {
    padding: 20px 24px 0;
}

.editor-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.editor-meta {
    margin-top: 2px;
    font-size: 14px;
    color: var(--text-muted);
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 1fr);
    gap: 28px;
    padding: 20px 24px 24px;
    align-items: start;
}

/* 위치 고르기 */
.picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.picker > .field-label {
    margin-bottom: 10px;
}

.picker-views {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.seg {
    position: relative;
}

.seg input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.seg span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    transition: border-color 0.15s, background-color 0.15s;
}

.seg:hover span {
    border-color: var(--line-strong);
}

.seg-count {
    font-style: normal;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.seg input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.seg input:checked + span .seg-count {
    color: var(--accent-text);
}

.seg input:focus-visible + span {
    outline: 3px solid var(--accent-ink);
    outline-offset: 2px;
}

.picker-stage {
    --stage-h: clamp(300px, calc(100dvh - 330px), 640px);
    display: flex;
    justify-content: center;
    border-radius: var(--r-box);
    background: var(--surface-2);
}

/* 좌표(%)는 사진 크기 기준이므로 frame 은 사진과 정확히 같은 크기여야 합니다 */
.picker-frame {
    --ar: 1.0625;
    position: relative;
    width: min(100%, calc(var(--stage-h) * var(--ar)));
    aspect-ratio: var(--ar);
    border-radius: var(--r-box);
    cursor: crosshair;
    -webkit-user-select: none;
    user-select: none;
}

.picker-frame img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    pointer-events: none;
    -webkit-user-drag: none;
}

.ctx-pins {
    position: absolute;
    inset: 0;
}

.ctx-pin {
    position: absolute;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    display: grid;
    place-items: center;
    border: 1.5px solid rgb(22 24 29 / 0.5);
    border-radius: 50%;
    background: rgb(252 252 253 / 0.88);
    color: #16181d;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.ctx-tip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    padding: 3px 8px;
    border-radius: 6px;
    background: rgb(17 19 24 / 0.92);
    color: #f4f5f7;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.ctx-pin:hover {
    z-index: 2;
}

.ctx-pin:hover .ctx-tip {
    opacity: 1;
}

.marker {
    position: absolute;
    z-index: 3;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    padding: 0;
    border: 3px solid #fcfcfd;
    border-radius: 50%;
    background: var(--pin);
    box-shadow: 0 0 0 4px rgb(42 82 201 / 0.35), 0 2px 8px rgb(10 12 16 / 0.45);
    cursor: grab;
    touch-action: none;
}

/* 가운데 점이 실제 저장되는 위치입니다 */
.marker::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: #fcfcfd;
}

.marker.is-dragging {
    cursor: grabbing;
}

.marker:focus-visible {
    outline: 3px solid #fcfcfd;
    outline-offset: 3px;
}

.picker-foot {
    min-height: 34px;
    margin: 10px 0 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.picker-coords {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.picker-coords.is-empty {
    color: var(--text-muted);
    font-weight: 500;
}

/* 입력 칸 */
.fields {
    min-width: 0;
}

.upload {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-box);
    transition: border-color 0.15s, background-color 0.15s;
}

.upload.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-thumb {
    width: 84px;
    height: 84px;
    flex: none;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: calc(var(--r-box) - 6px);
    background: var(--surface-2);
    color: var(--text-muted);
}

.upload-thumb .icon {
    width: 28px;
    height: 28px;
}

.upload-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-body {
    min-width: 0;
    flex: 1;
}

.upload-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
}

.upload-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.upload-actions {
    position: relative;
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.file-input:focus-visible + label {
    outline: 3px solid var(--accent-ink);
    outline-offset: 2px;
}

/* 저장 바: 편집 영역이 길어도 항상 화면 아래에 보입니다 */
.editor-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    border-radius: 0 0 var(--r-box) var(--r-box);
    background: var(--surface);
}

.editor-status {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.editor-status.is-dirty {
    color: var(--text);
}

/* ---------- 알림·확인 창 ---------- */

.toast-region {
    position: fixed;
    z-index: 50;
    left: 50%;
    bottom: 92px;
    transform: translateX(-50%);
    width: min(440px, calc(100vw - 32px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-ctl);
    background: #1f232b;
    color: #f4f5f7;
    box-shadow: 0 16px 40px -12px rgb(10 12 16 / 0.5);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    pointer-events: auto;
}

.toast .icon {
    margin-top: 1px;
    color: #8fe0b5;
}

.toast.is-error .icon {
    color: #ff9b8f;
}

.toast.is-warn .icon {
    color: #ffd27a;
}

.toast.is-leaving {
    opacity: 0;
    transition: opacity 0.2s;
}

.confirm {
    width: min(420px, calc(100vw - 32px));
    padding: 24px;
    border: 0;
    border-radius: var(--r-box);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

.confirm::backdrop {
    background: rgb(10 12 16 / 0.5);
}

.confirm-title {
    font-size: 18px;
    font-weight: 700;
}

.confirm-body {
    margin-top: 8px;
    font-size: 15px;
    color: var(--text-muted);
}

.pw-fields {
    margin-top: 20px;
}

.pw-dialog .field + .field {
    margin-top: 16px;
}

.pw-form-error {
    margin-top: 14px;
}

.confirm-actions {
    margin-top: 22px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- 움직임 ---------- */

@media (prefers-reduced-motion: no-preference) {
    .toast {
        animation: toast-in 0.22s var(--ease) both;
    }

    .row.is-flash {
        animation: row-flash 1.8s ease-out;
    }

    .confirm[open] {
        animation: toast-in 0.18s var(--ease) both;
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes row-flash {
    0%,
    30% {
        background: var(--accent-soft);
    }
}

/* ---------- 반응형 ---------- */

@media (max-width: 1280px) {
    .editor-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .picker-stage {
        --stage-h: clamp(300px, 58dvh, 600px);
    }
}

@media (max-width: 959.98px) {
    .admin-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 8px 16px 24px;
    }

    .list-pane {
        position: static;
        max-height: min(60dvh, 560px);
    }

    .editor-head {
        padding: 18px 16px 0;
    }

    .editor-grid {
        padding: 16px 16px 20px;
    }

    .editor-bar {
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .editor-status {
        display: none;
    }

    .editor-bar #resetBtn {
        margin-left: auto;
    }

    .toast-region {
        bottom: calc(84px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 560px) {
    .brand-tag {
        display: none;
    }

    /* 좁은 화면에서는 헤더 링크를 아이콘만 보이게 합니다 (읽어 주는 이름은 유지) */
    .admin-page .topbar-inner {
        flex-wrap: nowrap;
    }

    .admin-page .top-link {
        position: relative;
        padding: 10px;
    }

    .admin-page .top-link span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .login-card {
        padding: 28px 20px 20px;
    }
}
