/**
 * library-styles.css
 * SEM Library 공통 스타일.
 * semtree.kr 메인 팔레트 (sage/olive forest) 기반.
 * 학생 페이지와 관리자 페이지 양쪽에서 import.
 *
 * 폰트: Cinzel (display, 책 제목/헤더), Montserrat (body, UI), Noto Sans KR (한글)
 */

/* ═════════════════════════════════════════════════════════════════
   1. 디자인 토큰 (CSS Variables)
   ───────────────────────────────────────────────────────────────── */

:root {
  /* SEM 메인 팔레트 */
  --sage-light:    #E5E2D9;   /* 밝은 세이지 (배경) */
  --sage:          #C8C5BA;   /* 메인 세이지 (카드, 보더) */
  --sage-dark:     #A8A599;   /* 짙은 세이지 (호버, 강조) */
  --forest:        #082510;   /* 다크 포레스트 (텍스트, 강조) */
  --forest-light:  #1A4A28;   /* 밝은 포레스트 (보조 텍스트) */
  --olive:         #6B7142;   /* 올리브 (액센트) */
  --olive-light:   #8A9159;

  /* 중립색 */
  --bg:            #F5F3EC;   /* 페이지 배경 */
  --bg-card:       #FFFFFF;   /* 카드 배경 */
  --bg-overlay:    rgba(8, 37, 16, 0.85);
  --text-primary:  #082510;
  --text-secondary:#5A5E4A;
  --text-muted:    #8A8B7E;
  --border:        #D9D6CB;
  --border-strong: #B8B5A8;

  /* 상태 */
  --success: #2E7D32;
  --warning: #ED6C02;
  --error:   #C62828;
  --info:    #0277BD;

  /* 그림자 */
  --shadow-sm: 0 1px 2px rgba(8, 37, 16, 0.06);
  --shadow-md: 0 4px 12px rgba(8, 37, 16, 0.08);
  --shadow-lg: 0 12px 32px rgba(8, 37, 16, 0.12);
  --shadow-xl: 0 24px 64px rgba(8, 37, 16, 0.16);

  /* 폰트 */
  --font-display: 'Cinzel', 'Noto Serif KR', serif;
  --font-body:    'Montserrat', 'Noto Sans KR', sans-serif;
  --font-mono:    'JetBrains Mono', 'Consolas', monospace;

  /* 간격 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* 라운딩 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* 전환 */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* 레이아웃 */
  --max-width-content: 1400px;
  --header-height: 64px;
}

/* ═════════════════════════════════════════════════════════════════
   2. 베이스 리셋 + 타이포그래피
   ───────────────────────────────────────────────────────────────── */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
  color: var(--forest);
  letter-spacing: -0.01em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p { margin: 0; }

a {
  color: var(--forest-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--forest);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ═════════════════════════════════════════════════════════════════
   3. 레이아웃: 헤더 / 컨테이너
   ───────────────────────────────────────────────────────────────── */

.lib-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  backdrop-filter: blur(8px);
  background: rgba(245, 243, 236, 0.92);
}

.lib-header-inner {
  width: 100%;
  max-width: var(--max-width-content);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.lib-brand {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--forest);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.lib-brand-mark {
  width: 28px;
  height: 28px;
  background: var(--forest);
  color: var(--sage);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
}

.lib-container {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--space-6);
}

.lib-section {
  margin-bottom: var(--space-8);
}

/* ═════════════════════════════════════════════════════════════════
   4. 버튼
   ───────────────────────────────────────────────────────────────── */

.lib-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.lib-btn:hover:not(:disabled) {
  background: var(--sage-light);
  border-color: var(--sage-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.lib-btn:active:not(:disabled) {
  transform: translateY(0);
}

.lib-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lib-btn-primary {
  background: var(--forest);
  color: white;
  border-color: var(--forest);
}
.lib-btn-primary:hover:not(:disabled) {
  background: var(--forest-light);
  border-color: var(--forest-light);
  color: white;
}

.lib-btn-ghost {
  background: transparent;
  border-color: transparent;
}
.lib-btn-ghost:hover:not(:disabled) {
  background: var(--sage-light);
}

.lib-btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
}
.lib-btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: 16px;
}

/* ═════════════════════════════════════════════════════════════════
   5. 입력 필드 / 검색
   ───────────────────────────────────────────────────────────────── */

.lib-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.lib-input:focus {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(8, 37, 16, 0.08);
}

.lib-search {
  position: relative;
  flex: 1;
  max-width: 480px;
}
.lib-search-input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  font-size: 14px;
  transition: all var(--transition-fast);
}
.lib-search-input:focus {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(8, 37, 16, 0.08);
}
.lib-search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

.lib-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 14px;
  cursor: pointer;
}

/* ═════════════════════════════════════════════════════════════════
   6. 컬러 라벨 칩 (학원 A.R. Chart)
   ───────────────────────────────────────────────────────────────── */

.color-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  font-family: var(--font-body);
  white-space: nowrap;
  line-height: 1.4;
}
.color-chip-sm {
  padding: 1px 6px;
  font-size: 10px;
}
.color-chip-md {
  padding: 2px 8px;
  font-size: 11px;
}
.color-chip-lg {
  padding: 4px 12px;
  font-size: 13px;
}
.color-chip-none {
  background: var(--sage-light);
  color: var(--text-muted);
  font-style: italic;
}

/* ═════════════════════════════════════════════════════════════════
   7. 책 표지 (cover)
   ───────────────────────────────────────────────────────────────── */

