/* Baikal News CMS Admin Dashboard Style */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;600;700&display=swap');

:root {
  /* 바이칼 테마 메인 컬러 4종 */
  --color-blue-deep: #0f4c81;      /* Deep Baikal Blue (1) */
  --color-blue-light: #4ea8de;     /* Light Ice/Sky Blue (2) */
  --color-green-deep: #0d7a66;     /* Deep Emerald Green (3) */
  --color-green-light: #48c2a5;    /* Mint Teal Green (4) */

  /* 라이트모드 전용으로 변수 변경 */
  --admin-bg-body: #f4f7fa;        /* Light Ice Blue tinted grey-white */
  --admin-bg-panel: #ffffff;       /* Pure White for cards and panels */
  --admin-bg-input: #f1f5f9;       /* Slate 100 for input fields */
  --admin-border: #e2e8f0;         /* Slate 200 */
  --admin-border-light: #f1f5f9;   /* Slate 100 */
  
  --admin-text-primary: #0f172a;   /* Slate 900 */
  --admin-text-secondary: #475569; /* Slate 600 */
  --admin-text-muted: #94a3b8;     /* Slate 400 */
  
  --admin-accent-cyan: var(--color-green-light);    /* Mint Green */
  --admin-accent-blue: var(--color-blue-deep);      /* Deep Blue */
  --admin-accent-blue-hover: #0a365c;
  
  /* Status Colors */
  --status-draft: #64748b;         /* Gray */
  --status-review: #d97706;        /* Darker Yellow/Amber for visibility on light bg */
  --status-approved: var(--color-green-deep);
  --status-scheduled: #7c3aed;      /* Purple - approved but not yet live */
  --status-published: var(--color-blue-light);
  --status-archived: #94a3b8;      /* Slate */
  --status-rejected: #ef4444;      /* Red */
  --status-correction: #ea580c;     /* Orange - live but flagged for a correction notice */
  
  --font-sans: 'Inter', 'Noto Sans KR', sans-serif;
  --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 16px;           /* Large rounded corners like Jobie image */
  --border-radius-sm: 8px;

  /* Premium soft shadows for light mode panels */
  --box-shadow-soft: 0 10px 30px rgba(15, 76, 129, 0.03), 0 1px 3px rgba(15, 76, 129, 0.01);
  --box-shadow-hover: 0 20px 40px rgba(15, 76, 129, 0.07), 0 2px 8px rgba(15, 76, 129, 0.02);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--admin-bg-body);
  color: var(--admin-text-primary);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  /* 기본값(word-break: normal)은 한글 단어 중간(글자와 글자 사이)에서도
     줄바꿈을 허용해서, 좁은 화면에서 "예약"이 "예"/"약"으로, "번호"가
     "번"/"호"로 쪼개지는 등 지저분하게 보였다. keep-all은 상속되는
     속성이라 여기 한 번만 지정해도 관리자 페이지 전체(표 헤더, 패널
     제목 등)에 적용된다 -- 띄어쓰기 없는 한글 단어는 절대 쪼개지지 않고,
     띄어쓰기가 있는 지점에서만 줄바꿈된다. */
  word-break: keep-all;
}

/* #admin-app wraps the sidebar + main content so it can be hidden behind
   the login screen; it must still behave like body's old flex row did. */
#admin-app {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar Navigation */
.admin-sidebar {
  width: 260px;
  background-color: #0b1a30; /* Dark Baikal Blue background */
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--admin-border);
  text-align: center;
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--admin-accent-cyan);
}

.sidebar-sub {
  font-size: 0.72rem;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 4px;
}

.sidebar-menu {
  list-style: none;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 30px; /* Rounded pill style */
  transition: var(--transition-fast);
  cursor: pointer;
}

.sidebar-item a:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-item.active a {
  background: linear-gradient(135deg, var(--color-green-light), var(--color-green-deep));
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(13, 122, 102, 0.35);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--admin-border);
  font-size: 0.75rem;
  color: var(--admin-text-muted);
}

/* Main Layout Area */
.admin-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  height: 70px;
  background-color: var(--admin-bg-panel);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-title-area h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.profile-role-tag {
  background-color: var(--admin-border);
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 2px;
  color: var(--admin-accent-cyan);
}

.profile-name {
  font-weight: 500;
}

