/* 기본 리셋 & CSS 변수 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.hidden {
  display: none !important;
}

.mt-12 {
  margin-top: 12px;
}

/* 시스템 에러 배너 */
.error-banner {
  background-color: var(--danger-bg);
  border-bottom: 2px solid var(--danger);
  padding: 14px 20px;
  color: #991b1b;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.banner-content {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.banner-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.banner-text {
  flex-grow: 1;
}

.banner-text strong {
  font-size: 1rem;
  display: block;
  margin-bottom: 4px;
}

.banner-text p {
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: #b91c1c;
}

.error-detail-box {
  background: #450a0a;
  color: #fecaca;
  padding: 10px 14px;
  border-radius: 6px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.8rem;
  margin-top: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.close-banner {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: #991b1b;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

/* 메인 헤더 */
.main-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 24px 0;
  margin-bottom: 24px;
}

.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 2.4rem;
}

.brand h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 버튼 공통 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

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

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

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

.btn-outline-sm {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline-sm:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* 1. 미니멀 달력 카드 스타일 */
.calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  margin: 0 auto 24px auto;
  max-width: 440px; /* 미니멀한 콤팩트 사이즈 */
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-nav h2 {
  font-size: 1.15rem;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
}

.nav-arrow-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.nav-arrow-btn:hover {
  background: #e2e8f0;
  color: var(--primary);
}

.legend {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot-sample {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.dot-sample.has-note {
  background-color: var(--primary);
}

.dot-sample.today {
  border: 1.5px solid var(--primary);
}

.dot-sample.selected {
  background-color: #f59e0b;
}

/* 요일 및 날짜 그리드 (미니멀 컴팩트) */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
}

.weekday.sun {
  color: #ef4444;
}

.weekday.sat {
  color: #3b82f6;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-top: 4px;
}

/* 날짜 개별 셀 (미니멀) */
.day-cell {
  height: 42px;
  min-height: 42px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  position: relative;
  background-color: #ffffff;
}

.day-cell:hover {
  background-color: #f1f5f9;
  border-color: var(--border-color);
}

.day-cell.other-month {
  opacity: 0.25;
}

.day-cell.today .day-number {
  color: var(--primary);
  font-weight: 800;
  border-bottom: 2px solid var(--primary);
}

.day-cell.selected {
  background-color: #eff6ff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1.5px var(--primary);
}

.day-number {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
}

.day-cell.sunday .day-number {
  color: #ef4444;
}

.day-cell.saturday .day-number {
  color: #3b82f6;
}

/* 미니멀 인디케이터 도트/뱃지 */
.note-dot {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 50%;
  margin-top: 2px;
  display: inline-block;
}

.note-dot.has-count {
  width: auto;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background-color: var(--primary);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* 2. 하단 상세 정보 영역 */
.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 40px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-title-group h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.count-badge {
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

/* 프롬프트 상세 카드 */
.detail-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.prompt-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.prompt-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.prompt-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
}

.prompt-card-header h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
}

.card-title-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.card-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.group-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.time-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-card-action {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-card-action:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-card-action.delete:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* 프롬프트 본문 박스 (에디터/코드 톤) */
.prompt-box-wrapper {
  margin: 12px 0;
  position: relative;
}

.prompt-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b;
  color: #94a3b8;
  padding: 8px 14px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.copy-btn {
  background: #334155;
  border: none;
  color: #f8fafc;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #475569;
}

.prompt-content-code {
  background: #0f172a;
  color: #f1f5f9;
  padding: 16px;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* 부연 설명 박스 */
.description-box {
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin-top: 12px;
}

.description-box strong {
  display: block;
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.description-box p {
  font-size: 0.9rem;
  color: #475569;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-meta {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}

/* 빈 상태 */
.empty-detail {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-detail .empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}

.empty-detail h4 {
  font-size: 1.15rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

/* 3. 모달 레이어 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

textarea {
  resize: vertical;
}

.modal-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 14px;
  min-height: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* 푸터 */
.main-footer {
  margin-top: auto;
  text-align: center;
  padding: 30px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: #ffffff;
}

/* 반응형 */
@media (max-width: 640px) {
  .calendar-card {
    padding: 12px;
  }
  .day-cell {
    height: 38px;
    min-height: 38px;
  }
  .cal-nav h2 {
    font-size: 1.05rem;
    min-width: 90px;
  }
}
