/* WSC AI 비서 — 공통 스타일 */

/* ── 폰트 로드 ───────────────────────────────────── */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&family=JetBrains+Mono&display=swap');

/* ── CSS 변수 ────────────────────────────────────── */
:root {
  --font-main: 'Pretendard', 'Noto Sans KR', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;

  /* 라이트 모드 */
  --bg-page:       #f0f2f5;
  --bg-card:       #ffffff;
  --bg-surface:    #f8fafc;
  --bg-nav:        #1e293b;
  --text-primary:  #333333;
  --text-heading:  #1e293b;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;
  --input-bg:      #ffffff;
  --input-border:  #e2e8f0;
  --shadow-card:   0 1px 3px rgba(0,0,0,.07);
  --shadow-modal:  0 8px 40px rgba(0,0,0,.18);
  --shadow-login:  0 4px 24px rgba(0,0,0,.1);
}

[data-theme="dark"] {
  --bg-page:       #0f0f0f;
  --bg-card:       #1a1a1a;
  --bg-surface:    #242424;
  --bg-nav:        #111111;
  --text-primary:  #e0e0e0;
  --text-heading:  #f0f0f0;
  --text-muted:    #a0a0a0;
  --text-faint:    #6b6b6b;
  --border:        #333333;
  --border-light:  #2a2a2a;
  --input-bg:      #2d2d2d;
  --input-border:  #444444;
  --shadow-card:   0 1px 3px rgba(0,0,0,.4);
  --shadow-modal:  0 8px 40px rgba(0,0,0,.6);
  --shadow-login:  0 4px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-main); font-weight: 400; background: var(--bg-page); color: var(--text-primary); min-height: 100vh; }

/* 폼 요소 폰트 상속 (브라우저 기본 폰트 오버라이드) */
input, select, textarea, button { font-family: inherit; }

