/* ============================================================
   iPlan — 앱 셸 레이아웃
   사이드바(240px) + 메인 영역
   ============================================================ */

/* ── 앱 컨테이너 ── */
#app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── 메인 콘텐츠 영역 ── */
#main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── 탑바 ── */
.ip-topbar {
  display: flex;
  align-items: center;
  height: var(--ip-topbar-h);
  padding: 0 var(--s-6);
  border-bottom: 1px solid var(--line);
  background: var(--bg-base);
  flex-shrink: 0;
  z-index: var(--z-topbar);
}

.ip-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.ip-topbar-left .ip-page-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-main);
}

.ip-topbar-center {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin: 0 auto;
}

.ip-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

/* ── 뷰 전환 탭 ── */
.ip-view-tab {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-sub);
  transition: all var(--duration-normal) var(--ease-default);
}

.ip-view-tab:hover {
  color: var(--text-main);
  background: var(--surface-hover);
}

.ip-view-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.ip-view-tab svg {
  width: 16px;
  height: 16px;
}

/* ── 뷰 컨테이너 ── */
#view-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ip-view {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: var(--s-6);
}

.ip-view.active {
  display: flex;
  flex-direction: column;
}

/* ── 퀵 추가 바 ── */
.ip-quick-add {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--ip-quickadd-h);
  padding: 0 var(--s-6);
  border-top: 1px solid var(--line);
  background: var(--bg-base);
  flex-shrink: 0;
}

.ip-quick-add-input {
  flex: 1;
  padding: var(--s-2) var(--s-4);
  background: var(--surface-w2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text-main);
  transition: border-color var(--duration-normal) var(--ease-default);
}

.ip-quick-add-input::placeholder {
  color: var(--text-faint);
}

.ip-quick-add-input:focus {
  border-color: var(--accent);
}

.ip-quick-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--bg-base);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  transition: opacity var(--duration-normal) var(--ease-default);
}

.ip-quick-add-btn:hover {
  opacity: 0.85;
}

/* ── 태스크 상세 패널 ── */
#task-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--ip-detail-panel-w);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-raised);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-default);
  z-index: var(--z-modal);
  overflow-y: auto;
  padding: var(--s-6);
}

#task-detail-panel.open {
  transform: translateX(0);
}

.ip-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--s-6);
}

.ip-detail-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  transition: background var(--duration-fast) var(--ease-default);
}

.ip-detail-close:hover {
  background: var(--surface-hover);
  color: var(--text-main);
}

.ip-detail-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--s-4);
  line-height: var(--leading-tight);
}

.ip-detail-field {
  margin-bottom: var(--s-4);
}

.ip-detail-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--s-2);
}

.ip-detail-desc {
  padding: var(--s-3);
  background: var(--surface-w2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-sub);
  line-height: var(--leading-relaxed);
  min-height: 100px;
}

.ip-detail-desc:empty::before {
  content: '설명 추가...';
  color: var(--text-faint);
}

/* ── 상세 패널: 상태 행 ── */
.ip-detail-status-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.ip-detail-status-text {
  font-size: var(--text-sm);
  color: var(--text-sub);
}

/* ── 상세 패널: 날짜/셀렉트 ── */
.ip-detail-date,
.ip-detail-select {
  width: auto;
}

/* ── 상세 패널: 로딩 ── */
.ip-detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-10);
}

/* ── 상세 패널: 서브태스크 ── */
.ip-detail-field .ip-subtask-list {
  margin-left: 0;
  padding-left: 0;
  border-left: none;
  margin-bottom: var(--s-2);
}

.ip-subtask-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-default);
}

.ip-subtask-item:hover {
  background: var(--surface-hover);
}

.ip-subtask-item.completed .ip-subtask-title {
  text-decoration: line-through;
  color: var(--text-faint);
}

.ip-subtask-title {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-subtask-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  color: var(--text-faint);
  opacity: 0;
  transition: all var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
}

.ip-subtask-item:hover .ip-subtask-delete {
  opacity: 1;
}

.ip-subtask-delete:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

