/* 전체 애플리케이션 구조 및 레이아웃 */
:root {
    --font-sans: 'Noto Sans KR', 'Poppins', system-ui, -apple-system, sans-serif;
    --color-primary: #6366f1; /* indigo-500 */
    --color-primary-dark: #4f46e5; /* indigo-600 */
    --color-primary-light: #818cf8; /* indigo-400 */
    --color-primary-contrast: #ffffff;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
}

/* 기본 타이포그래피 */
body {
    font-family: var(--font-sans);
    color: var(--color-gray-800);
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.5rem;
}

/* 데스크톱에서 메인 콘텐츠 패딩 조정 */
@media (min-width: 768px) {
    main {
        padding-left: 16rem; /* 사이드바 너비 + 여백 */
    }
}

/* 카드 스타일 */
.card {
    @apply bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden transition-shadow;
}

.card:hover {
    @apply shadow-md;
}

.card-header {
    @apply px-4 py-3 border-b border-gray-200 bg-gray-50 font-medium;
}

.card-body {
    @apply p-4;
}

.card-footer {
    @apply px-4 py-3 border-t border-gray-200 bg-gray-50;
}

/* 버튼 스타일 */
.btn-primary {
    @apply inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500;
}

.btn-secondary {
    @apply inline-flex items-center justify-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500;
}

.btn-success {
    @apply inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500;
}

.btn-danger {
    @apply inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500;
}

/* 폼 요소 스타일 */
.form-control {
    @apply block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm;
}

.form-label {
    @apply block text-sm font-medium text-gray-700 mb-1;
}

.form-select {
    @apply block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm;
}

/* 알림 메시지 스타일 */
.alert {
    @apply rounded-md p-4 mb-4;
}

.alert-success {
    @apply bg-green-50 text-green-800;
}

.alert-info {
    @apply bg-blue-50 text-blue-800;
}

.alert-warning {
    @apply bg-yellow-50 text-yellow-800;
}

.alert-danger {
    @apply bg-red-50 text-red-800;
}

/* 페이지네이션 스타일 */
.pagination {
    @apply flex justify-center mt-4;
}

.page-item {
    @apply inline-flex;
}

.page-link {
    @apply relative inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50;
}

.page-item.active .page-link {
    @apply z-10 bg-primary-50 border-primary-500 text-primary-600;
}

.page-item.disabled .page-link {
    @apply bg-gray-100 text-gray-500 cursor-not-allowed;
}

/* 뱃지 스타일 */
.badge {
    @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
}

.badge-primary {
    @apply bg-primary-100 text-primary-800;
}

.badge-secondary {
    @apply bg-gray-100 text-gray-800;
}

.badge-success {
    @apply bg-green-100 text-green-800;
}

.badge-info {
    @apply bg-blue-100 text-blue-800;
}

.badge-warning {
    @apply bg-yellow-100 text-yellow-800;
}

.badge-danger {
    @apply bg-red-100 text-red-800;
}