/* Content wrapper */
.admin-content {
  padding: 40px;
  flex: 1;
}

/* Dashboard Widgets & Cards */
.admin-grid-4 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

/* 3-stat-card variant (subscribers, expenses) -- a class instead of an
   inline grid-template-columns override so the existing
   "@media (max-width:768px) .admin-grid-4 { grid-template-columns: 1fr }"
   rule can still collapse it on mobile. An inline style would win over
   that rule regardless of screen width and force 3 cramped columns on a
   phone. */
.stat-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.stat-card {
  border: none;
  border-radius: var(--border-radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: var(--transition-fast);
  box-shadow: var(--box-shadow-soft);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--box-shadow-hover);
}

.stat-card:nth-child(1) {
  background: linear-gradient(135deg, var(--color-blue-deep), #155e95);
}

.stat-card:nth-child(2) {
  background: linear-gradient(135deg, var(--color-blue-light), #6cc3f5);
}

.stat-card:nth-child(3) {
  background: linear-gradient(135deg, var(--color-green-deep), #129980);
}

.stat-card:nth-child(4) {
  background: linear-gradient(135deg, var(--color-green-light), #72e0c7);
}

.stat-card:nth-child(5) {
  background: linear-gradient(135deg, #b8860b, #e0c25e);
}

.stat-card:nth-child(6) {
  background: linear-gradient(135deg, #6d28d9, #a78bfa);
}

.stat-card:nth-child(7) {
  background: linear-gradient(135deg, #be185d, #f472b6);
}

.stat-card:nth-child(n) .stat-title {
  color: rgba(255, 255, 255, 0.8) !important;
}

.stat-card:nth-child(n) .stat-number {
  color: #ffffff !important;
}

.stat-card:nth-child(n) .stat-trend {
  color: rgba(255, 255, 255, 0.95) !important;
}

.stat-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--admin-text-primary);
  line-height: 1;
}

.stat-trend {
  font-size: 0.75rem;
  margin-top: 10px;
  color: var(--admin-text-secondary);
}

/* General Admin Panel Components */
.panel {
  background-color: var(--admin-bg-panel);
  border: 1px solid var(--admin-border-light);
  border-radius: var(--border-radius);
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--box-shadow-soft);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--admin-border);
  padding-bottom: 16px;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================= 숏폼 자동 생성 -- editorial redesign =================
   Scoped entirely under .shorts-editorial so no other admin tab is
   affected: warm paper surface, serif headings, small-caps STEP kickers,
   collapsible sections with a rotating chevron, and card-style cut rows. */
.shorts-editorial {
  --sf-bg: #f3f2f2;
  --sf-surface: #eae9e9;
  --sf-surface-2: #ffffff;
  --sf-text: #201e1d;
  --sf-text-muted: rgba(32, 30, 29, 0.6);
  --sf-accent: #0088b0;
  --sf-accent-700: #006786;
  --sf-accent-100: #e9f8ff;
  --sf-accent-2: #d6006c;
  --sf-accent-2-700: #aa0b56;
  --sf-accent-2-100: #fff1f4;
  --sf-divider: rgba(32, 30, 29, 0.14);
  --sf-heading-font: 'Noto Serif KR', 'Source Serif 4', Georgia, serif;
  --sf-body-font: 'Inter', 'Noto Sans KR', sans-serif;
  background: var(--sf-bg);
  color: var(--sf-text);
  font-family: var(--sf-body-font);
  border-radius: 14px;
  padding: 28px !important;
}
.shorts-editorial .panel-header { margin-bottom: 4px; }
.shorts-editorial .panel-title {
  font-family: var(--sf-heading-font);
  font-weight: 600;
  color: var(--sf-text);
}
.shorts-editorial .help-text { color: var(--sf-text-muted); }
.shorts-editorial .ai-api-config-panel {
  background: var(--sf-surface-2) !important;
  border-color: var(--sf-divider) !important;
  border-radius: 8px !important;
}
.shorts-editorial label { color: var(--sf-text); }
.shorts-editorial .form-control-admin {
  background: var(--sf-surface-2);
  border: 1px solid var(--sf-divider);
  color: var(--sf-text);
}
.shorts-editorial .form-control-admin:focus {
  border-color: var(--sf-accent);
  outline: none;
}

/* Buttons, retinted to the editorial palette (shorts wizard only) */
.shorts-editorial .btn-admin {
  border-radius: 5px;
  box-shadow: none;
  font-family: var(--sf-body-font);
}
.shorts-editorial .btn-admin-primary { background: var(--sf-accent); color: #fff; }
.shorts-editorial .btn-admin-primary:hover { background: var(--sf-accent-700); }
.shorts-editorial .btn-admin-success { background: var(--sf-accent-700); color: #fff; }
.shorts-editorial .btn-admin-secondary {
  background: transparent;
  border: 1px solid var(--sf-divider);
  color: var(--sf-text);
}
.shorts-editorial .btn-admin-secondary:hover { background: rgba(32, 30, 29, 0.06); }
.shorts-editorial .btn-admin-danger {
  background: transparent;
  border: 1px solid var(--sf-accent-2-100);
  color: var(--sf-accent-2-700);
}

/* Shared large size for the consequential end-of-pipeline actions --
   녹화 (captures the whole ~30s timeline), mp4 변환, and 영상 다운로드 --
   deliberately bigger/louder than their neighbors instead of blending in. */
.shorts-editorial .shorts-lg-btn {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 16px 32px;
  border-radius: 8px;
}
.shorts-editorial .shorts-lg-btn.shorts-btn-orange {
  background: #f97316;
  color: #fff;
}
.shorts-editorial .shorts-lg-btn.shorts-btn-orange:hover {
  background: #ea580c;
}
.shorts-editorial .shorts-lg-btn.shorts-btn-blue {
  background: var(--sf-accent);
  color: #fff;
}
.shorts-editorial .shorts-lg-btn.shorts-btn-blue:hover {
  background: var(--sf-accent-700);
}

/* Collapsible STEP sections */
.shorts-step { border-top: 1px solid var(--sf-divider); margin-top: 6px; }
.shorts-step:first-of-type { border-top: none; margin-top: 0; }
.shorts-step-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  cursor: pointer;
  padding: 22px 2px 10px;
  user-select: none;
}
.shorts-step-kicker {
  font-family: var(--sf-body-font);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sf-accent-700);
  flex-shrink: 0;
}
.shorts-step-heading {
  font-family: var(--sf-heading-font);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--sf-text);
  flex: 1;
  margin: 0;
}
.shorts-step-meta {
  font-size: 0.78rem;
  color: var(--sf-text-muted);
  flex-shrink: 0;
}
.shorts-step-chevron {
  color: var(--sf-accent-700);
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  transform: rotate(180deg);
}
.shorts-step-header.is-collapsed .shorts-step-chevron { transform: rotate(0deg); }
.shorts-step-body { padding: 4px 2px 24px; }
.shorts-step-body.is-collapsed { display: none; }

/* Cards */
.shorts-card {
  background: var(--sf-surface);
  border-radius: 8px;
  padding: 16px;
}
.shorts-card + .shorts-card { margin-top: 12px; }
.shorts-card-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--sf-accent-700);
  text-transform: uppercase;
}

/* Cut cards (step 2) */
.shorts-cut-row {
  background: var(--sf-surface-2);
  border: 1px solid var(--sf-divider);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.shorts-cut-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.shorts-cut-row-actions { display: flex; gap: 6px; }
.shorts-ghost-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sf-body-font);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--sf-accent-700);
}
.shorts-ghost-btn:hover { background: rgba(32, 30, 29, 0.06); }
.shorts-ghost-btn-danger { color: var(--sf-accent-2-700); }
.shorts-field-label {
  font-size: 0.72rem;
  color: var(--sf-text-muted);
  display: block;
  margin-bottom: 3px;
}

