/* =============================================
   토탈지원 - 관리자 스타일
   ============================================= */

:root {
  --admin-primary: #0F2B5B;
  --admin-secondary: #2563EB;
  --admin-accent: #F59E0B;
  --admin-bg: #F0F4F8;
  --admin-sidebar-width: 240px;
  --admin-header-height: 60px;
  --text: #1F2937;
  --text-light: #6B7280;
  --border: #E5E7EB;
  --bg-white: #FFFFFF;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.25s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.admin-body {
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  background: var(--admin-bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- 관리자 레이아웃 --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* --- 사이드바 --- */
.admin-sidebar {
  width: var(--admin-sidebar-width);
  background: var(--admin-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  overflow-y: auto;
  transition: var(--transition);
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--admin-header-height);
}

.sidebar-logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

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

.sidebar-nav-section {
  margin-bottom: 4px;
}

.sidebar-nav-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 8px 6px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav-item i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-nav-item.active {
  background: var(--admin-secondary);
  color: #fff;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* --- 메인 컨텐츠 영역 --- */
.admin-main {
  margin-left: var(--admin-sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  height: var(--admin-header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--admin-primary);
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-site-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.topbar-site-link:hover {
  color: var(--admin-secondary);
  border-color: var(--admin-secondary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-light);
}

.topbar-user-avatar {
  width: 32px;
  height: 32px;
  background: var(--admin-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.admin-content {
  padding: 28px 24px;
  flex: 1;
}

/* --- 페이지 헤더 --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--admin-primary);
}

.page-header-desc {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- 카드 --- */
.admin-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.admin-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--admin-primary);
}

.admin-card-body {
  padding: 20px;
}

/* --- 통계 카드 --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #EFF6FF; color: var(--admin-secondary); }
.stat-icon.green { background: #ECFDF5; color: var(--success); }
.stat-icon.yellow { background: #FFFBEB; color: var(--admin-accent); }
.stat-icon.red { background: #FEF2F2; color: var(--danger); }
.stat-icon.purple { background: #F5F3FF; color: #7C3AED; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--admin-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- 테이블 --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--admin-bg);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--admin-bg); }

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

.badge-success { background: #ECFDF5; color: var(--success); }
.badge-danger { background: #FEF2F2; color: var(--danger); }
.badge-warning { background: #FFFBEB; color: #D97706; }
.badge-info { background: #EFF6FF; color: var(--admin-secondary); }
.badge-gray { background: #F3F4F6; color: #4B5563; }

/* --- 버튼 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--admin-secondary);
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover { background: #059669; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: var(--admin-primary);
}

.btn-warning:hover { background: #d97706; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-light);
}

.btn-outline:hover {
  border-color: var(--admin-secondary);
  color: var(--admin-secondary);
}

.btn-ghost {
  background: none;
  color: var(--text-light);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--admin-bg);
  color: var(--text);
}

/* --- 폼 --- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}

.form-label .req {
  color: var(--danger);
  margin-left: 3px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-white);
  transition: var(--transition);
  font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--admin-secondary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
  outline: none;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
}

/* 이미지 업로드 --- */
.image-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--admin-bg);
  position: relative;
}

.image-upload-zone:hover,
.image-upload-zone.dragover {
  border-color: var(--admin-secondary);
  background: #EFF6FF;
}

.image-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 36px;
  color: var(--admin-secondary);
  margin-bottom: 12px;
}

.upload-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 13px;
  color: var(--text-light);
}

/* 이미지 미리보기 - 세로 크기 제한 없음 */
.image-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--admin-bg);
}

.image-preview img {
  width: 100%;
  /* height 고정 제거 */
  height: auto;
  object-fit: contain;
  display: block;
}

.image-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.image-preview-remove:hover {
  background: var(--danger);
}

/* 갤러리 그리드 */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.gallery-slot {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  background: var(--admin-bg);
  overflow: hidden;
}

.gallery-slot:hover {
  border-color: var(--admin-secondary);
  background: #EFF6FF;
}

.gallery-slot.has-image {
  border-style: solid;
  border-color: var(--border);
}

.gallery-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-slot .slot-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-light);
  pointer-events: none;
}

.gallery-slot .slot-add i { font-size: 24px; }
.gallery-slot .slot-add span { font-size: 12px; }

.gallery-slot .slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  border: none;
  z-index: 2;
}

.gallery-slot .slot-remove:hover {
  background: var(--danger);
}

.gallery-slot input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

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

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.25s ease;
}

.modal-sm { max-width: 420px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1000px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 1;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--admin-primary);
}

.modal-close {
  background: none;
  font-size: 18px;
  color: var(--text-light);
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  line-height: 1;
}

.modal-close:hover {
  background: var(--admin-bg);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: var(--bg-white);
}

/* --- 탭 --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--admin-secondary);
}

.tab-btn.active {
  color: var(--admin-secondary);
  border-bottom-color: var(--admin-secondary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* --- 검색 + 필터 바 --- */
.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg-white);
  font-family: inherit;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--admin-secondary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
  outline: none;
}

/* --- 상태 표시 --- */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.active::before { background: var(--success); }
.status-dot.inactive::before { background: var(--text-light); }
.status-dot.pending::before { background: var(--warning); }

/* --- 알림 --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-info { background: #EFF6FF; color: #1d4ed8; border-left: 3px solid #2563EB; }
.alert-success { background: #ECFDF5; color: #065f46; border-left: 3px solid var(--success); }
.alert-warning { background: #FFFBEB; color: #92400e; border-left: 3px solid var(--warning); }
.alert-danger { background: #FEF2F2; color: #991b1b; border-left: 3px solid var(--danger); }

/* --- 토스트 메시지 --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 280px;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--admin-secondary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-icon { font-size: 18px; }
.toast-icon.success { color: var(--success); }
.toast-icon.error { color: var(--danger); }
.toast-icon.warning { color: var(--warning); }
.toast-icon.info { color: var(--admin-secondary); }

.toast-msg {
  flex: 1;
  font-size: 14px;
  color: var(--text);
}

.toast-close {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
}

/* --- 빈 상태 --- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state i {
  font-size: 48px;
  color: var(--text-light);
  opacity: 0.4;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-light);
  opacity: 0.7;
}

/* --- 반응형 --- */
@media (max-width: 1024px) {
  :root { --admin-sidebar-width: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- 견적서 출력 스타일 --- */
@media print {
  .admin-sidebar, .admin-topbar, .modal-footer,
  .no-print { display: none !important; }
  
  .admin-main { margin-left: 0; }
  .modal-overlay { position: static; background: none; }
  .modal-box { box-shadow: none; max-height: none; }
  
  .quote-preview { border: none; }
  
  @page { size: A4; margin: 15mm; }
}