/* 모바일 최적화 */
@media (max-width: 767px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    main {
        padding-bottom: 5rem; /* 하단 네비게이션바 여백 확보 */
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
}

/* 세부 교수설계 단계 스타일 */
.step-card {
    @apply border-l-4 mb-4 bg-white rounded-lg shadow-sm overflow-hidden;
}

.step-analysis {
    @apply border-green-500;
}

.step-design {
    @apply border-primary-500;
}

.step-development {
    @apply border-orange-500;
}

.step-implementation {
    @apply border-red-500;
}

.step-evaluation {
    @apply border-purple-500;
}

.step-other {
    @apply border-gray-500;
}

/* 드래그 앤 드롭 스타일 */
.sortable-item {
    @apply cursor-move transition-colors duration-200;
}

.sortable-item.dragging {
    @apply bg-gray-50 opacity-80;
}

/* AI 생성 콘텐츠 스타일 */
.ai-content {
    @apply border-l-4 border-purple-500 pl-4 bg-gray-50 py-2 rounded-r-md;
}

/* 프로필 이미지 스타일 */
.profile-img {
    @apply w-24 h-24 object-cover rounded-full border-2 border-white shadow-sm;
}

.profile-img-sm {
    @apply w-12 h-12 object-cover rounded-full;
}

/* 반응형 테이블 */
.responsive-table {
    @apply min-w-full divide-y divide-gray-200;
}

.responsive-table th {
    @apply px-6 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider;
}

.responsive-table td {
    @apply px-6 py-4 whitespace-nowrap text-sm text-gray-500;
}

/* 로딩 인디케이터 */
.loading-indicator {
    @apply flex items-center justify-center p-4;
}

.loading-spinner {
    @apply animate-spin h-5 w-5 mr-3 text-primary-500;
}

/* 검색 필드 스타일 */
.search-container {
    @apply relative rounded-md shadow-sm;
}

.search-container input {
    @apply pl-10 focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-300 rounded-md;
}

.search-container .search-icon {
    @apply pointer-events-none absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400;
}


/* 카드 스타일 */
.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    padding: 0.75rem 1.25rem;
}

/* 버튼 스타일 */
.btn {
    border-radius: 0.25rem;
}

.btn-outline-primary:hover {
    color: #fff;
}

/* 폼 스타일 */
.form-control, .form-select {
    border-radius: 0.25rem;
}

.form-control:focus, .form-select:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* 페이지네이션 스타일 */
.pagination {
    margin-bottom: 0;
}

.page-link {
    color: #007bff;
    background-color: #fff;
    border: 1px solid #dee2e6;
}

.page-link:hover {
    color: #0056b3;
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}

/* 모바일 최적화 */
@media (max-width: 767.98px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* 태블릿 최적화 */
@media (min-width: 768px) and (max-width: 991.98px) {
    .navbar-brand {
        font-size: 1.3rem;
    }
}

/* 교수설계 카드 스타일 */
.design-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.design-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* 프로필 이미지 스타일 */
.profile-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.profile-img-sm {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 50%;
}

/* 학습자료 아이콘 스타일 */
.resource-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* 세부 교수설계 단계 스타일 */
.step-card {
    border-left: 5px solid #007bff;
    margin-bottom: 1rem;
}

.step-analysis {
    border-left-color: #28a745;  /* 분석 단계 */
}

.step-design {
    border-left-color: #007bff;  /* 설계 단계 */
}

.step-development {
    border-left-color: #fd7e14;  /* 개발 단계 */
}

.step-implementation {
    border-left-color: #dc3545;  /* 실행 단계 */
}

.step-evaluation {
    border-left-color: #6f42c1;  /* 평가 단계 */
}

.step-other {
    border-left-color: #6c757d;  /* 기타 단계 */
}

/* 드래그 앤 드롭 스타일 */
.sortable-item {
    cursor: move;
    transition: background-color 0.2s;
}

.sortable-item.dragging {
    background-color: #f8f9fa;
    opacity: 0.8;
}

/* AI 생성 콘텐츠 스타일 */
.ai-content {
    border-left: 3px solid #6f42c1;
    padding-left: 1rem;
    background-color: #f8f9fa;
}

/* 알림 배지 스타일 */
.badge-notification {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(25%, -25%);
}

/* 모든 모달 팝업의 위치 수정을 위한 포괄적인 CSS */
body .modal,
body .modal.fade,
body .modal.fade.show,
body .modal-dialog,
body .modal.fade .modal-dialog,
body .modal.fade.show .modal-dialog,
div[class*="modal"],
div[id*="modal"],
div[id*="Modal"],
div[aria-labelledby*="ModalLabel"],
.modal:has(.modal-title:contains("추가 단계")),
.modal:has(h5:contains("추가 단계")),
.modal:has(input[placeholder*="단계"]),
.ai-help-modal,
#aiHelpModal,
[aria-labelledby="aiHelpModalLabel"],
.modal-ai-help,
.modal-step,
#stepModal,
#addStepModal,
[aria-labelledby="stepModalLabel"],
[aria-labelledby="addStepModalLabel"] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow-y: auto !important;
    z-index: 1050 !important;
    padding-top: 50px !important;
}