/* Media thumbnail grid (step 3) -- every cell is a uniform 9:16 box so a
   wider front-video thumbnail can never bleed into the next column. */
.shorts-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}
.shorts-media-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}
.shorts-media-thumb video,
.shorts-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.shorts-media-thumb-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0));
}
.shorts-media-thumb-actions button,
.shorts-media-thumb-actions a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}
.shorts-media-thumb-actions button:hover,
.shorts-media-thumb-actions a:hover {
  background: rgba(255,255,255,0.3);
}
.shorts-media-thumb-actions .shorts-media-thumb-delete:hover {
  background: rgba(220,53,69,0.8);
}

/* Narration playback, styled like a real audio player -- only shown once
   narration actually exists (toggled via JS), with a live current/total
   time readout so the admin can judge whether 재생 속도 needs to go
   higher before it overlaps/cuts off, instead of guessing. */
.shorts-narration-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sf-surface-2, var(--admin-bg-secondary));
  border: 1px solid var(--sf-divider, var(--admin-border));
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
}
.shorts-narration-player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--sf-accent, var(--admin-accent-cyan));
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}
.shorts-narration-player-btn:hover {
  filter: brightness(1.1);
}
.shorts-narration-player-time {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--sf-text-muted, var(--admin-text-secondary));
  white-space: nowrap;
}

