/* ==========================================================
   GKMCN 대시보드 스타일 (메인 사이트 site.css 톤 유지)
   ========================================================== */

:root {
    --bg: #09090b;
    --bg-2: #111114;
    --bg-3: #18181c;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --dim: #71717a;
    --accent: #6469ff;
    --accent-soft: rgba(100, 105, 255, 0.14);
    --danger: #ff4d6d;
    --danger-soft: rgba(255, 77, 109, 0.14);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --radius: 16px;
    --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: -0.01em;
    word-break: keep-all;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
form { margin: 0; }

/* ---------------- 버튼 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    transition: background .2s, border-color .2s;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7479ff; }
.btn-ghost { border-color: var(--line-2); background: rgba(255,255,255,.03); }
.btn-ghost:hover { border-color: rgba(255,255,255,.35); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 77, 109, .24); }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-xs { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------- 폼 ---------------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form input,
.form select {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line-2);
    border-radius: 12px;
    background: var(--bg-3);
    color: var(--text);
    font: inherit;
    font-size: 15px;
}
.form input:focus,
.form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { grid-template-columns: repeat(4, 1fr) auto; align-items: end; }

/* ---------------- 알림 ---------------- */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 14px; margin-bottom: 20px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }

/* ---------------- 로그인 ---------------- */
.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: radial-gradient(ellipse at top, rgba(100, 105, 255, .18), transparent 60%), var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 40px 32px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--bg-2);
}
.auth-logo img { width: 120px; margin: 0 auto 12px; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.auth .btn { margin-top: 8px; }

/* ---------------- 레이아웃 ---------------- */
.dash { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.dash-side {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 28px 18px;
    border-right: 1px solid var(--line);
    background: var(--bg-2);
}
.dash-logo { display: flex; align-items: center; gap: 10px; padding: 0 10px 28px; }
.dash-logo img { width: 84px; }
.dash-logo span { font-size: 12px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.dash-nav { display: grid; gap: 4px; }
.dash-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
}
.dash-nav a:hover { background: rgba(255,255,255,.04); color: var(--text); }
.dash-nav a.is-active { background: var(--accent-soft); color: var(--text); }
.dash-nav i { font-size: 18px; }
.dash-me { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--line); }
.dash-me-name { font-weight: 700; }
.dash-me-id { font-size: 12px; color: var(--dim); margin-bottom: 12px; }

.dash-main { padding: 40px; min-width: 0; }
.dash-title { margin: 0 0 24px; font-size: 26px; letter-spacing: -0.02em; }
.dash-lead { margin: -12px 0 24px; color: var(--muted); }

/* ---------------- 카드 / 패널 ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card {
    display: block;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-2);
}
.card-link:hover { border-color: var(--line-2); }
.card-label { font-size: 13px; color: var(--dim); font-weight: 600; }
.card-value { margin-top: 6px; font-size: 26px; font-weight: 800; }
.card-value-sm { font-size: 16px; font-weight: 700; }
.card-meta { margin-top: 4px; font-size: 13px; color: var(--muted); }

.panel {
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-2);
}
.panel-title { margin: 0 0 18px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); color: var(--muted); }

/* ---------------- 테이블 ---------------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--dim);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.table .muted { color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-admin { background: var(--accent-soft); color: #a5a8ff; }
.badge-user { background: var(--bg-3); color: var(--muted); }

.small { font-size: 13px; }
.muted { color: var(--muted); }
.push { margin-left: auto; }

/* ---------------- 연동 / 나이트봇 ---------------- */
.connect { text-align: center; padding: 48px 24px; }
.connect .panel-title { justify-content: center; }
.connect p { margin: 0 0 24px; }
.connect-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--accent-soft);
    color: #a5a8ff;
    font-size: 30px;
}
.link-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.link-status { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.table .msg { white-space: normal; min-width: 220px; max-width: 420px; color: var(--muted); word-break: break-all; }
.table .empty { text-align: center; color: var(--dim); padding: 28px 12px; }
.table .empty.error { color: var(--danger); }

.form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line-2);
    border-radius: 12px;
    background: var(--bg-3);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    resize: vertical;
}
.form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form [hidden] { display: none; }

.modal {
    width: min(480px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    background: var(--bg-2);
    color: var(--text);
}
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line-2); transition: background .2s; }
.switch span::before { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); background: #fff; }

/* ---------------- 쪽지 (messages.js) ---------------- */
.unread {
    min-width: 20px;
    padding: 0 6px;
    margin-left: auto;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
}
.dim { color: var(--dim); }
.inbox { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.inbox .panel { margin-bottom: 0; }
.inbox-list { padding: 18px 10px; max-height: calc(100vh - 140px); overflow-y: auto; }
.inbox-list .panel-title { padding: 0 10px; }
.inbox-item { display: block; padding: 10px; border-radius: 10px; }
.inbox-item:hover { background: rgba(255,255,255,.04); }
.inbox-item.is-active { background: var(--accent-soft); }
.inbox-item-top { display: flex; align-items: center; gap: 8px; }
.inbox-item-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 420px; overflow: hidden; }
.chat-placeholder { justify-content: center; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.chat-back { display: none; font-size: 20px; color: var(--muted); }
.chat-label { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: #a5a8ff; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { margin: auto; color: var(--dim); font-size: 14px; text-align: center; }
.chat-empty.error { color: var(--danger); }
.bubble { max-width: min(75%, 520px); }
.bubble-text { padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; word-break: break-word; }
.bubble-meta { font-size: 11px; color: var(--dim); margin-top: 4px; padding: 0 4px; }
.bubble-other { align-self: flex-start; }
.bubble-other .bubble-text { background: var(--bg-3); border-top-left-radius: 4px; }
.bubble-mine { align-self: flex-end; text-align: right; }
.bubble-mine .bubble-text { background: var(--accent); color: #fff; border-top-right-radius: 4px; text-align: left; }
.chat-form { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat-form textarea {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--line-2);
    border-radius: 12px;
    background: var(--bg-3);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-form .btn { height: auto; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------------- 반응형 ---------------- */
@media (max-width: 960px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .btn { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .dash { grid-template-columns: 1fr; }
    .dash-side {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 14px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .dash-logo { padding: 0; margin-right: auto; }
    .dash-logo span { display: none; }
    .dash-nav { order: 4; width: 100%; grid-auto-flow: column; justify-content: start; overflow-x: auto; }
    .dash-nav a { padding: 8px 10px; font-size: 14px; white-space: nowrap; }
    .form-row { grid-template-columns: 1fr; }
    .inbox { grid-template-columns: 1fr; }
    .inbox-list { max-height: none; }
    .inbox.has-thread .inbox-list,
    .inbox:not(.has-thread) .chat-placeholder { display: none; }
    .chat { height: calc(100vh - 180px); }
    .chat-back { display: block; }
    .bubble { max-width: 88%; }
    .dash-me { order: 3; width: 100%; margin: 0; padding: 10px 0 0; display: flex; align-items: center; gap: 10px; }
    .dash-me-name { font-size: 14px; }
    .dash-me-id { margin: 0 auto 0 0; }
    .dash-me .btn-block { width: auto; }
    .dash-main { padding: 24px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .table-wrap { margin: 0 -24px; }
}
.inbox-list .panel-title + .inbox-item { margin-top: -6px; }
.inbox-list .inbox-item + .panel-title { margin-top: 18px; }