/* ── 서브태스크 추가 입력 ── */
.ip-subtask-add {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.ip-subtask-add-input {
  flex: 1;
  padding: var(--s-1) var(--s-3);
  background: var(--surface-w2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-main);
  min-height: 28px;
  transition: border-color var(--duration-normal) var(--ease-default);
}

.ip-subtask-add-input::placeholder {
  color: var(--text-faint);
}

.ip-subtask-add-input:focus {
  border-color: var(--accent);
}

.ip-detail-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-6);
  padding-top: var(--s-6);
  border-top: 1px solid var(--line);
}

/* ── 모달 오버레이 ── */
#modal-layer {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal-backdrop);
  align-items: center;
  justify-content: center;
}

#modal-layer.open {
  display: flex;
}

/* ── 토스트 ── */
#toast-container {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}

.ip-toast {
  padding: var(--s-3) var(--s-5);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn var(--duration-slow) var(--ease-default);
}

.ip-toast--success { border-left: 3px solid var(--success); }
.ip-toast--error   { border-left: 3px solid var(--danger); }
.ip-toast--info    { border-left: 3px solid var(--info); }

/* ── 햄버거 (모바일) ── */
.ip-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-sub);
}

.ip-hamburger:hover {
  background: var(--surface-hover);
}

/* ── 오프라인 표시 ── */
#offline-indicator {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: var(--warning);
  color: var(--bg-base);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-align: center;
  line-height: 32px;
  z-index: var(--z-toast);
}

#offline-indicator.show {
  display: block;
}

/* ── 검색 ── */
.ip-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  transition: all var(--duration-fast) var(--ease-default);
}

.ip-search-btn:hover {
  background: var(--surface-hover);
  color: var(--text-main);
}

/* ── 프로필 아바타 ── */
.ip-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-w3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--accent);
}

.ip-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── 바텀시트 (모바일 태스크 상세) ── */
.ip-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--bg-raised);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  z-index: var(--z-modal);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ip-bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--surface-w4);
  border-radius: var(--radius-full);
  margin: var(--s-3) auto var(--s-2);
  cursor: grab;
  transition: background var(--duration-fast) var(--ease-default);
}

.ip-bottom-sheet-handle:hover {
  background: var(--text-faint);
}

/* ── 검색 오버레이 ── */
.ip-search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal-backdrop);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.ip-search-overlay.open {
  display: flex;
}

.ip-search-panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn var(--duration-slow) var(--ease-default);
}

.ip-search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}

.ip-search-input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.ip-search-input {
  flex: 1;
  font-size: var(--text-md);
  color: var(--text-main);
  background: none;
  border: none;
}

.ip-search-input::placeholder {
  color: var(--text-faint);
}

.ip-search-kbd {
  font-size: var(--text-xs);
  color: var(--text-faint);
  padding: var(--s-0) var(--s-2);
  background: var(--surface-w2);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  font-family: var(--font-family);
}

.ip-search-results {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-2);
}

.ip-search-result-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
}

.ip-search-result-item:hover,
.ip-search-result-item.highlighted {
  background: var(--surface-hover);
}

.ip-search-result-title {
  font-size: var(--text-sm);
  color: var(--text-main);
}

.ip-search-result-meta {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.ip-search-empty {
  padding: var(--s-8);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-faint);
}

/* ── 설정 뷰 ── */
#settings-view {
  gap: var(--s-6);
}

.ip-settings-section {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.ip-settings-section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-main);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}

.ip-settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line-subtle);
  transition: background var(--duration-fast) var(--ease-default);
}

.ip-settings-item:last-child {
  border-bottom: none;
}

.ip-settings-item:hover {
  background: var(--surface-hover);
}

.ip-settings-label {
  font-size: var(--text-sm);
  color: var(--text-main);
}

.ip-settings-desc {
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: var(--s-1);
}

/* ── 토글 스위치 ── */
.ip-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-w3);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-default);
  flex-shrink: 0;
}

.ip-toggle.on {
  background: var(--accent);
}

.ip-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-main);
  border-radius: var(--radius-full);
  transition: transform var(--duration-normal) var(--ease-default);
}

.ip-toggle.on::after {
  transform: translateX(20px);
}

/* ── 프로필 카드 (설정 상단) ── */
.ip-profile-card {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5);
}

.ip-profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-w3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--accent);
  flex-shrink: 0;
}

.ip-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ip-profile-name {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-main);
}

.ip-profile-email {
  font-size: var(--text-xs);
  color: var(--text-faint);
}
