/* ============================
   만나관리 V6 — 통합 스타일
   ============================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f6fa;
  color: #333;
  line-height: 1.5;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font: inherit; }
input, select, textarea { font: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ---------- 로그인 ---------- */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
}
.login-card {
  background: #fff; border-radius: 12px; padding: 48px 40px;
  width: 360px; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.login-title { font-size: 1.8rem; color: #1a237e; margin-bottom: 4px; }
.login-subtitle { color: #666; font-size: 0.9rem; margin-bottom: 32px; }
.login-input {
  width: 100%; padding: 12px 16px; border: 1px solid #ddd;
  border-radius: 8px; font-size: 1rem; margin-bottom: 16px;
  outline: none; transition: border-color .2s;
}
.login-input:focus { border-color: #1a237e; }
.login-btn {
  width: 100%; padding: 12px; background: #1a237e; color: #fff;
  border-radius: 8px; font-size: 1rem; font-weight: 600;
  transition: background .2s;
}
.login-btn:hover { background: #283593; }
.login-error { color: #e53935; font-size: 0.85rem; margin-top: 8px; }

/* ---------- 앱 레이아웃 ---------- */
.app-container { display: flex; min-height: 100vh; }

/* ---------- 사이드바 ---------- */
.sidebar {
  width: 240px; background: #1a237e; color: #fff;
  display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .3s ease;
}
.sidebar-header {
  padding: 20px 16px 16px; display: flex;
  align-items: center; gap: 8px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-title { font-size: 1.2rem; font-weight: 700; }
.sidebar-version {
  background: rgba(255,255,255,0.2); padding: 2px 8px;
  border-radius: 4px; font-size: 0.75rem;
}
.sidebar-close {
  display: none; margin-left: auto; background: none;
  color: #fff; font-size: 1.5rem;
}
.sidebar-menu {
  list-style: none; flex: 1; overflow-y: auto; padding: 8px 0;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: rgba(255,255,255,0.75);
  border-left: 3px solid transparent; transition: all .2s;
  font-size: 0.92rem;
}
.menu-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.menu-item.active {
  background: rgba(255,255,255,0.12); color: #fff;
  border-left-color: #ffd54f;
}
.menu-icon { width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; }
.logout-btn {
  background: rgba(255,255,255,0.15); color: #fff;
  padding: 4px 12px; border-radius: 4px; font-size: 0.8rem;
}
.logout-btn:hover { background: rgba(255,255,255,0.25); }

/* ---------- 메인 콘텐츠 ---------- */
.main-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }

/* ---------- 상단바 ---------- */
.topbar {
  height: 56px; background: #fff; display: flex;
  align-items: center; padding: 0 24px; gap: 16px;
  border-bottom: 1px solid #e0e0e0; position: sticky; top: 0; z-index: 50;
}
.hamburger {
  display: none; background: none; font-size: 1.3rem; color: #333;
}
.page-title { font-size: 1.1rem; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.current-time { font-size: 0.85rem; color: #888; }

/* ---------- 콘텐츠 ---------- */
.content { padding: 24px; flex: 1; }

/* ---------- 카드 ---------- */
.card {
  background: #fff; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 1rem; font-weight: 600; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid #eee;
}

/* ---------- 통계 카드 (가로 나열) ---------- */
.stats-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
  background: #fff; border-radius: 8px; padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); flex: 1; min-width: 160px;
}
.stat-label { font-size: 0.8rem; color: #888; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #1a237e; }
.stat-sub { font-size: 0.75rem; color: #999; margin-top: 2px; }

/* ---------- 검색/필터 바 ---------- */
.filter-bar {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
  align-items: center;
}
.search-input {
  flex: 1; min-width: 200px; padding: 8px 14px;
  border: 1px solid #ddd; border-radius: 6px; outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: #1a237e; }
.filter-select {
  padding: 8px 12px; border: 1px solid #ddd;
  border-radius: 6px; background: #fff; min-width: 100px;
}
.filter-btn {
  padding: 8px 16px; background: #1a237e; color: #fff;
  border-radius: 6px; font-size: 0.85rem; font-weight: 500;
}
.filter-btn:hover { background: #283593; }
.filter-btn.secondary {
  background: #fff; color: #333; border: 1px solid #ddd;
}
.filter-btn.secondary:hover { background: #f5f5f5; }

/* ---------- 테이블 ---------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; font-size: 0.85rem; border: 1px solid #e0e0e0;
}
.data-table thead { background: #f8f9fa; }
.data-table th {
  padding: 10px 12px; text-align: left; font-weight: 600;
  border-bottom: 2px solid #dee2e6; white-space: nowrap;
  position: sticky; top: 0; background: #f8f9fa;
}
.data-table td {
  padding: 8px 12px; border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f5f7ff; }
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* 테이블 정렬 화살표 */
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: #eef; }
.sort-arrow { margin-left: 4px; opacity: 0.3; }
.sort-arrow.active { opacity: 1; }

/* ---------- 페이지네이션 ---------- */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 4px; margin-top: 16px; flex-wrap: wrap;
}
.page-btn {
  padding: 6px 12px; border: 1px solid #ddd;
  border-radius: 4px; background: #fff; font-size: 0.85rem;
  color: #333; transition: all .2s;
}
.page-btn:hover { background: #f0f0f0; }
.page-btn.active { background: #1a237e; color: #fff; border-color: #1a237e; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 0.8rem; color: #888; margin: 0 8px; }

/* ---------- 배지(태그) ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 0.75rem; font-weight: 500;
}
.badge-tax { background: #e3f2fd; color: #1565c0; }
.badge-exempt { background: #fff3e0; color: #ef6c00; }
.badge-frozen { background: #e8eaf6; color: #3949ab; }
.badge-chilled { background: #e0f7fa; color: #00838f; }
.badge-room { background: #fce4ec; color: #c62828; }
.badge-own { background: #e8f5e9; color: #2e7d32; }
.badge-ingredient { background: #fff8e1; color: #f57f17; }
.badge-expense { background: #f3e5f5; color: #7b1fa2; }

/* ---------- 슬라이드오버 ---------- */
.slideover-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 200;
}
.slideover {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px;
  background: #fff; z-index: 201; display: flex; flex-direction: column;
  box-shadow: -4px 0 16px rgba(0,0,0,0.1);
  transform: translateX(0); transition: transform .3s ease;
}
.slideover-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #eee;
}
.slideover-title { font-size: 1.1rem; font-weight: 600; }
.slideover-close { background: none; font-size: 1.5rem; color: #999; }
.slideover-close:hover { color: #333; }
.slideover-body { flex: 1; overflow-y: auto; padding: 20px; }

/* 슬라이드오버 폼 */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: #555; margin-bottom: 4px;
}
.form-input {
  width: 100%; padding: 8px 12px; border: 1px solid #ddd;
  border-radius: 6px; font-size: 0.9rem;
}
.form-input:focus { border-color: #1a237e; outline: none; }
.form-input:disabled { background: #f5f5f5; color: #999; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-actions {
  display: flex; gap: 8px; padding: 16px 20px;
  border-top: 1px solid #eee; background: #fff;
}
.btn-primary {
  padding: 10px 24px; background: #1a237e; color: #fff;
  border-radius: 6px; font-weight: 600;
}
.btn-primary:hover { background: #283593; }
.btn-secondary {
  padding: 10px 24px; background: #fff; color: #333;
  border: 1px solid #ddd; border-radius: 6px;
}
.btn-secondary:hover { background: #f5f5f5; }
.btn-danger {
  padding: 10px 24px; background: #e53935; color: #fff;
  border-radius: 6px; font-weight: 600;
}

/* ---------- 토스트 알림 ---------- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999; display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: 8px; color: #fff;
  font-size: 0.9rem; max-width: 360px; animation: toastIn .3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.success { background: #43a047; }
.toast.error { background: #e53935; }
.toast.info { background: #1565c0; }
.toast.warning { background: #ef6c00; }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- 로딩 ---------- */
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: #888;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid #e0e0e0;
  border-top-color: #1a237e; border-radius: 50%;
  animation: spin .8s linear infinite; margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 빈 상태 ---------- */
.empty-state {
  text-align: center; padding: 60px 20px; color: #999;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 1rem; }

/* ---------- 반응형 ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .slideover { width: 100%; }
}
@media (max-width: 768px) {
  .content { padding: 16px; }
  .stats-row { flex-direction: column; }
  .filter-bar { flex-direction: column; }
  .search-input { min-width: unset; }
}

/* ---------- 인쇄 ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .hamburger, .filter-bar,
  .pagination, .toast-container, .slideover-backdrop,
  .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; }
  .data-table { font-size: 10pt; }
  .data-table th { background: #eee !important; -webkit-print-color-adjust: exact; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
}

/* ---------- PIP 모드 ---------- */
.pip-container {
  position: fixed; bottom: 20px; right: 20px;
  width: 340px; height: 440px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  z-index: 9999; overflow: hidden;
  display: flex; flex-direction: column;
  border: 2px solid #1a237e;
  resize: both;
}
.pip-header {
  background: #1a237e; color: #fff;
  padding: 8px 12px; display: flex;
  justify-content: space-between; align-items: center;
  cursor: move; user-select: none;
  font-size: 0.85rem; font-weight: 600;
}
.pip-header button { background: none; color: #fff; font-size: 1.2rem; padding: 0 4px; }
.pip-body { flex: 1; overflow-y: auto; padding: 12px; font-size: 0.85rem; }

/* ---------- 메뉴 구분선 ---------- */
.menu-divider { height: 1px; background: rgba(255,255,255,0.15); margin: 8px 16px; }

/* ---------- OCR ---------- */
.ocr-preview { max-width: 100%; max-height: 300px; border-radius: 8px; border: 2px dashed #ccc; }
.ocr-upload-zone {
  border: 2px dashed #ccc; border-radius: 12px; padding: 32px;
  text-align: center; cursor: pointer; transition: border-color 0.2s;
  background: #fafbfc;
}
.ocr-upload-zone:hover { border-color: #1a237e; background: #f0f1ff; }
.ocr-result-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.ocr-result-table th { background: #f5f6fa; padding: 8px; border: 1px solid #e0e0e0; font-size: 0.85rem; }
.ocr-result-table td { padding: 6px 8px; border: 1px solid #e0e0e0; }
.ocr-result-table input { width: 100%; border: none; background: transparent; padding: 2px; }
.ocr-mode-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.ocr-mode-tab {
  padding: 8px 16px; border-radius: 8px; border: 1px solid #ddd;
  background: #fff; cursor: pointer; font-weight: 500;
}
.ocr-mode-tab.active { background: #1a237e; color: #fff; border-color: #1a237e; }

/* ---------- 도구 카드 ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tool-card {
  background: #fff; border-radius: 10px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08); border: 1px solid #eee;
}
.tool-card h3 { font-size: 1rem; margin-bottom: 12px; color: #1a237e; }
.tool-card .tool-btn {
  padding: 8px 16px; border-radius: 6px; background: #1a237e;
  color: #fff; font-size: 0.85rem; margin-top: 8px;
}
.tool-card .tool-btn:hover { background: #283593; }
.tool-card .tool-btn.danger { background: #c62828; }
.tool-card .tool-btn.danger:hover { background: #d32f2f; }