/* Generation/recording status text was the same tiny .help-text size as
   every other hint on the page, easy to miss -- exactly the kind of miss
   that led to repeat clicks on a paid Veo generation. Bigger and bolder,
   in the accent color, so "아직 진행 중" reads as a warning, not a footnote. */
#shorts-media-status,
#shorts-assembly-status {
  font-size: 1rem !important;
  font-weight: 700 !important;
  color: var(--sf-accent, var(--admin-accent-cyan)) !important;
}

/* Impossible-to-miss indicator while ANY shorts generation/recording is
   running (Veo, images, narration, recording) -- fixed to the viewport so
   it stays visible no matter where the admin has scrolled to, tied
   directly to the shortsBusyOperations counter that already guards
   against an accidental refresh mid-generation. */
.shorts-busy-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 12px;
  background: #0b1a30;
  color: #fff;
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
}
.shorts-busy-banner.is-active {
  display: flex;
}
.shorts-busy-banner-arrow {
  display: inline-block;
  font-size: 1.3rem;
  animation: shortsBusyArrowMove 1s ease-in-out infinite;
}
@keyframes shortsBusyArrowMove {
  0%   { transform: translateX(0); opacity: 0.6; }
  50%  { transform: translateX(10px); opacity: 1; }
  100% { transform: translateX(0); opacity: 0.6; }
}

/* Bottom action bar */
.shorts-editorial .shorts-actions-bar {
  border-top: 1px solid var(--sf-divider) !important;
}

/* Buttons */
.btn-admin {
  padding: 10px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.btn-admin-primary {
  background-color: var(--admin-accent-blue);
  color: #ffffff;
}

.btn-admin-primary:hover {
  background-color: var(--admin-accent-blue-hover);
  transform: translateY(-1px);
}

.btn-admin-secondary {
  background-color: var(--admin-bg-input);
  color: var(--admin-text-secondary);
  border: 1px solid var(--admin-border);
}

.btn-admin-secondary:hover {
  background-color: var(--admin-border);
  color: var(--admin-text-primary);
}

.btn-admin-purple {
  background-color: #7c3aed;
  color: #ffffff;
}

.btn-admin-purple:hover {
  background-color: #6d28d9;
  transform: translateY(-1px);
}

.btn-admin-outline-teal {
  background-color: #ecfdf9;
  color: var(--color-green-deep);
  border: 1px solid var(--color-green-light);
}

.btn-admin-outline-teal:hover {
  background-color: #d3f5ec;
}

/* Dashboard "빠른 작업" widget - square box buttons on desktop */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 16px;
}

.quick-action-box {
  width: 100%;
  aspect-ratio: auto;
  min-height: 129px;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.3;
  padding: 12px 8px;
  font-size: 1.1rem;
}

.btn-admin-success {
  background-color: var(--color-green-deep);
  color: #ffffff;
}

.btn-admin-success:hover {
  background-color: #0a6352;
  transform: translateY(-1px);
}

.btn-admin-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-admin-danger:hover {
  background-color: #dc2626;
  transform: translateY(-1px);
}

.btn-admin-orange {
  background-color: #f97316;
  color: #ffffff;
}

