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

html,
body {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  height: calc(var(--vh, 1vh) * 100); /* Fallback for CSS custom properties */
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* 모바일 Safari 및 iOS 디바이스 최적화 */
@supports (-webkit-touch-callout: none) {
  html,
  body {
    height: -webkit-fill-available;
  }
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.app-container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--vh, 1vh) * 100);
  max-width: 1200px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  padding: 20px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="0.5" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  pointer-events: none;
}

.header h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  color: white;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
  line-height: 1.2;
}

.header p {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  position: relative;
  z-index: 1;
}

.main-content {
  flex: 1;
  padding: 30px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 30px;
}

.control-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  flex-shrink: 0;
}

.control-card {
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.control-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.control-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.control-card:hover::before {
  transform: scaleX(1);
}

.card-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title i {
  color: #667eea;
  font-size: 1.2rem;
}

.file-input-container {
  position: relative;
  margin-bottom: 20px;
}

.file-input {
  display: none;
}

.file-input-label {
  display: inline-block;
  padding: 16px 24px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
  position: relative;
  overflow: hidden;
}

.file-input-label::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.file-input-label:hover::before {
  left: 100%;
}

.file-input-label:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
}

.file-input-label i {
  margin-right: 8px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

.btn-primary i {
  font-size: 1.1rem;
}

.btn-primary.loading {
  pointer-events: none;
  position: relative;
}

.btn-primary.loading::after {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

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

.result-section {
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.8);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.result-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-title i {
  color: #667eea;
}

.result-content {
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  min-height: 200px;
}

.result-content:empty::before {
  content: "결과가 여기에 표시됩니다...";
  color: #94a3b8;
  font-style: italic;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.product-item {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
  animation: fadeInUp 0.5s ease-out forwards;
  opacity: 0;
}

.product-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.product-item:nth-child(1) {
  animation-delay: 0.1s;
}
.product-item:nth-child(2) {
  animation-delay: 0.2s;
}
.product-item:nth-child(3) {
  animation-delay: 0.3s;
}
.product-item:nth-child(4) {
  animation-delay: 0.4s;
}
.product-item:nth-child(5) {
  animation-delay: 0.5s;
}

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

.product-info {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.5;
}

.product-no {
  font-weight: 600;
  color: #667eea;
}

.product-name {
  font-weight: 500;
  color: #1f2937;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.status-waiting {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
}

.status-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.status-error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.status-loading {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.status-indicator i {
  font-size: 0.9rem;
}

/* 커스텀 스크롤바 스타일 */
.result-content::-webkit-scrollbar {
  width: 8px;
}

.result-content::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.result-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
}

.result-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .app-container {
    margin: 0;
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
  }

  .header {
    padding: 20px 15px;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .main-content {
    padding: 20px 15px;
    gap: 20px;
  }

  .control-section {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .control-card {
    padding: 20px;
  }

  .result-section {
    padding: 20px;
  }

  .result-content {
    min-height: 150px;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 15px 10px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .header p {
    font-size: 0.9rem;
  }

  .main-content {
    padding: 15px 10px;
    gap: 15px;
  }

  .control-card {
    padding: 15px;
  }

  .btn-primary {
    padding: 12px 20px;
    font-size: 0.9rem;
  }

  .result-section {
    padding: 15px;
  }

  .result-content {
    min-height: 120px;
    padding: 15px;
  }

  .card-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
  }

  .status-indicator {
    margin-bottom: 12px;
  }
}
