/* Custom styles for Sales CRM */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --hot: #ef4444;
  --warm: #f97316;
  --cold: #3b82f6;
}

* { box-sizing: border-box; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f8fafc;
  color: #1e293b;
}

/* 로그인 화면 */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1d4ed8 100%);
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  color: white;
}

.code-input {
  letter-spacing: 0.3em;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

.code-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 네비게이션 */
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: #1e293b;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: #2563eb; color: white; }

.nav-item i { width: 20px; text-align: center; font-size: 1rem; }

.main-content {
  margin-left: 260px;
  min-height: 100vh;
  background: #f8fafc;
}

.page-header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-content { padding: 24px; }

/* 카드 */
.card {
  background: white;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.card-header { padding: 20px 24px; border-bottom: 1px solid #f1f5f9; }
.card-body { padding: 20px 24px; }

/* 통계 카드 */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 20px 24px;
  border: 1px solid #e2e8f0;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}

/* 배지 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-hot { background: #fee2e2; color: #dc2626; }
.badge-warm { background: #ffedd5; color: #ea580c; }
.badge-cold { background: #dbeafe; color: #2563eb; }
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-paused { background: #fef3c7; color: #d97706; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-high { background: #fee2e2; color: #dc2626; }
.badge-medium { background: #fef3c7; color: #d97706; }
.badge-low { background: #f0fdf4; color: #16a34a; }
.badge-pending { background: #f1f5f9; color: #64748b; }
.badge-in_progress { background: #dbeafe; color: #2563eb; }
.badge-completed { background: #dcfce7; color: #16a34a; }
.badge-cancelled { background: #fee2e2; color: #dc2626; }
.badge-won { background: #dcfce7; color: #16a34a; }
.badge-lost { background: #fee2e2; color: #dc2626; }

/* 테이블 */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  vertical-align: middle;
}
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 0.875rem;
  font-weight: 500; cursor: pointer; border: none; transition: all 0.2s;
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: white; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: 6px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 8px; }

/* 폼 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px;
  font-size: 0.875rem; outline: none; transition: border-color 0.2s; background: white;
}
.form-control:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* 모달 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: white; border-radius: 20px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 24px 28px 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid #f1f5f9;
}

.modal-body { padding: 24px 28px; }
.modal-footer { padding: 16px 28px 24px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid #f1f5f9; }

/* 관심도 바 */
.interest-bar { height: 6px; border-radius: 3px; background: #e2e8f0; overflow: hidden; }
.interest-fill { height: 100%; border-radius: 3px; }
.interest-hot { background: linear-gradient(90deg, #ef4444, #f97316); width: 100%; }
.interest-warm { background: linear-gradient(90deg, #f97316, #facc15); width: 60%; }
.interest-cold { background: linear-gradient(90deg, #3b82f6, #06b6d4); width: 30%; }

/* 단계 파이프라인 */
.pipeline-stage {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}

/* 빈 상태 */
.empty-state {
  text-align: center; padding: 60px 20px; color: #94a3b8;
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; opacity: 0.4; }

/* 로딩 */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: #94a3b8; }
.spinner { width: 24px; height: 24px; border: 3px solid #e2e8f0; border-top-color: #2563eb; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 알림 토스트 */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #1e293b; color: white; padding: 14px 20px;
  border-radius: 12px; font-size: 0.875rem; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 340px; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* 검색/필터 바 */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* 반응형 */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* 스크롤바 스타일 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 애니메이션 */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 칸반 보드 */
.kanban-col {
  background: #f8fafc;
  border-radius: 14px;
  padding: 16px;
  min-height: 200px;
  border: 1px solid #e2e8f0;
}

.kanban-card {
  background: white;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.2s;
}
.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

/* 유저 아바타 */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.875rem;
}

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab-item {
  padding: 10px 20px; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  color: #64748b; transition: all 0.2s;
}
.tab-item:hover { color: #2563eb; }
.tab-item.active { color: #2563eb; border-bottom-color: #2563eb; }

/* 진행 단계 */
.stage-badge {
  display: inline-flex; align-items: center; padding: 4px 10px;
  border-radius: 6px; font-size: 0.75rem; font-weight: 600;
}
.stage-initial { background: #f1f5f9; color: #64748b; }
.stage-contacted { background: #dbeafe; color: #2563eb; }
.stage-meeting_scheduled { background: #e0f2fe; color: #0284c7; }
.stage-proposal_sent { background: #fef3c7; color: #d97706; }
.stage-negotiation { background: #ffedd5; color: #ea580c; }
.stage-won { background: #dcfce7; color: #16a34a; }
.stage-lost { background: #fee2e2; color: #dc2626; }

/* 달력 */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day { min-height: 80px; background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 6px; }
.calendar-day.other-month { background: #f8fafc; opacity: 0.6; }
.calendar-day.today { border-color: #2563eb; border-width: 2px; }
.cal-event { padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; margin-bottom: 2px; cursor: pointer; truncate: true; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-task { background: #dbeafe; color: #1d4ed8; }
.cal-meeting { background: #dcfce7; color: #15803d; }
.cal-feedback { background: #fef3c7; color: #b45309; }

/* ============================
   품질 이슈 관련 스타일
   ============================ */

/* 심각도 배지 */
.badge-critical { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; font-weight: 700; }
.badge-medium-q { background: #fefce8; color: #ca8a04; border: 1px solid #fde68a; }
.badge-low-q    { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* 처리 상태 배지 */
.qbadge-open     { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.qbadge-progress { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.qbadge-resolved { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.qbadge-closed   { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }
.qbadge-wont     { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }

/* 카테고리 배지 */
.badge-category { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; font-size: 0.7rem; }

/* 영향도 바 */
.impact-bar {
  width: 60px; height: 6px; background: #e2e8f0;
  border-radius: 3px; overflow: hidden;
}
.impact-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.3s ease;
}

/* 심각도별 행 강조 */
tr.critical-row { background: #fef2f2; }
tr.high-row { background: #fff7ed; }

/* 이슈 등록 폼 range 스타일 */
input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(37,99,235,0.4);
}

/* 대시보드 stat-card 클릭 가능 표시 */
.stat-card.cursor-pointer:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

/* 사이드바 품질 이슈 메뉴 강조 */
.nav-item.quality-active {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* 모바일 반응형 개선 */
@media (max-width: 768px) {
  .grid.lg\\:grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; gap: 8px; }
  .filter-bar .form-control { max-width: 100% !important; }
  table { font-size: 0.75rem; }
  th, td { padding: 8px 10px; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
}

/* 토스트 위치 개선 */
.toast {
  animation: slideInRight 0.3s ease;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 빈 상태 개선 */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px; color: #94a3b8;
  text-align: center;
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }

/* 품질 이슈 테이블 좁은 컬럼 */
.quality-table th:first-child,
.quality-table td:first-child { width: 40px; text-align: center; }

/* whitespace-pre-wrap 텍스트 영역 */
.whitespace-pre-wrap { white-space: pre-wrap; }