.btn-admin-orange:hover {
  background-color: #ea580c;
  transform: translateY(-1px);
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-draft { background-color: rgba(148, 163, 184, 0.15); color: var(--status-draft); border: 1px solid rgba(148, 163, 184, 0.3); }
.badge-review { background-color: rgba(251, 191, 36, 0.15); color: var(--status-review); border: 1px solid rgba(251, 191, 36, 0.3); }
.badge-approved { background-color: rgba(34, 197, 94, 0.15); color: var(--status-approved); border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-scheduled { background-color: rgba(124, 58, 237, 0.15); color: var(--status-scheduled); border: 1px solid rgba(124, 58, 237, 0.3); }
.badge-published { background-color: rgba(6, 182, 212, 0.15); color: var(--status-published); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-archived { background-color: rgba(100, 116, 139, 0.15); color: var(--status-archived); border: 1px solid rgba(100, 116, 139, 0.3); }
.badge-rejected { background-color: rgba(239, 68, 68, 0.15); color: var(--status-rejected); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-correction { background-color: rgba(234, 88, 12, 0.15); color: var(--status-correction); border: 1px solid rgba(234, 88, 12, 0.3); }

/* Tables */
.admin-table-wrapper {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

/* Article list checkboxes: hidden until "삭제" is clicked once */
.article-select-col {
  display: none;
}

#articles-list-view.delete-mode-active .article-select-col {
  display: table-cell;
}

.admin-table th {
  background-color: var(--admin-bg-body);
  color: var(--admin-text-primary);
  font-weight: 600;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 2px solid var(--admin-border);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-text-secondary);
}

.admin-table tr:hover td {
  background-color: var(--admin-border-light);
  color: var(--admin-text-primary);
}

/* 기사 관리 목록의 제목 셀 -- 데스크톱 기본값(한 줄 말줄임). 반응형
   미디어쿼리에서 이 클래스를 다시 오버라이드해 모바일 카드형에서는
   자연스럽게 줄바꿈되도록 한다 (인라인 style로 두면 그 오버라이드가
   특정도 문제로 먹히지 않아서 클래스로 옮겼다). */
.articles-title-cell {
  font-weight: 500;
  color: var(--admin-text-primary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-links {
  display: flex;
  gap: 12px;
}

.action-links a {
  font-size: 0.8rem;
  color: var(--admin-accent-cyan);
  font-weight: 500;
  cursor: pointer;
}

.action-links a:hover {
  text-decoration: underline;
}

.shorts-status-box {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  color: #ffffff !important;
}

.shorts-status-box:hover {
  text-decoration: none !important;
  opacity: 0.88;
}

.shorts-status-create {
  background-color: var(--color-green-deep);
}

.shorts-status-sns {
  background-color: var(--color-green-deep);
}

.shorts-status-shorts {
  background-color: #7c3aed;
}

/* 저장 또는 다운로드를 한 번이라도 한 기사는 회색으로 반전시켜
   "이미 작업했다"는 걸 목록에서 바로 알아볼 수 있게 한다. 색상 클래스와
   함께 붙는 두 클래스 조합이라 위 단일 클래스 규칙보다 항상 우선한다. */
.shorts-status-box.shorts-status-done {
  background-color: #9ca3af;
}

/* Tabs Panel routing switcher */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Form Styles */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Homepage curation slots (홈화면 큐레이션) */
.curation-slot-group {
  margin-bottom: 32px;
}

.curation-slot-group > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--admin-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.curation-slot-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.curation-slot select {
  width: 100%;
}

.curation-preview {
  margin-top: 6px;
}

.curation-preview-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background-color: var(--admin-bg-input);
  border-radius: var(--border-radius-sm);
  font-size: 0.78rem;
  color: var(--admin-text-primary);
}

.curation-preview-card img {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.form-group-admin {
  margin-bottom: 20px;
}

.form-group-admin label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--admin-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control-admin {
  width: 100%;
  background-color: var(--admin-bg-input);
  border: 1px solid var(--admin-border-light);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--admin-text-primary);
  border-radius: var(--border-radius);
  transition: var(--transition-fast);
}

.form-control-admin:focus {
  outline: none;
  border-color: var(--admin-accent-cyan);
}

textarea.form-control-admin {
  resize: vertical;
  min-height: 120px;
}

/* Visually masks API key text as dots without being a real type="password"
   input. A real password-type field that gets its value set programmatically
   (loadGeminiApiKey()/loadClaudeApiKey() run on every AI 집필실/숏폼/카카오
   브리핑 tab visit) while sitting hidden behind a non-active .tab-content
   was the actual repeat trigger for Chrome's "update saved password?"
   prompt -- not the login form, which was already fixed separately. Plain
   text + this masking avoids the password-manager heuristics entirely. */
.masked-key-input {
  -webkit-text-security: disc;
}

.help-text {
  font-size: 0.75rem;
  color: var(--admin-text-muted);
  margin-top: 4px;
}

/* SNS 관리 -- 공용 기사 검색 피커 (최근 48시간 내 발행 기사만 대상).
   두 서브탭(카드뉴스/발행용 콘텐츠)이 각자 독립된 인스턴스로 재사용한다. */
.sns-article-picker {
  position: relative;
}

.sns-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 280px;
  overflow-y: auto;
  background-color: var(--admin-bg-panel);
  border: 1px solid var(--admin-border-light);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-soft);
}

.sns-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--admin-border);
}

