/* ==========================================================================
   컴포넌트 스타일 — 버튼 / 카드 / 배지 / 진행바 / 아이콘 / 사이드바 / 탑바 등
   ========================================================================== */

/* ---------- 버튼: 입체 그림자 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-btn-hover); }
.btn:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.btn-secondary:hover { box-shadow: 0 4px 10px rgba(0,0,0,.10); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  box-shadow: none;
  padding: 10px 16px;
}
.btn-ghost:hover { background: var(--surface); transform: none; box-shadow: none; }

.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- 카드 ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  transition: .15s ease;
}
.card-hover:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }

.card-surface { background: var(--surface); border-color: var(--border); }

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--sub);
}
.badge-primary { background: rgba(35,131,226,.10); color: var(--primary); border-color: rgba(35,131,226,.25); }
.badge-success { background: rgba(46,139,87,.10); color: var(--success); border-color: rgba(46,139,87,.25); }
.badge-warning { background: rgba(199,123,23,.10); color: var(--warning); border-color: rgba(199,123,23,.25); }
.badge-danger { background: rgba(209,69,59,.10); color: var(--danger); border-color: rgba(209,69,59,.25); }

/* ---------- 진행바 / 게이지 ---------- */
.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width .4s ease;
}

.gauge-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.gauge-ring svg { transform: rotate(-90deg); }
.gauge-ring .gauge-value {
  position: absolute;
  text-align: center;
}
.gauge-ring .gauge-value .num { font-size: 30px; font-weight: 700; line-height: 1; }
.gauge-ring .gauge-value .label { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* ---------- 듀오톤 아이콘 ---------- */
.icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.icon .secondary { opacity: .25; fill: currentColor; }
.icon .primary { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 32px; height: 32px; }

/* ---------- 사이드바 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  font-weight: 700;
  font-size: 18px;
}
.sidebar-brand .logo-dot {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  box-shadow: var(--shadow-btn);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sub);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  transition: .12s ease;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.nav-item.active .icon { color: var(--primary); }

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: var(--space-4) 12px var(--space-1);
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ---------- 탑바 ---------- */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  background: rgba(var(--bg-rgb), .85);
  backdrop-filter: blur(6px);
  z-index: 10;
}

/* ---------- 다크/라이트 테마 토글 ---------- */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: .12s ease;
}
.theme-toggle-btn:hover { background: var(--surface); }
.theme-toggle-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (max-width: 640px) {
  .topbar { padding: 0 var(--space-4); }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- 모바일 사이드바 토글 ---------- */
.mobile-nav-toggle { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
  }
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    /* <button>은 브라우저 기본 색을 쓰기 때문에(부모 color를 자동 상속하지 않음)
       명시적으로 지정하지 않으면 라이트에서도 우연히 비슷해 보이다가 다크에서는
       검정 아이콘이 어두운 배경에 묻혀 버린다 — 아이콘이 항상 --text를 따르게 한다. */
    color: var(--text);
    cursor: pointer;
  }
}

