/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --text: #1e1e2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --border-light: #f0f1f3;
  --primary: #4f6ef7;
  --primary-hover: #3b5de7;
  --primary-light: #eef2ff;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --header-h: 52px;
  --toolbar-h: 44px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.header-left, .header-right { display: flex; align-items: center; gap: 12px; }

.logo {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

/* ===== Project Tabs ===== */
.project-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.project-tab {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.15s;
}

.project-tab:hover { background: var(--primary-light); border-color: var(--primary); }
.project-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.project-tab .tab-delete {
  margin-left: 6px;
  opacity: 0.5;
  cursor: pointer;
  font-size: 10px;
}
.project-tab .tab-delete:hover { opacity: 1; }

/* ===== Auth Status ===== */
.auth-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
}

.auth-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #d1d5db;
}

.auth-status.connected .auth-dot { background: var(--success); }
.auth-status.disconnected .auth-dot { background: #d1d5db; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--toolbar-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

.sync-status {
  font-size: 11px;
  color: var(--text-secondary);
}

.sync-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(79,110,247,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.view-mode-group {
  display: flex;
  gap: 1px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn { border-radius: 4px; font-weight: 500; }
.view-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  gap: 12px;
}

.filter-left { display: flex; align-items: center; flex: 1; max-width: 260px; }
.filter-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.filter-search {
  width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s;
}

.filter-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,110,247,0.1);
}

.filter-search::placeholder { color: #aaa; }

.filter-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 140px;
  transition: border-color 0.15s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-clear {
  color: var(--danger);
  border-color: var(--danger);
  font-size: 11px;
}

.filter-clear:hover {
  background: #fef2f2;
}

.filter-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { padding: 6px 8px; border: none; background: transparent; font-size: 15px; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-full { width: 100%; justify-content: center; }

/* ===== App Layout — 사이드바 + 메인 ===== */
.app-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.sidebar-header h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.sidebar-collapse-btn {
  font-size: 10px;
  padding: 4px 6px;
  color: var(--text-secondary);
}

.sidebar-expand-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 50;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sidebar-expand-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== Sidebar Sections ===== */
.sidebar-section {
  border-bottom: 1px solid var(--border-light);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.sidebar-section-header:hover {
  background: var(--surface-alt);
}

.sidebar-chevron {
  font-size: 8px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.sidebar-section.collapsed .sidebar-chevron {
  transform: rotate(-90deg);
}

.sidebar-section.collapsed .sidebar-section-body {
  display: none;
}

.sidebar-section-body {
  padding: 12px 16px;
  background: var(--surface-alt);
}

/* ===== Sidebar Jira Status ===== */
.sidebar-jira-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin-bottom: 12px;
}

.sidebar-jira-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
}

.sidebar-jira-status.connected .status-dot {
  background: var(--success);
}

.sidebar-jira-status.disconnected .status-dot {
  background: var(--danger);
}

/* ===== Sidebar Settings ===== */
.sidebar-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sidebar-setting-row label {
  font-size: 11px;
  color: var(--text-secondary);
}

.sidebar-view-mode {
  gap: 2px;
}

/* ===== Sidebar Filters ===== */
.sidebar-filter-group {
  margin-bottom: 10px;
}

.sidebar-filter-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.sidebar-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
  background: var(--surface);
}

.sidebar-input:focus {
  outline: none;
  border-color: var(--primary);
}

.sidebar-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
  background: var(--surface);
  cursor: pointer;
}

/* ===== Sidebar Unscheduled List ===== */
.sidebar-unscheduled {
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

.unscheduled-list {
  display: flex;
  flex-direction: column;
}

.unscheduled-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
}

.unscheduled-item {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}

.unscheduled-item:hover {
  background: var(--primary-light);
}

.unscheduled-item-key {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.unscheduled-item-name {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.unscheduled-item-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-secondary);
}

.unscheduled-item-status {
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 9px;
  font-weight: 600;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 6px;
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(245,246,248,0.9));
}

.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { margin-bottom: 8px; color: var(--text); font-size: 18px; }
.empty-state p { font-size: 13px; line-height: 1.8; }

.btn-sync-header.loading {
  color: var(--primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Gantt Container — 메인 영역 (스크롤 방식) ===== */
.gantt-container {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

/* frappe-gantt 내부 wrapper div */
.gantt-container > div {
  height: 100%;
  overflow: auto;
}

/* ===== Legend — 간트 하단 컴팩트 스트립 ===== */
.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ===== Unscheduled Tasks — 접이식 드로어 ===== */
.unscheduled-drawer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  transition: max-height 0.3s ease;
}

.unscheduled-drawer.collapsed .unscheduled-body-wrap {
  max-height: 0;
  overflow: hidden;
}

.unscheduled-drawer:not(.collapsed) .unscheduled-body-wrap {
  max-height: 240px;
  overflow-y: auto;
}

.unscheduled-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.unscheduled-toggle:hover {
  background: var(--surface-alt);
}

.unscheduled-toggle-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unscheduled-toggle-left h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.unscheduled-chevron {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.3s ease;
  display: inline-block;
}

.unscheduled-drawer.collapsed .unscheduled-chevron {
  transform: rotate(180deg);
}

.unscheduled-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary);
  color: white;
}

.unscheduled-hint {
  font-size: 11px;
  color: var(--text-secondary);
}

.unscheduled-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.unscheduled-table th {
  text-align: left;
  padding: 6px 16px;
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1;
}

.unscheduled-table td {
  padding: 6px 16px;
  border-bottom: 1px solid var(--border-light);
}

.unscheduled-table tr {
  cursor: pointer;
  transition: background 0.1s;
}

.unscheduled-table tbody tr:hover {
  background: var(--primary-light);
}

.unscheduled-table .task-key-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 11px;
}

.unscheduled-table .status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-secondary);
}

/* 미배정 스크롤바 */
.unscheduled-body-wrap::-webkit-scrollbar { width: 5px; }
.unscheduled-body-wrap::-webkit-scrollbar-track { background: transparent; }
.unscheduled-body-wrap::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ===== Settings Panel ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  backdrop-filter: blur(2px);
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  z-index: 201;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 15px; font-weight: 700; }

.panel-body { padding: 20px; }

.setting-section { margin-bottom: 24px; }
.setting-section h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--text-secondary); }

.form-group { margin-bottom: 12px; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}

/* ===== Jira Status Box ===== */
.jira-status-box {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  margin-bottom: 10px;
  text-align: center;
  border: 1px solid var(--border-light);
}

.jira-status-message { font-size: 12px; font-weight: 600; }
.jira-status-message.connected { color: var(--success); }
.jira-status-message.disconnected { color: var(--danger); }

.setting-hint {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Category Color Picker ===== */
.category-color-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-color-row input[type="color"] {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
  background: transparent;
}

.category-color-name {
  font-size: 12px;
  font-weight: 500;
}

/* ===== 헤더 동기화 버튼 ===== */
.btn-sync-header {
  color: var(--text-secondary);
  border-color: var(--border);
  font-size: 12px;
  padding: 4px 10px;
}
.btn-sync-header:not(:disabled):hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
.btn-sync-header:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ===== 프로젝트 모달 키 입력 ===== */
.project-key-row {
  display: flex;
  gap: 8px;
}
.label-hint {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}
.field-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}
.jql-advanced-toggle {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.jql-advanced-toggle:hover {
  color: var(--primary);
}

/* ===== Today Button ===== */
.btn-today {
  font-weight: 600;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-today:hover {
  background: var(--primary-light);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: white;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
