/* ============ Reset & Base ============ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img {
  image-orientation: none;
}

body {
  font-family: 'Nanum Gothic', 'Malgun Gothic', sans-serif;
  font-size: 14px;
  background: #F0F4F8;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
}

/* ============ Layout ============ */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ Header ============ */
.app-header {
  text-align: center;
  margin-bottom: 32px;
}

.app-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #2563EB;
  letter-spacing: -0.5px;
}

.app-subtitle {
  font-size: 14px;
  color: #64748b;
  margin-top: 4px;
}

/* ============ Cards ============ */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 24px;
}

.section-card {
  margin-bottom: 24px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1e293b;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
}

/* ============ Upload Area ============ */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafbfc;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #2563EB;
  background: #eff6ff;
}

.drop-zone.drag-over {
  box-shadow: inset 0 0 0 2px #2563EB;
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: #94a3b8;
  display: block;
}

.drop-zone:hover .upload-icon,
.drop-zone.drag-over .upload-icon {
  color: #2563EB;
}

.drop-text {
  font-size: 16px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 8px;
}

.drop-sub {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 12px;
}

.drop-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 12px;
}

/* ============ Loading ============ */
.loading {
  text-align: center;
  padding: 32px;
}

.loading p {
  color: #64748b;
  font-size: 14px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #2563EB;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: #e2e8f0;
  color: #475569;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

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

.btn-lg {
  padding: 12px 28px;
  font-size: 16px;
}

.btn-full {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal {
  max-width: 420px;
  text-align: center;
  animation: modalIn 0.2s ease;
}

.modal h3 {
  margin-bottom: 12px;
}

.modal p {
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-buttons {
  justify-content: center;
}

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

/* ============ Edit Layout ============ */
.edit-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.left-panel {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
}

.right-panel {
  flex: 1;
  min-width: 0;
}

.right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.right-panel-header h2 {
  margin-bottom: 0;
}

/* ============ Form ============ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: auto;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-group input::placeholder {
  color: #9ca3af;
}

.form-actions {
  margin-top: 24px;
}

/* ============ Rotation Controls ============ */
.rotation-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* ============ Crop Container ============ */
#crop-container {
  border-radius: 8px;
  background: #f1f5f9;
  overflow: hidden;
  min-height: 200px;
}

#crop-container img {
  max-width: 100%;
  display: block;
}

/* ============ Preview ============ */
.hint-text {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 16px;
}

#preview-wrapper {
  display: flex;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 16px;
  overflow: auto;
}

#preview-container {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#preview-image {
  display: block;
  max-width: 900px;
  max-height: 600px;
  border-radius: 4px;
}

/* ============ Text Box Overlay ============ */
#text-box {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  padding: 8px 12px;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Nanum Gothic', 'Malgun Gothic', sans-serif;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.5;
  z-index: 10;
  min-width: 80px;
  min-height: 30px;
  overflow: hidden;
}

#text-content {
  pointer-events: none;
}

#text-content .text-line {
  white-space: nowrap;
}

/* ============ Resize Handles ============ */
.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #2563EB;
  border: 2px solid #fff;
  border-radius: 2px;
  z-index: 20;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.rh-nw { top: -6px; left: -6px; cursor: nw-resize; }
.rh-ne { top: -6px; right: -6px; cursor: ne-resize; }
.rh-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.rh-se { bottom: -6px; right: -6px; cursor: se-resize; }

.preview-actions {
  margin-top: 20px;
  justify-content: center;
}

/* ============ Cropper.js Overrides ============ */
.cropper-view-box,
.cropper-face {
  border-radius: 0;
}

.cropper-line,
.cropper-point {
  background-color: #2563EB;
}

.cropper-modal {
  background-color: #000;
  opacity: 0.5;
}
