/* 공통 스타일 - 모든 페이지에서 사용 */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
}

/* 네비게이션 */
.navbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

.nav-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.nav-menu {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--gray-700);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--gray-100);
  border-radius: 8px;
}

.btn-logout {
  padding: 8px 16px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* 메인 컨테이너 */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 32px;
  margin: 0 0 8px 0;
}

.page-header p {
  color: var(--gray-600);
  margin: 0;
}

/* 통계 카드 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  gap: 16px;
  align-items: center;
}

.stat-icon {
  font-size: 40px;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

/* 탭 */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--gray-200);
}

.tab-btn {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 카드 */
.card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 24px;
}

.card h2 {
  font-size: 20px;
  margin: 0 0 20px 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h2 {
  margin: 0;
}

/* 테이블 */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--gray-100);
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-700);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
}

tr:hover {
  background: var(--gray-50);
}

/* 필터 */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters input,
.filters select {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
}

/* 버튼 */
.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  padding: 10px 20px;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  padding: 10px 20px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  padding: 10px 20px;
  background: #6b7280;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.btn-view {
  background: var(--primary);
  color: white;
}

.btn-delete {
  background: var(--danger);
  color: white;
}

/* 기관 통계 */
.institution-item {
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.institution-name {
  font-weight: 600;
  font-size: 16px;
}

.institution-count {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

/* 반응형 */
@media (max-width: 768px) {
  /* 네비게이션 */
  .navbar {
    padding: 0 16px;
  }

  .nav-content {
    flex-direction: column;
    height: auto;
    padding: 12px 0;
    gap: 12px;
  }

  .nav-logo {
    font-size: 18px;
  }

  .nav-menu {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }

  .nav-link {
    padding: 6px 12px;
    font-size: 14px;
  }

  .nav-user {
    font-size: 14px;
    padding: 6px 12px;
  }

  .btn-logout {
    padding: 6px 12px;
    font-size: 14px;
  }

  /* 메인 컨테이너 */
  .main-container {
    padding: 20px 12px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .page-header p {
    font-size: 14px;
  }

  /* 통계 카드 */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-icon {
    font-size: 32px;
  }

  .stat-value {
    font-size: 24px;
  }

  /* 카드 */
  .card {
    padding: 16px;
    border-radius: 8px;
  }

  .card h2 {
    font-size: 18px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-header > div {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* 탭 */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
  }

  /* 테이블 */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  th, td {
    padding: 8px;
    font-size: 13px;
  }

  /* 필터 */
  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    width: 100%;
  }

  /* 버튼 */
  .btn-primary,
  .btn-success,
  .btn-danger,
  .btn-secondary {
    width: 100%;
    padding: 12px 16px;
  }

  /* 모달 */
  .modal {
    padding: 12px;
  }

  .modal-content {
    max-width: 100%;
    max-height: 95vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-header h3 {
    font-size: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  /* Footer */
  .page-footer {
    padding: 24px 16px;
    font-size: 12px;
  }
}

/* 작은 모바일 디바이스 (480px 이하) */
@media (max-width: 480px) {
  .nav-logo {
    font-size: 16px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .stat-value {
    font-size: 20px;
  }

  .card {
    padding: 12px;
  }

  th, td {
    padding: 6px;
    font-size: 12px;
  }

  .btn-small {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* 모달 스타일 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--gray-600);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.modal-body {
  padding: 24px;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Badge 스타일 */
.badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* Footer 스타일 */
.page-footer {
  text-align: center;
  padding: 32px 24px;
  margin-top: 60px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 13px;
  line-height: 1.8;
}

.page-footer .copyright {
  margin-bottom: 8px;
  font-weight: 500;
}

.page-footer .developers {
  color: var(--gray-500);
  font-size: 12px;
}