.sns-picker-item:last-child {
  border-bottom: none;
}

.sns-picker-item:hover {
  background-color: var(--admin-bg-input);
}

.sns-picker-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sns-picker-item-date {
  color: var(--admin-text-secondary);
  flex-shrink: 0;
  font-size: 0.78rem;
}

.sns-picker-empty {
  padding: 14px;
  font-size: 0.85rem;
  color: var(--admin-text-secondary);
}

/* Article editor specifics */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: stretch;
}

/* 본문 편집기(form-content)가 우측 사이드바 칼럼과 항상 나란한 높이가
   되도록: 그리드가 두 칼럼을 이미 같은 행 높이로 늘려주므로(align-items:
   stretch), 왼쪽 칼럼을 세로 flex로 만들고 본문 편집기가 담긴 마지막
   form-group만 flex:1로 남는 공간을 모두 채우게 한다. 우측 사이드바
   높이는 기사 상태(승인자/예약발행 필드 노출 여부)나 대표 이미지
   미리보기 표시 여부에 따라 계속 바뀌는데, 고정 px 값이나 JS 높이 계산은
   그때마다 다시 어긋나므로 순수 CSS로 항상 맞도록 한다. */
.editor-layout > div:first-child {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-layout > div:first-child > .form-group-admin:last-child {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-sidebar-widget {
  background-color: var(--admin-bg-body);
  border: 1px solid var(--admin-border);
  padding: 20px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 24px;
}

.editor-sidebar-widget h4 {
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 1px solid var(--admin-border);
  padding-bottom: 8px;
  margin-bottom: 12px;
  color: var(--admin-text-primary);
  text-transform: uppercase;
}

/* Workflow Visualization panel */
.workflow-visual {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--admin-bg-body);
  border: 1px solid var(--admin-border-light);
  padding: 16px 24px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 28px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--admin-text-muted);
}

.workflow-step.active {
  color: var(--admin-accent-cyan);
  font-weight: 700;
}

.workflow-connector {
  flex: 1;
  height: 2px;
  background-color: var(--admin-border);
  margin: 0 16px;
}

.workflow-connector.active {
  background-color: var(--admin-accent-cyan);
}

/* AI Generation Panel Layout */
.ai-action-panel {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
}

.ai-controls {
  border-right: 1px solid var(--admin-border);
  padding-right: 32px;
}

.ai-output-box {
  background-color: var(--admin-bg-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--border-radius);
  padding: 32px;
  min-height: 500px;
  color: var(--admin-text-primary);
}

.ai-generating-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(56, 189, 248, 0.1);
  border-radius: 50%;
  border-top-color: var(--admin-accent-cyan);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ai-output-content {
  display: block;
}

.ai-result-section {
  border-bottom: 1px dashed var(--admin-border);
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.ai-result-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.ai-tag {
  background-color: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: var(--admin-accent-cyan);
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 6px;
}

/* Trending / info-topic pick lists (AI writer modes 3 & 4) */
.trending-list-box {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--admin-border-light);
  border-radius: var(--border-radius);
  padding: 8px;
  background-color: var(--admin-bg-input);
}

.trending-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  font-size: 0.84rem;
  cursor: pointer;
  border-radius: 4px;
}

.trending-item:hover {
  background-color: var(--admin-border-light);
}

.trending-item input {
  margin-top: 3px;
  flex-shrink: 0;
}

.trending-item span {
  flex: 1;
}

.trending-item-link {
  flex-shrink: 0;
  color: var(--admin-accent-cyan);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
}

.trending-item-link:hover {
  text-decoration: underline;
}

