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

:root {
  --instagram-gradient: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  --primary: #5b4fcf;
  --primary-light: #7c72db;
  --secondary: #00b4d8;
  --success: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
  --bg: #f0f2f7;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.15);
}

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

/* ===== LAYOUT ===== */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

.main-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  padding: 40px 20px;
  background: var(--instagram-gradient);
  border-radius: var(--radius);
  color: white;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.15);
}
.header > * { position: relative; z-index: 1; }
.logo { display: flex; align-items: center; justify-content: center; gap: 12px; }
.logo i { font-size: 40px; }
.logo h1 { font-size: 28px; font-weight: 800; }
.subtitle { opacity: 0.9; margin-top: 8px; font-size: 16px; }

/* ===== CARD ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s;
  position: relative;
}
.card:hover { box-shadow: var(--shadow-hover); }

.step-card { border-top: 4px solid var(--primary); }
.step-badge {
  position: absolute;
  top: -1px; right: 24px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 0 0 8px 8px;
  letter-spacing: 1px;
}

.card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.card h2 i { color: var(--primary); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.required { color: var(--danger); }

textarea, input[type="text"], input[type="date"], select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: #fafafa;
  transition: border-color 0.2s, background 0.2s;
  font-family: inherit;
}
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}
textarea { resize: vertical; }

/* ===== AI SELECTOR ===== */
.ai-selector { display: flex; gap: 12px; }
.ai-option { flex: 1; cursor: pointer; }
.ai-option input { display: none; }
.ai-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 600;
}
.ai-card i { font-size: 24px; color: var(--primary); }
.ai-card img { width: 28px; height: 28px; object-fit: contain; }
.ai-option input:checked + .ai-card {
  border-color: var(--primary);
  background: #f0eeff;
  color: var(--primary);
}

/* ===== STYLE GRID ===== */
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-option input { display: none; }
.style-card {
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.style-option input:checked + .style-card {
  border-color: var(--secondary);
  background: #e0f7fc;
}

/* ===== RATIO SELECTOR ===== */
.ratio-selector { display: flex; gap: 8px; }
.ratio-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--border);
  background: white;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.ratio-btn.active {
  border-color: var(--primary);
  background: #f0eeff;
  color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-instagram { background: var(--instagram-gradient); color: white; font-size: 16px; padding: 16px; }
.btn-instagram:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(188,24,136,0.4); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-danger { background: var(--danger); color: white; }

/* ===== RESULT AREA ===== */
.result-area {
  min-height: 120px;
  margin-bottom: 16px;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--text-muted);
  gap: 10px;
  border: 2px dashed var(--border);
  border-radius: 10px;
}
.empty-state i { font-size: 24px; }

.result-item {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.result-item:hover { border-color: var(--primary); background: #fafafe; }
.result-item.selected {
  border-color: var(--primary);
  background: #f0eeff;
}
.result-item .model-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
  display: inline-block;
}
.result-item p { font-size: 14px; line-height: 1.6; }
.select-btn {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 11px;
  padding: 4px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.selected-content label { font-size: 13px; font-weight: 700; color: var(--success); margin-bottom: 8px; display: block; }
.selected-content small { color: var(--text-muted); font-size: 12px; }

/* ===== IMAGE GRID ===== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.image-item {
  aspect-ratio: 1;
  border: 3px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}
.image-item img { width: 100%; height: 100%; object-fit: cover; }
.image-item:hover { border-color: var(--primary); }
.image-item.selected { border-color: var(--primary); }
.image-item.selected::after {
  content: '✓ 선택됨';
  position: absolute;
  inset: 0;
  background: rgba(91,79,207,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

/* ===== SCHEDULE ===== */
.schedule-options { display: flex; gap: 20px; }
.radio-inline { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.time-display {
  margin-top: 8px;
  padding: 10px 14px;
  background: #f0f9ff;
  border-radius: 8px;
  font-size: 13px;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== PREVIEW ===== */
.preview-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
  background: white;
}
.preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.preview-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--instagram-gradient);
}
.preview-image-wrap {
  width: 100%;
  padding-top: 100%;
  position: relative;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-image-wrap > i {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  color: #ddd;
}
.preview-image-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-caption {
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  max-height: 80px;
  overflow: hidden;
  color: var(--text-muted);
}

/* ===== SCHEDULE TABLE ===== */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.schedule-table th {
  background: #f8f9fa;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}
.schedule-table td {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.empty-row { text-align: center; color: var(--text-muted); padding: 40px !important; }

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.status-pending { background: #fff3cd; color: #856404; }
.status-posted { background: #d4edda; color: #155724; }
.status-failed { background: #f8d7da; color: #721c24; }

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}
.loading-box {
  background: white;
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  min-width: 200px;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid #f0eeff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { font-weight: 600; color: var(--text-muted); }

.link-small { font-size: 12px; color: var(--primary); text-decoration: none; display: block; margin-top: 6px; }
.link-small:hover { text-decoration: underline; }