body .modal-dialog,
body .modal.fade .modal-dialog,
body .modal.fade.show .modal-dialog {
    position: relative !important;
    margin: 0 auto !important;
    top: 10% !important;
    transform: none !important;
    width: auto !important;
    max-width: 500px !important;
}

.modal-content {
    max-height: 80vh !important;
    overflow-y: auto !important;
}

/* 태블릿 환경에서의 모달 조정 */
@media (min-width: 768px) and (max-width: 1023px) {
    body .modal-dialog,
    body .modal.fade .modal-dialog,
    body .modal.fade.show .modal-dialog {
        top: 8% !important;
        width: 90% !important;
        max-width: 600px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* 모바일 환경에서의 모달 조정 */
@media (max-width: 767px) {
    body .modal-dialog,
    body .modal.fade .modal-dialog,
    body .modal.fade.show .modal-dialog {
        top: 5% !important;
        width: 95% !important;
        margin: 0 auto !important;
    }
}

/* Tailwind 모달 위치 조정을 위한 CSS */
#ai-help-modal .sm\:align-middle,
.fixed.inset-0.overflow-y-auto .sm\:align-middle {
    vertical-align: top !important; /* 중앙(middle) 대신 상단(top)으로 정렬 변경 */
    padding-top: 5% !important; /* 상단 여백 추가 */
}

/* 모든 화면 크기에서 상단 여백 조정 */
#ai-help-modal .sm\:my-8,
.fixed.inset-0.overflow-y-auto .sm\:my-8 {
    margin-top: 5% !important; /* 상단 여백 추가 */
    margin-bottom: 1rem !important; /* 하단 여백 축소 */
}

/* 모바일에서도 상단으로 정렬 */
#ai-help-modal .align-bottom,
.fixed.inset-0.overflow-y-auto .align-bottom {
    vertical-align: top !important;
    padding-top: 5% !important;
}

/* 모달 컨테이너의 패딩 조정 */
#ai-help-modal .pb-20,
.fixed.inset-0.overflow-y-auto .pb-20 {
    padding-bottom: 5rem !important; /* 기본값 유지 */
    padding-top: 2rem !important; /* 상단 패딩 추가 */
}

/* 모달의 변환(transform) 속성 조정 */
#ai-help-modal .transform,
.fixed.inset-0.overflow-y-auto .transform {
    transform: translateY(0) !important; /* Y축 이동 제거 */
}

/* 작은 화면에서의 추가 조정 */
@media (max-width: 640px) {
    #ai-help-modal .align-bottom,
    .fixed.inset-0.overflow-y-auto .align-bottom {
        padding-top: 10% !important; /* 모바일에서 더 많은 상단 여백 */
    }
    
    #ai-help-modal .pb-20,
    .fixed.inset-0.overflow-y-auto .pb-20 {
        padding-bottom: 4rem !important; /* 하단 패딩 약간 축소 */
    }
}

/* 드래그 앤 드롭 관련 스타일 */
.sortable-item {
    transition: background-color 0.2s ease;
    cursor: grab;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    border: 1px solid #e5e7eb;
  }
  
  .sortable-item:active {
    cursor: grabbing;
  }
  
  .sortable-item.sortable-ghost {
    opacity: 0.5;
    background-color: #f3f4f6;
  }
  
  .sortable-item.sortable-chosen {
    background-color: #f3f4f6;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }
  
  .sortable-item .handle {
    cursor: grab;
    color: #9ca3af;
  }
  
  .sortable-item .handle:hover {
    color: #6b7280;
  }
  
  /* 모달 스타일 추가 */
  #sortStepsModal .modal-dialog {
    max-width: 500px;
  }
  
  #sortable-steps {
    padding: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
  }