/* AI self-check results (check.md) */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.83rem;
  color: var(--admin-text-primary);
}

.checklist-icon {
  flex-shrink: 0;
  font-weight: 700;
  width: 16px;
  text-align: center;
}

.checklist-item.pass .checklist-icon {
  color: #10b981;
}

.checklist-item.fail .checklist-icon {
  color: #ef4444;
}

.checklist-item.fail {
  color: var(--admin-text-secondary);
}

/* AI 글쓰기 학습 sample list */
.training-sample-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--admin-border-light);
  font-size: 0.85rem;
}

.training-sample-item:last-child {
  border-bottom: none;
}

/* Modal Popup Styles */
.modal-admin {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-admin.active {
  display: flex;
}

.modal-admin-content {
  background-color: var(--admin-bg-panel);
  border: 1px solid var(--admin-border-light);
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 100%;
  padding: 32px;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--admin-text-muted);
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--admin-text-primary);
}

/* Image Thumbnail Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.media-card {
  border: 1px solid var(--admin-border);
  background-color: var(--admin-bg-body);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: var(--transition-fast);
}

.media-card:hover {
  border-color: var(--admin-accent-cyan);
}

.media-card.selected {
  border-color: var(--admin-accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.media-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

.media-action-btn {
  background-color: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 0.68rem;
  cursor: pointer;
  line-height: 1.4;
}

.media-action-btn:hover {
  background-color: rgba(15, 23, 42, 0.95);
}

.media-action-btn.media-action-danger:hover {
  background-color: #ef4444;
}

.media-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.media-card-info {
  padding: 8px;
  font-size: 0.72rem;
  color: var(--admin-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar toggle button (Hamburger) */
.sidebar-toggle-btn {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 20px;
  height: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 101;
  order: -1; /* Place before title */
}

.sidebar-toggle-btn span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--admin-text-primary);
  border-radius: 2px;
  transition: var(--transition-fast);
}

/* Sidebar navigation overlay for mobile */
.admin-sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(11, 26, 48, 0.4);
  backdrop-filter: blur(4px);
  z-index: 99;
}

.admin-sidebar-overlay.active {
  display: block;
}

/* Static page custom layout styles (originally inline styles) */
.static-page-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
}

.static-page-sidebar {
  border-right: 1px solid var(--admin-border);
  padding-right: 20px;
}

/* Login screen */
.admin-login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  background-color: var(--admin-bg-body);
  padding: 24px;
}

.admin-login-card {
  width: 100%;
  max-width: 380px;
  background-color: var(--admin-bg-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--border-radius);
  padding: 40px 32px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.admin-login-logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--admin-text-primary);
  text-align: center;
}

.admin-login-sub {
  font-size: 0.82rem;
  color: var(--admin-text-secondary);
  text-align: center;
  margin-top: 6px;
  margin-bottom: 28px;
}

.admin-login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 24px;
}

.rich-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background-color: var(--admin-bg-input);
  border: 1px solid var(--admin-border-light);
  border-bottom: none;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  padding: 8px;
}

.rich-editor-toolbar select,
.rich-editor-toolbar button,
.rich-editor-toolbar input[type="color"] {
  background-color: var(--admin-bg-panel);
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  color: var(--admin-text-primary);
  font-size: 0.8rem;
  padding: 6px 9px;
  cursor: pointer;
}

.rich-editor-toolbar input[type="color"] {
  padding: 2px;
  width: 34px;
  height: 30px;
}

.rich-editor-toolbar button:hover,
.rich-editor-toolbar select:hover {
  background-color: var(--admin-border-light);
}

.rich-editor-toolbar .toolbar-divider {
  width: 1px;
  height: 22px;
  background-color: var(--admin-border);
  margin: 0 4px;
}