.book-cover-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sage-light);
  overflow: hidden;
  border-radius: var(--radius-sm);
  aspect-ratio: 2 / 3;
  width: 100%;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3);
  background: var(--sage);
  color: var(--forest);
}
.book-cover-placeholder-initials {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 600;
  line-height: 1;
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
}
.book-cover-placeholder-title {
  font-size: 11px;
  line-height: 1.3;
  font-weight: 500;
  opacity: 0.92;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ═════════════════════════════════════════════════════════════════
   8. 도서 카드 (그리드 뷰)
   ───────────────────────────────────────────────────────────────── */

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--sage-dark);
}

.book-card-cover {
  position: relative;
  overflow: hidden;
}
.book-card-cover .book-cover-wrap {
  border-radius: 0;
  transition: transform var(--transition-slow);
}
.book-card:hover .book-cover-img {
  transform: scale(1.04);
}

.book-card-color-badge {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 2;
  box-shadow: var(--shadow-sm);
}

.book-card-source-badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 2;
  background: rgba(8, 37, 16, 0.85);
  color: var(--sage);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
}

.book-card-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-card-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--forest);
  margin-bottom: var(--space-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.book-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}

.book-card-atos {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--olive);
  font-size: 13px;
}

.book-card-quiz {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ═════════════════════════════════════════════════════════════════
   9. 리스트 뷰 (대안 표시)
   ───────────────────────────────────────────────────────────────── */

.book-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.book-list-row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto auto auto;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  align-items: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  color: inherit;
}
.book-list-row:last-child {
  border-bottom: none;
}
.book-list-row:hover {
  background: var(--sage-light);
}

.book-list-cover {
  width: 56px;
  height: 84px;
}

.book-list-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--forest);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-list-isbn {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.book-list-atos {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--olive);
  font-size: 14px;
  min-width: 40px;
  text-align: center;
}

.book-list-source {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 32px;
  text-align: center;
}

.book-list-location {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  min-width: 80px;
  text-align: center;
}

@media (max-width: 768px) {
  .book-list-row {
    grid-template-columns: 48px 1fr auto;
  }
  .book-list-source,
  .book-list-location {
    display: none;
  }
}

/* ═════════════════════════════════════════════════════════════════
   10. 그리드 컨테이너
   ───────────────────────────────────────────────────────────────── */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}
@media (min-width: 1200px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-5);
  }
}
@media (max-width: 640px) {
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
}

/* ═════════════════════════════════════════════════════════════════
   11. 뷰 토글
   ───────────────────────────────────────────────────────────────── */

.view-toggle {
  display: inline-flex;
  background: var(--sage-light);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border);
}
.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
}
.view-toggle-btn:hover {
  color: var(--forest);
}
.view-toggle-btn.active {
  background: var(--bg-card);
  color: var(--forest);
  box-shadow: var(--shadow-sm);
}

/* ═════════════════════════════════════════════════════════════════
   12. 필터 바
   ───────────────────────────────────────────────────────────────── */

.lib-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

.lib-toolbar-group {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.lib-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* 컬러 필터 칩 그리드 */
.color-filter-row {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.color-filter-chip {
  cursor: pointer;
  opacity: 0.5;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}
.color-filter-chip:hover {
  opacity: 0.85;
}
.color-filter-chip.active {
  opacity: 1;
  border-color: var(--forest);
  transform: scale(1.08);
}

/* ═════════════════════════════════════════════════════════════════
   13. 결과 카운트 / 빈 상태
   ───────────────────────────────────────────────────────────────── */

.result-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}
.result-count strong {
  color: var(--forest);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
}

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-3);
  opacity: 0.4;
}
.empty-state-message {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ═════════════════════════════════════════════════════════════════
   14. 로딩 / 스피너
   ───────────────────────────────────────────────────────────────── */

.lib-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  gap: var(--space-3);
  color: var(--text-secondary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--sage);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

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

/* skeleton 카드 */
.book-card-skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.book-card-skeleton .skeleton-cover {
  aspect-ratio: 2 / 3;
  background: linear-gradient(90deg, var(--sage-light), var(--bg), var(--sage-light));
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.book-card-skeleton .skeleton-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
}
.book-card-skeleton .skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, var(--sage-light), var(--bg), var(--sage-light));
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.book-card-skeleton .skeleton-line:nth-child(2) {
  width: 70%;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═════════════════════════════════════════════════════════════════
   15. 로그인 화면
   ───────────────────────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(at 20% 30%, rgba(107, 113, 66, 0.08), transparent 50%),
    radial-gradient(at 80% 70%, rgba(200, 197, 186, 0.4), transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.login-brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--forest);
  margin-bottom: var(--space-2);
  letter-spacing: 0.04em;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.login-error {
  color: var(--error);
  font-size: 13px;
  margin-top: var(--space-2);
  min-height: 1.4em;
}

/* ═════════════════════════════════════════════════════════════════
   16. 페이지네이션 / 더보기
   ───────────────────────────────────────────────────────────────── */

.lib-load-more {
  display: flex;
  justify-content: center;
  padding: var(--space-8) 0;
}

/* ═════════════════════════════════════════════════════════════════
   17. 반응형 유틸
   ───────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .lib-container {
    padding: var(--space-4);
  }
  .lib-header {
    padding: 0 var(--space-4);
  }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .lib-toolbar {
    gap: var(--space-2);
  }
}

@media (max-width: 480px) {
  .lib-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .lib-toolbar-group {
    flex-wrap: wrap;
  }
  .lib-search {
    max-width: 100%;
  }
}
