/* 
 * 전공의수첩 시스템 - shadcn/ui 기반 CSS
 * Tailwind CSS 유틸리티 클래스를 직접 구현
 */

/* CSS 변수 정의 (shadcn/ui 기본값) */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 222.2 84% 4.9%;
  --radius: 0.5rem;
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 4.9%;
  --card-foreground: 210 40% 98%;
  --popover: 222.2 84% 4.9%;
  --popover-foreground: 210 40% 98%;
  --primary: 210 40% 98%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 210 40% 98%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
  --ring: 212.7 26.8% 83.9%;
}

/* 기본 스타일 리셋 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
}

/* 링크 기본 스타일 재설정 */
a {
  text-decoration: none !important;
  color: inherit !important;
}

a:hover {
  text-decoration: none !important;
}

a:visited {
  color: inherit !important;
}

a:focus {
  outline: none;
  text-decoration: none !important;
}

/* 컨테이너 */
.container {
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 640px) {
  .container { max-width: 640px; }
}
@media (min-width: 768px) {
  .container { max-width: 768px; }
}
@media (min-width: 1024px) {
  .container { max-width: 1024px; }
}
@media (min-width: 1280px) {
  .container { max-width: 1280px; }
}

/* 레이아웃 유틸리티 */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.min-h-screen { min-height: 100vh; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }

/* 패딩/마진 */
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* z-index 확장 */
.z-60 { z-index: 60; }

/* 드롭다운 메뉴 배경 */
.bg-popover {
  background-color: hsl(var(--background));
  opacity: 1;
}

.dark .bg-popover {
  background-color: hsl(var(--background));
  opacity: 1;
}

/* 사용자 메뉴 드롭다운 */
#user-menu {
  background-color: white;
  opacity: 1;
}

.dark #user-menu {
  background-color: hsl(222.2 84% 4.9%);
}

/* 드롭다운 메뉴 링크 스타일 재설정 */
#user-menu a {
  text-decoration: none !important;
  color: inherit !important;
}

#user-menu a:hover {
  text-decoration: none !important;
}

#user-menu a:visited {
  color: inherit !important;
}

/* 사이드바 링크 스타일 */
.sidebar-nav-item {
  text-decoration: none !important;
  color: inherit !important;
}

.sidebar-nav-item:hover {
  text-decoration: none !important;
}

.sidebar-nav-item:visited {
  color: inherit !important;
}

/* 서브메뉴 링크 스타일 */
.submenu a {
  text-decoration: none !important;
  color: inherit !important;
}

.submenu a:hover {
  text-decoration: none !important;
}

.submenu a:visited:not(.active-submenu) {
  color: inherit !important;
}

/* 활성 서브메뉴는 visited 스타일을 무시 */
.submenu a.active-submenu:visited {
  color: #2563eb !important; /* 파란색 */
}

/* 사용자 메뉴 컨테이너 스타일 */
.user-menu-container {
  width: 250px;
}

/* 사이드바 활성 메뉴 스타일 */
.sidebar-nav-item.active {
  color: hsl(var(--primary)) !important;
  font-weight: 600 !important;
}

/* 서브메뉴 활성 스타일 */
.submenu .active-submenu,
.active-submenu {
  color: #2563eb !important; /* 파란색 */
  font-weight: 500 !important;
}

/* 서브메뉴 패딩 조정 */
.submenu a {
  padding-left: 40px !important;
}

/* 서브메뉴 hover 스타일 (활성 항목은 제외) */
.submenu a:hover:not(.active-submenu) {
  background-color: hsl(var(--accent) / 0.5) !important;
}

/* 서브메뉴 간격 조정 */
.submenu {
  gap: 6px;
  margin-top: 10px !important;
}

/* Hidden 클래스 정의 (Tailwind CSS 대체) */
.hidden {
  display: none !important;
}

/* 사용자 메뉴 버튼 스타일 */
.user-menu-button {
  width: 100%;
  padding-right: 15px;
}