/* Nav */
nav { background: var(--bg-nav); color: white; padding: 0 20px; display: flex; align-items: center; height: 52px; gap: 4px; }
nav .brand { font-weight: 700; font-size: 1.05em; margin-right: 16px; color: #f1f5f9; letter-spacing: -.3px; }
nav a.nav-link { color: #94a3b8; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: .9em; }
nav a.nav-link:hover { background: #334155; color: #f1f5f9; }
nav a.nav-link.active { background: #3b82f6; color: white; }
nav .spacer { flex: 1; }
nav .logout-btn { background: none; border: 1px solid #475569; color: #94a3b8; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: .85em; }
nav .logout-btn:hover { border-color: #ef4444; color: #ef4444; }
nav .theme-toggle { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 4px 6px; border-radius: 6px; color: #94a3b8; }
nav .theme-toggle:hover { background: #334155; color: #f1f5f9; }

/* Layout */
main { max-width: 1140px; margin: 24px auto; padding: 0 16px; }
.page-title { font-size: 1.4em; font-weight: 700; color: var(--text-heading); margin-bottom: 20px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border-radius: 10px; padding: 20px 16px; box-shadow: var(--shadow-card); text-align: center; }
.stat-card .num { font-size: 2.1em; font-weight: 800; color: var(--text-heading); line-height: 1.1; }
.stat-card .lbl { color: var(--text-muted); font-size: .82em; margin-top: 6px; }
.stat-card.red .num { color: #ef4444; }
.stat-card.blue .num { color: #3b82f6; }
.stat-card.green .num { color: #22c55e; }
.stat-card.orange .num { color: #f97316; }

/* Cards */
.card { background: var(--bg-card); border-radius: 10px; padding: 20px; box-shadow: var(--shadow-card); margin-bottom: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-weight: 700; font-size: 1em; color: var(--text-heading); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88em; }
th { text-align: left; padding: 10px 12px; background: var(--bg-surface); border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-surface); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .78em; font-weight: 600; white-space: nowrap; }
.b-blue   { background: #dbeafe; color: #1d4ed8; }
.b-green  { background: #dcfce7; color: #16a34a; }
.b-yellow { background: #fef9c3; color: #854d0e; }
.b-red    { background: #fee2e2; color: #dc2626; }
.b-gray   { background: #f1f5f9; color: #475569; }
.b-purple { background: #ede9fe; color: #6d28d9; }
.b-orange { background: #ffedd5; color: #c2410c; }

/* Priority dots */
.pri { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.pri-high   { background: #ef4444; }
.pri-mid    { background: #f59e0b; }
.pri-low    { background: #22c55e; }

/* Buttons */
.btn { padding: 7px 16px; border: none; border-radius: 7px; cursor: pointer; font-size: .88em; font-weight: 500; transition: opacity .15s; }
.btn:hover { opacity: .87; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: #3b82f6; color: white; }
.btn-success { background: #22c55e; color: white; }
.btn-danger  { background: #ef4444; color: white; }
.btn-ghost   { background: #f1f5f9; color: #475569; }
.btn-sm { padding: 4px 10px; font-size: .8em; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid var(--input-border); border-radius: 7px; font-size: .88em; background: var(--input-bg); color: var(--text-primary); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-page); }
.login-box { background: var(--bg-card); border-radius: 14px; padding: 44px 36px; width: 340px; box-shadow: var(--shadow-login); text-align: center; }
.login-box .logo { font-size: 2.5em; margin-bottom: 10px; }
.login-box h1 { font-size: 1.3em; font-weight: 700; color: var(--text-heading); margin-bottom: 6px; }
.login-box .sub { color: var(--text-muted); font-size: .88em; margin-bottom: 28px; }
.login-box input[type=password] { width: 100%; padding: 11px 14px; border: 1px solid var(--input-border); border-radius: 8px; font-size: .95em; margin-bottom: 12px; outline: none; background: var(--input-bg); color: var(--text-primary); }
.login-box input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.login-box .btn-primary { width: 100%; padding: 11px; font-size: .95em; }
.error-msg { color: #ef4444; font-size: .85em; margin-top: 10px; }

/* Loader */
.loader { text-align: center; padding: 40px; color: var(--text-muted); font-size: .95em; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 200; overflow-y: auto; padding: 40px 16px; }
.modal { background: var(--bg-card); border-radius: 12px; padding: 28px; width: 100%; max-width: 560px; box-shadow: var(--shadow-modal); }
.modal h3 { font-size: 1.1em; font-weight: 700; margin-bottom: 18px; color: var(--text-heading); }
.modal label { display: block; font-size: .85em; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 8px 11px; border: 1px solid var(--input-border); border-radius: 7px; margin-bottom: 12px; font-size: .9em; background: var(--input-bg); color: var(--text-primary); }
.modal textarea { min-height: 72px; resize: vertical; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* Report */
.report-box { background: var(--bg-surface); border-radius: 8px; padding: 16px; white-space: pre-wrap; font-size: .87em; line-height: 1.75; margin-top: 14px; max-height: 380px; overflow-y: auto; border: 1px solid var(--border); }

/* Task row detail */
.task-title a { color: var(--text-heading); text-decoration: none; font-weight: 500; }
.task-title a:hover { color: #3b82f6; text-decoration: underline; }
.task-meta { color: var(--text-faint); font-size: .8em; margin-top: 2px; }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.empty .icon { font-size: 2.5em; margin-bottom: 10px; }

/* Calendar task color chips */
.cal-blue   { background:#dbeafe; color:#1d4ed8; }
.cal-orange { background:#ffedd5; color:#c2410c; }
.cal-purple { background:#ede9fe; color:#6d28d9; }
.cal-yellow { background:#fef9c3; color:#854d0e; }
.cal-gray   { background:#f1f5f9; color:#475569; }
.cal-red    { background:#fee2e2; color:#dc2626; }
.cal-green  { background:#dcfce7; color:#16a34a; }
.cal-pink   { background:#fce7f3; color:#9d174d; }
.cal-brown  { background:#fef3c7; color:#92400e; }

/* 브랜드 축약 — 기본: 전체 텍스트 표시 */
.brand-short { display: none; }

/* 로그아웃 버튼 — 기본: 아이콘 숨김, 텍스트 표시 */
.nav-icon-mobile { display: none; }

/* Responsive */
@media (max-width: 640px) {
  main { padding: 0 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px 12px; }
  .card { padding: 16px 12px; }
  table { font-size: .8em; }
  td, th { padding: 7px 8px; }
  .hide-mobile { display: none; }
}

/* 모바일 네비게이션 한 줄 정렬 */
@media (max-width: 480px) {
  nav {
    padding: 0 6px;
    gap: 1px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  nav .brand {
    font-size: 0.82em;
    margin-right: 2px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  nav .brand-full { display: none; }
  nav .brand-short { display: inline; }
  nav a.nav-link {
    font-size: 0.72rem;
    padding: 6px 5px;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
    min-width: 0;
  }
  /* 📅📊🔔⚙️ 아이콘 버튼 — 패딩 축소 */
  nav .nav-icon-btn,
  nav .cal-toggle-btn,
  nav .settings-btn {
    padding: 5px 7px;
    font-size: .82em;
    margin-right: 1px;
    flex-shrink: 0;
  }
  nav .logout-btn {
    padding: 5px 7px;
    font-size: .82em;
    white-space: nowrap;
    flex-shrink: 0;
  }
  nav .theme-toggle {
    padding: 5px 7px;
    flex-shrink: 0;
  }
  .nav-icon-mobile { display: inline; }
  .nav-text-mobile { display: none; }
}

/* ── 다크 모드 전역 오버라이드 ──────────────────────── */
/* 배지 — 라이트 파스텔 → 다크 딥톤 */
[data-theme="dark"] .b-blue   { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .b-green  { background: #14532d; color: #86efac; }
[data-theme="dark"] .b-yellow { background: #422006; color: #fcd34d; }
[data-theme="dark"] .b-red    { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .b-gray   { background: #1e293b; color: #94a3b8; }
[data-theme="dark"] .b-purple { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .b-orange { background: #431407; color: #fdba74; }
/* btn-ghost */
[data-theme="dark"] .btn-ghost { background: var(--bg-surface); color: var(--text-muted); }
[data-theme="dark"] .btn-ghost:hover { background: var(--border); color: var(--text-primary); }
/* 캘린더 이벤트 칩 — 다크모드: 카테고리 색상 배경 + 흰 글자 (Notion 스타일) */
[data-theme="dark"] .cal-blue   { background: #2563eb; color: #fff; }
[data-theme="dark"] .cal-orange { background: #ea7b1f; color: #fff; }
[data-theme="dark"] .cal-purple { background: #7c3aed; color: #fff; }
[data-theme="dark"] .cal-yellow { background: #b45309; color: #fff; }
[data-theme="dark"] .cal-gray   { background: #4b5563; color: #fff; }
[data-theme="dark"] .cal-red    { background: #dc2626; color: #fff; }
[data-theme="dark"] .cal-green  { background: #059669; color: #fff; }
[data-theme="dark"] .cal-pink   { background: #db2777; color: #fff; }
[data-theme="dark"] .cal-brown  { background: #92400e; color: #fff; }