/* ---------- 폼 요소 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field label { font-size: 13px; font-weight: 700; color: var(--text); }
.field input, .field select, .field textarea {
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35,131,226,.15);
}
.field-hint { font-size: 12px; color: var(--sub); }

.chip-select { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg);
  color: var(--sub);
  transition: .12s ease;
}
.chip:hover { border-color: var(--primary); color: var(--text); }
.chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

/* ---------- 빈 상태 ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-6);
  color: var(--sub);
}

/* ---------- 탭 버튼 (로그인/회원가입, 전공/대학 등) ---------- */
.tab-btn { transition: .12s ease; }
.tab-btn.active {
  background: var(--bg);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.tab-btn:not(.active) { background: var(--surface); color: var(--sub); }

/* ---------- AI 응답 카드 (FUTURE COACH) — 규칙 기반 카드와 시각적으로 구분 ---------- */
.card-ai {
  background: var(--sky-tint);
  border-color: var(--sky-border);
}

/* ---------- 브랜드 로고 이미지 ----------
   전부 투명 배경 PNG. 별도 배경 박스 없이 이미지 자체만 표시하고,
   width 또는 height 한쪽만 고정하고 반대쪽은 auto로 둬서 원본 비율을 유지한다. */
.sidebar-logo-mark {
  height: 64px;
  width: auto;
  display: block;
}
.sidebar-logo-word {
  height: 44px;
  width: auto;
  display: block;
}
.auth-logo-word {
  width: 300px;
  max-width: 100%;
  height: auto;
  display: inline-block;
  /* 원본 PNG 캔버스의 좌우 여백이 비대칭(왼쪽 48px, 오른쪽 20px)이라
     텍스트의 시각적 중심을 맞추기 위해 살짝 왼쪽으로 보정한다. */
  transform: translateX(-8.5px);
}

/* 워드마크 PNG는 짙은 네이비 글자라 다크 배경(사이드바/로그인 카드)에서 거의
   안 보인다 — 별도 다크용 이미지 자산을 새로 만들지 않고, 다크 모드에서만
   전체를 흰색 실루엣으로 반전시켜 대비를 확보한다(그라데이션 색감은 이 화면에서만 생략됨). */
[data-theme="dark"] .sidebar-logo-word,
[data-theme="dark"] .auth-logo-word {
  filter: brightness(0) invert(1);
}

.form-message-error { background: rgba(209,69,59,.08); color: var(--danger); border: 1px solid rgba(209,69,59,.25); }
.form-message-success { background: rgba(46,139,87,.08); color: var(--success); border: 1px solid rgba(46,139,87,.25); }

/* ---------- 저장 상태 표시 (MY PROFILE 등 폼 저장 버튼 옆에 사용) ---------- */
.save-status-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.save-status { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.save-status-clean { color: var(--sub); font-weight: 500; }
.save-status-dirty { color: var(--warning); }
.save-status-saving { color: var(--sub); font-weight: 500; }
.save-status-success { color: var(--success); }
.save-status-error { color: var(--danger); }
.save-status-retry { margin-left: 2px; }

/* ---------- 인증 페이지 전용 ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: var(--space-4);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card-hover);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--sub);
  font-size: 12px;
  margin: var(--space-4) 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.oauth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: var(--space-2);
  transition: .12s ease;
}
.oauth-btn:hover { background: var(--surface); }

/* ---------- 첫 방문 활동 가이드 모달 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 1000;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
  padding: var(--space-6);
}
.onboarding-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.onboarding-list li {
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 출석 캘린더 ---------- */
.att-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--sub);
  text-align: center;
}
.att-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.att-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.att-day-empty { background: transparent; }
.att-day-missed { color: var(--sub); }
.att-day-future { color: var(--border); background: transparent; }
.att-day-done { background: var(--primary); color: #fff; font-weight: 700; }
.att-day-today { box-shadow: 0 0 0 2px var(--primary) inset; font-weight: 700; }
.att-day-done.att-day-today { box-shadow: 0 0 0 2px #fff inset; }

/* ---------- 캘린더 & 계획 (calendar.html) ---------- */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--sub);
  text-align: center;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  min-height: 96px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: .12s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-day:hover { background: var(--border); }
.cal-day-empty { background: transparent; cursor: default; }
.cal-day-empty:hover { background: transparent; }
.cal-day-num { font-size: 13px; color: var(--text); display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.cal-day-ratio { font-size: 10px; color: var(--sub); font-weight: 500; white-space: nowrap; }
.cal-day-ratio-done { color: var(--success); font-weight: 700; }
/* 모바일 전용 점 표시 — PC에서는 숨겨두고 위 cal-day-ratio 텍스트를 그대로 쓴다 */
.cal-day-dot {
  display: none;
  align-self: center;
  flex-shrink: 0;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--primary);
  margin-top: 1px;
}
.cal-day-dot.cal-day-dot-done { background: var(--success); }
.cal-day-today { box-shadow: 0 0 0 2px var(--primary) inset; }
.cal-day-today .cal-day-num { font-weight: 700; color: var(--primary); }
.cal-day-selected { box-shadow: 0 0 0 2px var(--sky-accent) inset; }
.cal-day-events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-event-chip {
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--sky-tint);
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event-chip.cal-event-done { background: var(--surface); color: var(--sub); text-decoration: line-through; }
.cal-day-more { font-size: 11px; color: var(--sub); }

/* 주간 뷰 */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.week-day-col { display: flex; flex-direction: column; gap: 6px; }
.week-day-header { text-align: center; font-size: 12px; color: var(--sub); padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.week-day-header.cal-day-today { box-shadow: none; color: var(--primary); font-weight: 700; }
.week-day-cell { min-height: 160px; } /* 기존엔 JS 인라인 style이었음 — 모바일에서 재정의하려고 클래스로 옮김 */

/* ---------- 모바일 캘린더(≤860px) — "한눈에 보기" 전용 ----------
   PC 레이아웃/기능은 그대로 두고, 이 블록만 모바일에서 셀을 작게 만들고
   일정 텍스트 대신 점 하나로 존재/완료 여부만 보여준다. 날짜 탭 → 아래
   selected-day-panel(+필터)로 상세를 보는 흐름은 기존 그대로 재사용한다. */
@media (max-width: 860px) {
  .cal-weekdays, .cal-grid { gap: 3px; }
  .cal-day {
    min-height: 46px;
    padding: 4px 2px;
    gap: 1px;
  }
  .cal-day-num { font-size: 12px; justify-content: center; }
  .cal-day-ratio { display: none; }
  .cal-day-dot { display: block; }
  .cal-day-events { display: none; }

  .week-day-cell { min-height: 46px; }
  .week-day-header { font-size: 11px; padding-bottom: 2px; }
}

/* 일정 목록 항목 (선택한 날짜 패널, 대시보드 오늘 일정 카드 공용) */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-item.task-done .task-item-title { color: var(--sub); text-decoration: line-through; }
.task-checkbox {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  background: var(--bg);
}
.task-checkbox.checked { background: var(--primary); border-color: var(--primary); color: #fff; }
.task-item-time { font-size: 12px; color: var(--sub); flex-shrink: 0; min-width: 44px; }

/* ---------- Dashboard 카드 개인화(드래그 정렬) — 이 섹션만 신규 추가, 기존 규칙은 손대지 않음 ---------- */
#dashboard-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}
#dashboard-cards > .card-drag-wrapper:last-child { grid-column: 1 / -1; }
.card-drag-wrapper.card-full-width { grid-column: 1 / -1; }
.card-drag-wrapper { transition: box-shadow .1s ease; border-radius: var(--radius); }
.card-drag-wrapper.dragging { opacity: .4; }
.card-drag-wrapper.drag-over-top { box-shadow: 0 -3px 0 var(--primary); }
.card-drag-wrapper.drag-over-bottom { box-shadow: 0 3px 0 var(--primary); }

.card-drag-toolbar { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-2); height: 0; overflow: visible; }
.card-drag-handle {
  display: none;
  cursor: grab;
  color: var(--sub);
  font-size: 15px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  user-select: none;
  position: relative;
  top: 6px;
}
.card-drag-handle:hover { background: var(--surface); color: var(--text); }
.card-drag-wrapper.dragging .card-drag-handle { cursor: grabbing; }
.dashboard-editing .card-drag-handle { display: inline-flex; }

/* 기본(PC, >860px)에서는 편집 모드여도 이동 버튼을 켜지 않는다 — 손잡이 드래그로
   충분하다(요청 7항: PC에서는 이동 버튼을 숨기거나 최소화). 860px 이하에서만 켠다. */
.card-move-buttons { display: none; gap: 6px; position: relative; top: 6px; }
.card-move-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}
.card-move-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.card-move-btn:disabled { opacity: .35; cursor: default; }

@media (max-width: 860px) {
  #dashboard-cards { grid-template-columns: 1fr; }
  .dashboard-editing .card-drag-handle { display: none; }
  /* 860px 이하에서는 드래그 대신 항상 ▲▼ 버튼을 우선한다(요청 7항 — 모바일에서 드래그에 의존하지 않음) */
  .card-move-buttons { display: none; }
  .dashboard-editing .card-move-buttons { display: flex; }
}

/* ---------- 커리어넷 검색 카드(career.html) — 2차 방어용 line-clamp.
   .card-title를 전역으로 건드리면 다른 페이지 카드에도 영향이 가므로, 이
   카드들에만 좁게 적용한다. 근본 수정(필드 매핑)이 우선이고, 이건 혹시 실제
   API가 예상 밖으로 긴 값을 주더라도 카드가 화면을 뒤덮지 않게 하는 안전장치다. */
.cn-card-title-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