/* 사용자 메뉴 드롭다운 크기 조정 */
#user-menu {
  width: 250px !important;
}

/* 드롭다운 메뉴 아이템 간격 조정 */
#user-menu .space-y-1 > * + * {
  margin-top: 0.375rem; /* 6px */
}

/* 드롭다운 메뉴 링크 패딩 조정 */
#user-menu a {
  padding: 0.5rem 0.75rem !important; /* py-2 px-3 */
}

/* 아이콘 크기 조정 */
#user-menu svg {
  width: 1rem !important;
  height: 1rem !important;
}

/* 드롭다운 메뉴 텍스트 크기 */
#user-menu .font-medium {
  font-size: 0.875rem; /* text-sm */
}

/* 아이콘 컨테이너 크기 조정 */
#user-menu .w-5.h-5 {
  width: 1rem !important;
  height: 1rem !important;
}
.mb-6 { margin-bottom: 1.5rem; }

/* 텍스트 스타일 */
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-center { text-align: center; }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-destructive { color: hsl(var(--destructive)); }

/* Card 컴포넌트 */
.card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.375rem;
}

.card-content {
  padding: 1.5rem;
}

.card-footer {
  padding: 1.5rem;
  border-top: 1px solid hsl(var(--border));
}

/* Form 컴포넌트 */
.form-group {
  margin-bottom: 1.5rem;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: hsl(var(--foreground));
  background-color: transparent;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  transition: all 0.2s;
}

.input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsla(var(--ring), 0.1);
}

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

.input-error {
  border-color: hsl(var(--destructive));
}

/* Button 컴포넌트 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
  background-color: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
  background-color: hsl(var(--secondary) / 0.8);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid hsl(var(--input));
  color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-ghost {
  background-color: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover:not(:disabled) {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

/* Alert 컴포넌트 */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 1rem;
}

.alert-destructive {
  background-color: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border-color: hsl(var(--destructive) / 0.2);
}

.alert-success {
  background-color: hsl(142.1 76.2% 36.3% / 0.1);
  color: hsl(142.1 76.2% 36.3%);
  border-color: hsl(142.1 76.2% 36.3% / 0.2);
}

.alert-secondary {
  background-color: hsl(var(--secondary) / 0.1);
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--secondary) / 0.2);
}

/* Separator */
.separator {
  height: 1px;
  background-color: hsl(var(--border));
  margin: 1.5rem 0;
}

.separator-with-text {
  position: relative;
  text-align: center;
  margin: 2rem 0;
}

.separator-with-text::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: hsl(var(--border));
}

.separator-with-text span {
  position: relative;
  padding: 0 1rem;
  background-color: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  text-transform: uppercase;
}

/* Grid 시스템 */
.grid {
  display: grid;
  gap: 1rem;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 9999px;
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: 9999px;
  padding: 0 10px;
}

.badge-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-radius: 9999px;
  padding: 0 10px;
}

.badge-success {
  background-color: hsl(142.1 76.2% 36.3%);
  color: white;
  border-radius: 9999px;
  padding: 0 10px;
}

.badge-warning {
  background-color: hsl(45.4 93.4% 47.5%);
  color: white;
  border-radius: 9999px;
  padding: 0 10px;
}

.badge-error {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-radius: 9999px;
  padding: 0 10px;
}

.badge-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-radius: 9999px;
  padding: 0 10px;
}

/* Loading 애니메이션 */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* 반응형 유틸리티 */
@media (max-width: 640px) {
  .sm\:hidden { display: none; }
}

@media (min-width: 768px) {
  .md\:flex { display: flex; }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .lg\:max-w-5xl { max-width: 64rem; }
}
/* 추가 버튼 크기 */
.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1rem;
  border-radius: 0.25rem;
}

.btn-xs svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* DataTable 가운데 정렬 */
.data-table td,
.data-table th {
  text-align: center;
  vertical-align: middle;
}

/* 특정 컬럼은 왼쪽 정렬 (제목 등) */
.data-table td.text-left,
.data-table th.text-left {
  text-align: left;
}
