/* ==========================================================================
   세종국악 Admin Console — 디자인 토큰 + 레이아웃 + 컴포넌트
   ========================================================================== */
:root {
  --ink: #1A1614;
  --ink-soft: #2B2623;
  --hanji: #F6F1E8;
  --hanji-deep: #ECE4D1;
  --paper: #FBF8F2;
  --red: #B8342A;
  --red-dark: #8E2520;
  --red-soft: #F2D7D3;
  --blue: #1F4B44;
  --gold: #B8894B;
  --gold-soft: #EDE0C9;
  --stone-100: #E9E2D3;
  --stone-200: #C9C0AD;
  --stone-300: #8E8778;
  --stone-400: #5A544B;
  --success: #5F8A6B;
  --warning: #D49A3B;
  --danger: #B8342A;
  --border: rgba(26, 22, 20, 0.12);
  --border-strong: rgba(26, 22, 20, 0.88);
  --font-serif: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font-sans); background: var(--hanji); color: var(--ink); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ==========================================================================
   로그인 화면
   ========================================================================== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--ink); }
.login-card { background: var(--paper); padding: 56px 48px; max-width: 440px; width: 100%; border-top: 3px solid var(--red); }
.login-brand { text-align: center; margin-bottom: 40px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.login-brand h1 { font-family: var(--font-serif); font-weight: 800; font-size: 26px; margin: 0; letter-spacing: -0.01em; }
.login-brand .sub { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--stone-300); margin-top: 10px; }
.login-foot { font-size: 11px; color: var(--stone-400); line-height: 1.8; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ==========================================================================
   App Shell
   ========================================================================== */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar { background: var(--ink); color: var(--hanji); display: flex; flex-direction: column; padding: 24px 0; }
.sidebar .brand { padding: 0 20px 28px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid rgba(246,241,232,0.12); margin-bottom: 16px; }
.sidebar .brand-mark { width: 40px; height: 40px; background: var(--red); color: var(--hanji); display: flex; align-items: center; justify-content: center; font-family: var(--font-serif); font-weight: 800; font-size: 20px; }
.sidebar .brand-title { font-family: var(--font-serif); font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.sidebar .brand-sub { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em; color: rgba(246,241,232,0.55); text-transform: uppercase; margin-top: 3px; }

.sidebar .nav { display: flex; flex-direction: column; }
.sidebar .nav a { padding: 12px 20px; color: rgba(246,241,232,0.78); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 12px; transition: all 0.15s; border-left: 3px solid transparent; }
.sidebar .nav a:hover { background: rgba(246,241,232,0.06); color: var(--hanji); }
.sidebar .nav a.active { background: rgba(184,52,42,0.12); color: var(--hanji); border-left-color: var(--red); }
.sidebar .nav a i { font-size: 16px; opacity: 0.85; }
.sidebar .nav a .badge { margin-left: auto; background: var(--red); color: var(--hanji); font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.nav-divider { height: 1px; background: rgba(246,241,232,0.12); margin: 16px 20px; }

.sidebar-foot { margin-top: auto; padding: 20px; font-size: 11px; color: rgba(246,241,232,0.55); border-top: 1px solid rgba(246,241,232,0.12); }
.env-tag { display: inline-block; margin-top: 8px; padding: 3px 8px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; background: rgba(246,241,232,0.1); }
.env-tag.production { background: rgba(95,138,107,0.2); color: var(--success); }

/* ==========================================================================
   Main + Topbar
   ========================================================================== */
.main { display: flex; flex-direction: column; background: var(--hanji); min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 32px; background: var(--paper); border-bottom: 1px solid var(--border); }
.topbar h2 { font-family: var(--font-serif); font-weight: 700; font-size: 24px; margin: 0; letter-spacing: -0.015em; }
.topbar-actions { display: flex; gap: 8px; }

.content { padding: 32px; flex: 1; }

/* ==========================================================================
   컴포넌트
   ========================================================================== */

/* 폼 */
.fld { margin-bottom: 16px; }
.fld label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--stone-400); margin-bottom: 6px; }
.fld input, .fld textarea, .fld select { width: 100%; padding: 12px 14px; border: 1px solid var(--border); background: var(--paper); color: var(--ink); transition: border-color 0.15s; }
.fld input:focus, .fld textarea:focus, .fld select:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red); }
.fld textarea { resize: vertical; min-height: 120px; font-family: var(--font-mono); line-height: 1.7; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* 버튼 */
.btn-primary { background: var(--ink); color: var(--hanji); border: 0; padding: 13px 22px; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; transition: background 0.15s; }
.btn-primary:hover:not(:disabled) { background: var(--red); }
.btn-primary:disabled { background: var(--stone-300); cursor: not-allowed; }
.btn-primary.w-full { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); padding: 11px 20px; font-size: 13px; font-weight: 600; }
.btn-ghost:hover { background: var(--ink); color: var(--hanji); }
.btn-danger { background: var(--red); color: var(--hanji); border: 0; padding: 9px 16px; font-size: 12px; font-weight: 600; }
.btn-danger:hover { background: var(--red-dark); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-icon { padding: 8px 10px; }

/* 카드 */
.card { background: var(--paper); border: 1px solid var(--border); padding: 24px; }
.card-title { font-family: var(--font-serif); font-weight: 700; font-size: 18px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

/* 통계 그리드 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--paper); border: 1px solid var(--border); padding: 22px 24px; position: relative; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--red); }
.stat-card.gold::before { background: var(--gold); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.success::before { background: var(--success); }
.stat-card .label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--stone-400); margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-serif); font-weight: 800; font-size: 36px; line-height: 1; letter-spacing: -0.02em; }
.stat-card .sub { font-size: 12px; color: var(--stone-400); margin-top: 6px; }

/* 테이블 */
.table-wrap { background: var(--paper); border: 1px solid var(--border); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 14px 16px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--stone-400); border-bottom: 2px solid var(--border); font-weight: 700; background: var(--hanji-deep); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table tr:hover td { background: rgba(184,137,75,0.04); }
.table tr.unread td { background: rgba(184,52,42,0.03); }
.table tr.unread td:first-child::before { content: '●'; color: var(--red); margin-right: 8px; }
.table .ellipsis { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table .cell-link { cursor: pointer; color: var(--ink); font-weight: 500; }
.table .cell-link:hover { color: var(--red); text-decoration: underline; }

/* 배지 */
.badge-status { display: inline-block; padding: 3px 9px; font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.badge-status.new { background: var(--red); color: var(--hanji); }
.badge-status.in_progress { background: var(--gold); color: var(--ink); }
.badge-status.resolved { background: var(--success); color: var(--hanji); }
.badge-status.spam { background: var(--stone-400); color: var(--hanji); }
.badge-status.archived { background: var(--stone-200); color: var(--ink); }
.badge-status.draft { background: var(--stone-300); color: var(--hanji); }
.badge-status.published { background: var(--success); color: var(--hanji); }
.badge-status.scheduled { background: var(--blue); color: var(--hanji); }
.badge-status.ongoing { background: var(--red); color: var(--hanji); }
.badge-status.completed { background: var(--stone-300); color: var(--hanji); }
.badge-status.cancelled { background: var(--stone-400); color: var(--hanji); text-decoration: line-through; }

/* 필터 바 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--border); }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid var(--border); background: var(--hanji); font-size: 12px; }
.filter-bar .chip { padding: 6px 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; border: 1px solid var(--border); background: transparent; color: var(--ink); }
.filter-bar .chip.active { background: var(--ink); color: var(--hanji); border-color: var(--ink); }
.filter-bar .grow { flex: 1; }

/* 페이지네이션 */
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 12px 0; font-family: var(--font-mono); font-size: 11px; color: var(--stone-400); }
.pager button { background: transparent; border: 1px solid var(--border); padding: 8px 14px; font-size: 11px; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

/* 에러·피드백 */
.form-error { background: var(--red-soft); color: var(--red-dark); padding: 12px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px; border-left: 3px solid var(--red); }
.form-success { background: rgba(95,138,107,0.15); color: var(--success); padding: 12px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px; border-left: 3px solid var(--success); }

/* Empty state */
.empty { text-align: center; padding: 64px 24px; color: var(--stone-400); }
.empty .icon { font-size: 48px; color: var(--stone-200); margin-bottom: 12px; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--stone-400); }
.loading i { animation: spin 1s linear infinite; font-size: 24px; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 모달 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(26,22,20,0.72); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100; animation: fadeIn 0.15s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--paper); max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto; animation: slideUp 0.2s cubic-bezier(0.2, 0.6, 0.2, 1); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-family: var(--font-serif); font-weight: 700; font-size: 18px; margin: 0; }
.modal-close { background: transparent; border: 0; font-size: 22px; color: var(--stone-400); padding: 4px 8px; cursor: pointer; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--hanji-deep); }

/* Toast */
.toast-host { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--hanji); padding: 12px 18px; font-size: 13px; font-weight: 600; border-left: 3px solid var(--success); box-shadow: 0 4px 16px rgba(0,0,0,0.2); animation: slideRight 0.2s; max-width: 400px; }
@keyframes slideRight { from { transform: translateX(20px); opacity: 0; } }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--gold); }

/* Detail view 레이아웃 */
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
.detail-main { background: var(--paper); border: 1px solid var(--border); padding: 28px 32px; }
.detail-side { display: flex; flex-direction: column; gap: 16px; }
.detail-field { padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-field:last-child { border-bottom: 0; }
.detail-field .label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--stone-400); margin-bottom: 4px; }
.detail-field .value { font-size: 14px; line-height: 1.7; word-break: break-word; }
.detail-field.big .value { font-family: var(--font-serif); font-weight: 700; font-size: 20px; }

/* 반응형 */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
  .sidebar { flex-direction: row; padding: 8px 16px; }
  .sidebar .brand { border-bottom: 0; padding: 0; margin: 0 16px 0 0; }
  .sidebar .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .sidebar .nav a { padding: 10px 14px; border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar .nav a.active { border-bottom-color: var(--red); border-left: 0; }
  .sidebar .nav-divider, .sidebar-foot { display: none; }
  .content { padding: 20px 16px; }
  .topbar { padding: 14px 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