.rich-editor-body {
  min-height: 640px;
  max-height: 900px;
  overflow-y: auto;
  border: 1px solid var(--admin-border-light);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  padding: 20px;
  background-color: #ffffff;
  color: var(--admin-text-primary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* 기사 본문 편집기(#form-content)만: 우측 사이드바와 나란한 높이를 flex로
   채우도록 위의 고정 min/max-height 대신 flex:1을 쓴다 (다른 rich-editor-body
   인스턴스인 페이지 HTML 편집기는 그대로 고정 높이를 유지). */
#form-content.rich-editor-body {
  flex: 1 1 auto;
  min-height: 300px;
  max-height: none;
}

.rich-editor-body:focus {
  outline: none;
  border-color: var(--admin-accent-cyan);
}

.rich-editor-body img {
  max-width: 100%;
  height: auto;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .sidebar-toggle-btn {
    display: flex;
  }
  
  /* Sidebar responsive transition */
  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(11, 26, 48, 0.15);
  }
  
  .admin-sidebar.active {
    left: 0;
  }
  
  /* Main area adjusts to full width */
  .admin-main {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }
  
  /* Header adjustments */
  .admin-header {
    padding: 0 20px;
    gap: 12px;
    justify-content: flex-start;
  }

  /* Every panel's title + action button(s) row -- no wrap on desktop is
     fine (plenty of width), but on a phone a title plus one or more
     buttons (e.g. 월별 리포트's ◀/▶ month nav, 구독자 관리's 목록 복사)
     can overflow past the screen edge instead of dropping to a second
     line. */
  .panel-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* .panel-title is itself display:flex (for icon+text titles elsewhere),
     so once .panel-header above starts wrapping, squeezing it into a
     shared row with the button group let its own text fragments/spans
     wrap independently at the flex-item level instead of as one normal
     paragraph -- title text broke apart letter-by-letter/word-by-word in
     a disjointed way instead of a clean line wrap. Giving it the full
     row width fixes both: it gets a normal-width box to wrap text in,
     and the button group cleanly drops to its own line under it. */
  .panel-header .panel-title {
    flex-basis: 100%;
  }

  .header-title-area {
    flex: 1;
  }
  
  .header-title-area h2 {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }
  
  .user-profile-badge {
    gap: 6px;
    font-size: 0.75rem;
  }
  
  .profile-name {
    display: none; /* Hide visitor name to save space on mobile */
  }

  /* Content inner paddings */
  .admin-content {
    padding: 24px 16px;
  }

  /* Grid structure collapses */
  .admin-grid-4 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Shrink the 5 dashboard stat cards (검토 대기 ~ 총 조회수) on mobile */
  .stat-card {
    padding: 12px 16px;
  }

  .stat-title {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .stat-trend {
    font-size: 0.68rem;
    margin-top: 4px;
  }

  /* Keep "빠른 작업" as the original stacked full-width bar buttons on mobile */
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }

  .quick-action-box {
    aspect-ratio: auto;
    flex-direction: row;
    padding: 10px 20px;
  }

  .grid-main-sidebar {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .editor-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .ai-action-panel {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .ai-controls {
    border-right: none;
    border-bottom: 1px solid var(--admin-border);
    padding-right: 0;
    padding-bottom: 24px;
  }
  
  .static-page-container {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .static-page-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--admin-border);
    padding-right: 0;
    padding-bottom: 16px;
  }

  /* Workflow bar to vertical timeline */
  .workflow-visual {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px;
  }
  
  .workflow-step {
    width: 100%;
    justify-content: flex-start;
  }
  
  .workflow-connector {
    width: 2px;
    height: 16px;
    margin: 0 0 0 28px;
    flex: none;
  }
  
  /* Tables wrapper scroll enhancement */
  .admin-table-wrapper {
    margin: 0 -16px;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
  }
  
  .admin-table {
    min-width: 600px; /* Force minimum table width for smooth scroll */
  }

  /* 기사 관리 목록: 카드형 대신 원래의 표 형태를 유지하되(가로 스크롤은
     감수), 작업(편집/미리보기/숏폼/복사) 칸의 버튼들이 좁은 화면에서
     줄바꿈되어 행이 세로로 길어지지 않도록 한 줄로 고정한다. 표 자체는
     위 .admin-table의 min-width:600px + 가로 스크롤을 그대로 쓴다. */
  .articles-table .action-links {
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  /* Modal contents adjustment */
  .modal-admin-content {
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* AI API Config Panel & Help UI styling */
.ai-api-config-panel {
  box-shadow: var(--box-shadow-soft);
  transition: var(--transition-fast);
}

.ai-api-config-panel:hover {
  border-color: var(--color-blue-light) !important;
}

.ai-api-config-panel h4:hover {
  color: var(--color-blue-deep);
}
