/* 재고조사 앱 전역 스타일 */

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

:root {
  /* 색상 팔레트 */
  --primary: hsl(220, 90%, 56%);
  --primary-dark: hsl(220, 90%, 45%);
  --primary-light: hsl(220, 90%, 96%);
  --secondary: hsl(160, 84%, 39%);
  --success: hsl(142, 76%, 36%);
  --warning: hsl(38, 92%, 50%);
  --danger: hsl(0, 84%, 60%);
  --bg: hsl(0, 0%, 98%);
  --surface: hsl(0, 0%, 100%);
  --text: hsl(220, 13%, 18%);
  --text-secondary: hsl(220, 9%, 46%);
  --border: hsl(220, 13%, 91%);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* 컨테이너 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* 헤더 */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* 네비게이션 */
nav {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

nav a {
  padding: 10px 20px;
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
}

nav a:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

nav a.active {
  background: var(--primary);
  color: white;
}

/* 카드 */
.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* 버튼 */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-secondary {
  background: var(--text-secondary);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

/* 입력 필드 */
input[type="text"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* 검색바 */
.search-box {
  position: relative;
  margin-bottom: 24px;
}

.search-box input {
  padding-left: 48px;
  font-size: 1.1rem;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 1.2rem;
}

/* 제품 리스트 */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s;
  align-items: center;
}

.product-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.product-item.has-quantity {
  background: hsl(142, 76%, 96%);
  border-color: var(--success);
}

.product-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.product-info .code {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-family: "Courier New", monospace;
}

.quantity-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quantity-input input {
  width: 100px;
  text-align: center;
  font-weight: 600;
  font-size: 1.1rem;
}

.quantity-input label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* 드래그 앤 드롭 영역 */
.dropzone {
  border: 3px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--primary-light);
}

.dropzone:hover {
  border-color: var(--primary);
  background: var(--surface);
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.02);
}

.dropzone-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.dropzone h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text);
}

.dropzone p {
  color: var(--text-secondary);
}

/* 프로그레스 바 */
.progress {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 16px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* 알림 메시지 */
.alert {
  padding: 16px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.alert-success {
  background: hsl(142, 76%, 95%);
  color: var(--success);
  border: 1px solid var(--success);
}

.alert-error {
  background: hsl(0, 84%, 97%);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.alert-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
}

/* 로딩 스피너 */
.spinner {
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 테이블 */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

thead {
  background: var(--primary-light);
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--primary);
}

tbody tr:hover {
  background: var(--bg);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* 유틸리티 클래스 */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-secondary);
}

.mt-1 {
  margin-top: 8px;
}
.mt-2 {
  margin-top: 16px;
}
.mt-3 {
  margin-top: 24px;
}
.mb-1 {
  margin-bottom: 8px;
}
.mb-2 {
  margin-bottom: 16px;
}
.mb-3 {
  margin-bottom: 24px;
}

.hidden {
  display: none;
}

/* 반응형 디자인 - 모바일 */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  header h1 {
    font-size: 1.2rem;
  }

  nav {
    gap: 8px;
  }

  nav a {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .card {
    padding: 16px;
  }

  .product-item {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .quantity-input {
    justify-content: flex-end;
  }

  .quantity-input input {
    width: 80px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  table {
    font-size: 0.9rem;
  }

  th,
  td {
    padding: 8px 12px;
  }
}

/* 다크 모드 지원 (선택적) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(220, 13%, 10%);
    --surface: hsl(220, 13%, 15%);
    --text: hsl(0, 0%, 95%);
    --text-secondary: hsl(220, 9%, 70%);
    --border: hsl(220, 13%, 25%);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .product-item.has-quantity {
    background: hsl(142, 76%, 15%);
    border-color: var(--success);
  }
}

/* 로그인 입력 진동 애니메이션 */
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

.shake {
  animation: shake 0.3s ease-in-out;
  border-color: var(--danger) !important;
}
