/* dashboard.css — 대시보드 전용 스타일 (전역/사이드바/탑바는 layout.css에서 관리) */

/* ============================================
   DASHBOARD CARD VARIANTS (db-1, db-2)
   ============================================ */

/* db-1: Colored Cards */
.db-1 .stat-card {
  border-radius: 12px;
  padding: 1.5rem;
  color: white;
  transition: all 0.3s ease;
}
.db-1 .stat-card.stat-1 { background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%); }
.db-1 .stat-card.stat-2 { background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%); }
.db-1 .stat-card.stat-3 { background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%); }
.db-1 .stat-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15); }

/* db-2: Left Border */
.db-2 .stat-card {
  border-radius: 8px;
  padding: 1.5rem;
  background: white;
  border-left: 4px solid;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.db-2 .stat-card.stat-1 { border-left-color: #3B82F6; }
.db-2 .stat-card.stat-2 { border-left-color: #F59E0B; }
.db-2 .stat-card.stat-3 { border-left-color: #EF4444; }
.db-2 .stat-card .stat-label { color: var(--light); font-size: 0.875rem; }
.db-2 .stat-card .stat-value { color: var(--brand); font-size: 1.875rem; font-weight: 700; margin-top: 0.5rem; }
.db-2 .stat-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }

/* ============================================
   PANEL VARIANTS (layout-1)
   ============================================ */

/* layout-1: Default */
.layout-1 {
  border-radius: 0;
}

/* ============================================
   KPI SIDE LAYOUT
   ============================================ */

.kpi-side {
  flex: 4;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kpi-side .kpi-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--bg-light);
  border-radius: 10px;
  transition: background 0.15s;
}

.kpi-side .kpi-card:hover { background: #E5E7EB; }

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-item {
  margin-bottom: 0.5rem;
}

.progress-item:last-child { margin-bottom: 0; }

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.progress-label-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand);
}

.progress-label-count {
  font-size: 0.875rem;
  font-weight: 700;
  color: #3B82F6;
  background: rgba(59, 130, 246, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-1 { background: linear-gradient(90deg, #3B82F6, #1E40AF); }
.progress-2 { background: linear-gradient(90deg, #F59E0B, #D97706); }
.progress-3 { background: linear-gradient(90deg, #8B5CF6, #6D28D9); }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.dash-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--brand);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 60;
  animation: slideIn 0.3s ease;
}

.dash-toast.dash-toast-success { background: #10B981; }
.dash-toast.dash-toast-error { background: #EF4444; }
.dash-toast.dash-toast-warning { background: #F59E0B; }
.dash-toast.dash-toast-info { background: #3B82F6; }

.dash-toast i { font-size: 1rem; flex-shrink: 0; }
.dash-toast-body { flex: 1; }
.dash-toast-title { font-weight: 700; font-size: 0.875rem; display: block; }
.dash-toast-message { font-size: 0.8125rem; opacity: 0.9; }
.dash-toast-close { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 0.875rem; padding: 0; flex-shrink: 0; }
.dash-toast-close:hover { color: white; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================
   CONTENT AREA (대시보드 내부 스크롤 영역)
   ============================================ */


/* .content-wrapper는 layout.css에서 정의 (중복 제거) */


#contentArea {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

/* ============================================
   STAT CARDS (db-3)
   ============================================ */

#contentArea .stat-cards-row {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 0.5rem;
}

#contentArea .stat-card {
  border-radius: 12px;
  padding: 1.5rem;
  background: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 10px 20px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

#contentArea .stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1), 0 20px 32px rgba(0, 0, 0, 0.08);
}

#contentArea .db-3 .stat-card {
  border-radius: 12px;
  padding: 1.5rem;
  background: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 10px 20px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

#contentArea .db-3 .stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1), 0 20px 32px rgba(0, 0, 0, 0.08);
}

.stat-card .stat-label { font-size: 0.875rem; margin-bottom: 0.5rem; }
.stat-card .stat-value { font-size: 1.875rem; font-weight: 700; }
.stat-card .stat-subtitle { font-size: 0.75rem; margin-top: 0.5rem; opacity: 0.8; }
.db-3 .stat-card .stat-label { color: var(--light); }
.db-3 .stat-card .stat-value { color: var(--brand); margin-top: 0.5rem; }

/* ============================================
   PANELS (layout-2)
   ============================================ */

.dash-panel {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

.layout-2 {
  border: 1px solid var(--tint);
  border-radius: 8px;
}

.dash-panel-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dash-panel-title i { color: #3B82F6; }

.table-wrapper { overflow-x: auto; overflow-y: auto; flex: 1; min-height: 0; }

table { width: 100%; font-size: 0.875rem; border-collapse: collapse; }

table thead {
  background: var(--background);
  border-bottom: 1px solid var(--tint);
  position: sticky;
  top: 0;
  z-index: 1;
}

table th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--tertiary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table td { padding: 0.75rem; border-bottom: 1px solid var(--tint); color: var(--brand); }
table tbody tr:hover { background: var(--bg-light); }

/* ============================================
   STATUS BADGES
   ============================================ */

.status-badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* orders.css가 .status-badge를 덮어쓰므로 specificity를 높여서 재정의 */
#contentArea .status-badge {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-pending { background: rgba(249,158,11,0.1); color: #B45309; }
.status-completed { background: rgba(34,197,94,0.1); color: #15803D; }
.status-processing { background: rgba(59,130,246,0.1); color: #1E40AF; }
.status-shipped { background: rgba(139,92,246,0.1); color: #5B21B6; }

/* ============================================
   CHART + KPI LAYOUT
   ============================================ */

.chart-kpi-row { display: flex; gap: 1rem; margin-bottom: 0.5rem; }
.chart-panel { margin-bottom: 0; flex: 6; min-width: 0; width: auto; }

.kpi-card { flex: 1; display: flex; align-items: center; gap: 1.25rem; }

.kpi-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.kpi-info { display: flex; flex-direction: column; gap: 0.25rem; }
.db-kpi-label { font-size: 0.8125rem; color: var(--tertiary); font-weight: 500; }
.db-kpi-value { font-size: 2rem; font-weight: 800; color: var(--brand); line-height: 1; }
.db-kpi-value small { font-size: 0.875rem; font-weight: 500; color: var(--light); margin-left: 0.25rem; }

/* ============================================
   NOTIFICATION PANEL
   ============================================ */

.noti-panel {
  position: absolute;
  top: 100%;
  right: 0;
  width: 380px;
  max-height: 480px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--tint);
  z-index: 1000;
  overflow: hidden;
  margin-top: 0.5rem;
}

.noti-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bg-light);
}

.noti-title { font-size: 0.9375rem; font-weight: 700; color: var(--brand); }

.noti-read-all {
  font-size: 0.75rem;
  font-weight: 600;
  color: #3B82F6;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.noti-read-all:hover { background: rgba(59,130,246,0.08); }
.noti-list { overflow-y: auto; max-height: 380px; }

.noti-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--bg-light);
  cursor: pointer;
  transition: background 0.15s;
}

.noti-item:hover { background: var(--bg-light); }
.noti-item:last-child { border-bottom: none; }
.noti-item.noti-unread { background: rgba(59,130,246,0.03); }
.noti-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 0.375rem; }
.noti-item.noti-read .noti-dot { opacity: 0; }
.noti-content { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.noti-text { font-size: 0.8125rem; font-weight: 500; color: var(--brand); line-height: 1.4; }
.noti-item.noti-read .noti-text { color: var(--light); font-weight: 400; }
.noti-time { font-size: 0.6875rem; color: var(--light); }
.noti-icon { flex-shrink: 0; font-size: 0.875rem; margin-top: 0.125rem; }

/* ============================================
   RECENT DOCUMENTS
   ============================================ */

.recent-docs-list { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

.recent-doc-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--bg-light);
  text-decoration: none;
  transition: background 0.15s;
  border-radius: 6px;
}

.recent-doc-item:last-child { border-bottom: none; }
.recent-doc-item:hover { background: var(--bg-light); }
.recent-doc-badge { font-size: 0.6875rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 4px; white-space: nowrap; }
.recent-doc-number { font-size: 0.8125rem; font-weight: 600; color: var(--brand); flex: 1; }
.recent-doc-date { font-size: 0.75rem; color: var(--light); }

/* ============================================
   RECEIVABLE LIST
   ============================================ */

.receivable-list { display: flex; flex-direction: column; overflow-y: auto; flex: 1; min-height: 0; }

.receivable-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--tint);
}

.receivable-item:last-child { border-bottom: none; }
.receivable-info { display: flex; flex-direction: column; gap: 0.125rem; }
.receivable-name { font-size: 0.875rem; font-weight: 600; color: var(--brand); }
.receivable-date { font-size: 0.75rem; color: var(--light); }
.receivable-amount { font-size: 0.875rem; font-weight: 700; color: var(--brand); }
.receivable-amount.overdue { color: #EF4444; }

/* ============================================
   BAR CHART
   ============================================ */

.chart-legend { display: flex; gap: 1.25rem; margin-bottom: 0.5rem; font-size: 0.8125rem; color: var(--tertiary); }
#contentArea .dash-legend-item { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; color: var(--tertiary); }
#contentArea .dash-legend-dot { width: 10px; height: 10px; border-radius: 3px; border: none; }
#contentArea .dash-legend-quote { background: #3B82F6; }
#contentArea .dash-legend-order { background: #10B981; }

.chart-container { display: flex; height: 200px; margin-bottom: 0.5rem; }

.chart-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-right: 0.75rem;
  font-size: 0.6875rem;
  color: var(--light);
  text-align: right;
  min-width: 28px;
  padding-bottom: 22px;
}

.chart-area {
  flex: 1;
  position: relative;
  border-left: 1px solid var(--tint);
  border-bottom: 1px solid var(--tint);
}

.chart-grid-lines {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.dash-grid-line { width: 100%; height: 1px; background: var(--bg-light); }

.chart-bars {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  padding: 0 1rem;
}

.dash-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }

.dash-bar-pair {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  flex: 1;
  width: 100%;
  justify-content: center;
  padding-bottom: 2px;
}

.dash-bar {
  width: 20px;
  border-radius: 4px 4px 0 0;
  position: relative;
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
  min-height: 4px;
}

.dash-bar:hover { filter: brightness(1.15); }
.dash-bar-quote { background: linear-gradient(180deg, #60A5FA, #3B82F6); }
.dash-bar-order { background: linear-gradient(180deg, #34D399, #10B981); }

.dash-bar-tooltip {
  display: none;
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: #FFFFFF;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.dash-bar-tooltip::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--brand);
}

.dash-bar:hover .dash-bar-tooltip { display: block; }
.dash-bar-label { font-size: 0.75rem; color: var(--tertiary); margin-top: 6px; }

/* ============================================
   CHART SUMMARY
   ============================================ */

.chart-summary {
  display: flex;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tint);
}

.chart-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-summary-label { font-size: 0.75rem; color: var(--light); }
.chart-summary-value { font-size: 1.125rem; font-weight: 700; color: var(--brand); }
.chart-summary-value.highlight { color: #10B981; }

/* ============================================
   DARK MODE (대시보드 전용 — sidebar/topbar 제외)
   ============================================ */

body.dark-mode #contentArea { background: var(--brand); }
body.dark-mode .dash-panel { background: var(--secondary); border-color: rgba(255,255,255,0.08); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
body.dark-mode .dash-panel-title { color: #E5E7EB; }
body.dark-mode .dash-panel-title span { color: #9CA3AF; }
body.dark-mode table thead { background: rgba(255,255,255,0.05); border-bottom-color: rgba(255,255,255,0.08); }
body.dark-mode table th { color: #D1D5DB; }
body.dark-mode table td { color: #D1D5DB; border-color: rgba(255,255,255,0.08); }
body.dark-mode table tbody tr:hover { background: rgba(255,255,255,0.04); }
body.dark-mode table td strong { color: #F3F4F6; }
body.dark-mode .db-3 .stat-card { background: var(--secondary); }
body.dark-mode .db-kpi-label { color: #9CA3AF; }
body.dark-mode .db-kpi-value { color: #F3F4F6; }
body.dark-mode .db-kpi-value small { color: #9CA3AF; }
body.dark-mode .status-badge { opacity: 0.9; }
body.dark-mode .status-pending { background: rgba(249,158,11,0.15); color: #FBBF24; }
body.dark-mode .status-completed { background: rgba(34,197,94,0.15); color: #4ADE80; }
body.dark-mode .status-processing { background: rgba(59,130,246,0.15); color: #60A5FA; }
body.dark-mode .status-shipped { background: rgba(139,92,246,0.15); color: #A78BFA; }
body.dark-mode .noti-panel { background: #1F2937; border-color: #374151; }
body.dark-mode .noti-header { border-color: #374151; }
body.dark-mode .noti-title { color: #F3F4F6; }
body.dark-mode .noti-item { border-color: #374151; }
body.dark-mode .noti-item:hover { background: #374151; }
body.dark-mode .noti-item.noti-unread { background: rgba(59,130,246,0.08); }
body.dark-mode .noti-text { color: #E5E7EB; }
body.dark-mode .recent-doc-item { border-color: #374151; }
body.dark-mode .recent-doc-item:hover { background: #374151; }
body.dark-mode .recent-doc-number { color: #E5E7EB; }
body.dark-mode .receivable-item { border-color: rgba(255,255,255,0.08); }
body.dark-mode .receivable-name { color: #F3F4F6; }
body.dark-mode .receivable-date { color: #9CA3AF; }
body.dark-mode .receivable-amount { color: #E5E7EB; }
body.dark-mode .receivable-amount.overdue { color: #FCA5A5; }
body.dark-mode .chart-area { border-color: rgba(255,255,255,0.1); }
body.dark-mode .dash-grid-line { background: rgba(255,255,255,0.06); }
body.dark-mode .chart-y-axis { color: #9CA3AF; }
body.dark-mode .dash-bar-label { color: #D1D5DB; }
body.dark-mode .chart-legend { color: #D1D5DB; }
body.dark-mode .layout-2 { border-color: rgba(255,255,255,0.08); }
body.dark-mode .layout-2 .dash-panel-title { border-color: rgba(255,255,255,0.08); }
body.dark-mode .db-3 .stat-label { color: var(--light); }
body.dark-mode .db-3 .stat-value { color: #E5E7EB; }
body.dark-mode .progress-label-text { color: #E5E7EB; }
body.dark-mode .progress-label-count { background: rgba(59,130,246,0.2); color: #93C5FD; }
body.dark-mode .progress-bar { background: rgba(255,255,255,0.08); }
body.dark-mode .chart-summary { border-color: rgba(255,255,255,0.08); }
body.dark-mode .chart-summary-label { color: #9CA3AF; }
body.dark-mode .chart-summary-value { color: #F3F4F6; }
body.dark-mode .dash-panel strong { color: #E5E7EB; }

/* ============================================
   SCROLLBAR
   ============================================ */

.db-page ::-webkit-scrollbar { width: 8px; }
.db-page ::-webkit-scrollbar-track { background: transparent; }
.db-page ::-webkit-scrollbar-thumb { background: var(--tint); border-radius: 4px; }
.db-page ::-webkit-scrollbar-thumb:hover { background: var(--light); }
