@import url('https://fonts.googleapis.com/css2?family=Agbalumo&display=swap');

/* Crowny Class Portal Common Styles */

/* ====================================
   색상 및 스타일 변수 (여기서 한번에 수정)
   ==================================== */
:root {
  /* 메인 브랜드 색상 */
  --primary: #8A38F5;           /* 메인 보라색 */
  --primary-dark: #7030d4;      /* 진한 보라색 */
  --primary-light: #a855f7;     /* 연한 보라색 */
  --secondary: #D53A6B;         /* 분홍색 */
  --secondary-light: #f472b6;   /* 연한 분홍색 */

  /* 다크 테마 배경색 (사이드바) */
  --dark-bg: #1B1D21;           /* 사이드바 배경 */
  --dark-secondary: #1A1C22;    /* 사이드바 보조 배경 */
  --dark-tertiary: #2B2D35;     /* 사이드바 호버 */
  --dark-border: #3d3d54;       /* 사이드바 테두리 */

  /* 라이트 테마 배경색 (본문) */
  --light-bg: #f3f4f6;          /* 페이지 배경 */
  --light-card: #ffffff;        /* 카드 배경 */
  --light-border: #e5e7eb;      /* 테두리 */
  --light-hover: #f9fafb;       /* 호버 배경 */

  /* 텍스트 색상 */
  --text-primary: #ffffff;      /* 다크 배경 위 텍스트 */
  --text-dark: #1f2937;         /* 라이트 배경 위 텍스트 */
  --text-secondary: #9ca3af;    /* 보조 텍스트 */
  --text-muted: #6b7280;        /* 약한 텍스트 */

  /* 상태 색상 */
  --success: #22C55E;           /* 성공/완료 */
  --success-light: #dcfce7;     /* 성공 배경 */
  --warning: #F59E0B;           /* 경고 */
  --warning-light: #fef3c7;     /* 경고 배경 */
  --error: #EF4444;             /* 에러 */
  --error-light: #fee2e2;       /* 에러 배경 */
  --info: #3B82F6;              /* 정보 */
  --info-light: #dbeafe;        /* 정보 배경 */

  /* Border Radius (둥글기) */
  --radius-sm: 6px;             /* 작은 요소 */
  --radius-md: 10px;            /* 중간 요소 (버튼, 인풋) */
  --radius-lg: 12px;            /* 큰 요소 (카드 내부) */
  --radius-xl: 16px;            /* 카드, 모달 */
  --radius-2xl: 20px;           /* 큰 카드 */
  --radius-full: 9999px;        /* 원형 (아바타, 뱃지) */

  /* 그림자 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
  --shadow-primary: 0 4px 14px rgba(138, 56, 245, 0.35);

  /* 간격 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* 사이드바 너비 */
  --sidebar-width: 260px;

  /* 헤더 높이 */
  --header-height: 64px;

  /* 폰트 크기 */
  --font-xs: 11px;
  --font-sm: 13px;
  --font-md: 14px;
  --font-lg: 16px;
  --font-xl: 18px;
  --font-2xl: 24px;
  --font-3xl: 28px;

  /* 트랜지션 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* 테두리 */
  --border-width: 1px;          /* 기본 테두리 굵기 */
  --border-color: #e5e7eb;      /* 기본 테두리 색상 */
  --border-dark: #3d3d54;       /* 다크 테두리 색상 */
  --border: var(--border-width) solid var(--border-color);
  --border-dark-style: var(--border-width) solid var(--border-dark);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  line-height: 1.6;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 260px;
  background: var(--dark-bg);
  border-right: 1px solid var(--dark-border);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 32px;
  height: auto;
}

.sidebar-logo-text {
  color: white;
  font-weight: 700;
  font-size: 18px;
  font-family: 'Agbalumo', cursive;
}

.sidebar-logo-sub {
  display: block;
  color: var(--primary);
  font-size: 11px;
  font-weight: 500;
  margin-top: -2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 16px;
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(138,56,245,0.3), rgba(213,58,107,0.2));
  color: white;
}

.sidebar-link i {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.sidebar-link.active i {
  opacity: 1;
  color: var(--primary);
}

.sidebar-badge {
  margin-left: auto;
  background: var(--secondary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  margin-bottom: 12px;
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.sidebar-user-info {
  flex: 1;
}

.sidebar-user-name {
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.sidebar-user-role {
  color: var(--primary);
  font-size: 12px;
}

.sidebar-user-email {
  color: #888;
  font-size: 11px;
  word-break: break-all;
}

/* Main Content */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
}

/* Header */
.header {
  height: 64px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
}

.header-title p {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ecfdf5;
  padding: 6px 12px;
  border-radius: 20px;
}

.header-sync-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-sync-text {
  color: #059669;
  font-size: 13px;
  font-weight: 500;
}

/* Page Content */
.page-content {
  padding: 24px;
}

/* Cards */
.card {
  background: white;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.card-body {
  padding: 20px;
}

/* Stat Cards */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.stat-icon.purple { background: #f3e8ff; color: var(--primary); }
.stat-icon.blue { background: #dbeafe; color: var(--info); }
.stat-icon.green { background: #dcfce7; color: var(--success); }
.stat-icon.orange { background: #ffedd5; color: var(--warning); }
.stat-icon.pink { background: #fce7f3; color: var(--secondary); }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(138, 56, 245, 0.4);
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-outline {
  background: transparent;
  border: 1px solid #d1d5db;
  color: #374151;
}

.btn-outline:hover {
  background: #f9fafb;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(138, 56, 245, 0.1);
}

.form-input::placeholder {
  color: #9ca3af;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #f9fafb;
}

.table td {
  font-size: 14px;
  color: #374151;
}

.table tr:hover td {
  background: #f9fafb;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* List Items */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  background: #f9fafb;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.list-item:hover {
  background: #f3f4f6;
}

.list-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.list-item-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f3f4f6;
  border-radius: 10px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover {
  color: #374151;
}

.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Chat UI */
.chat-container {
  display: flex;
  height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.chat-sidebar {
  width: 280px;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chat-list-item:hover {
  background: #f9fafb;
}

.chat-list-item.active {
  background: #f3e8ff;
}

.chat-list-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.chat-list-info {
  flex: 1;
  min-width: 0;
}

.chat-list-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.chat-list-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-meta {
  text-align: right;
}

.chat-list-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-list-unread {
  width: 20px;
  height: 20px;
  background: var(--secondary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  margin-left: auto;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f9fafb;
}

.chat-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-message.sent {
  flex-direction: row-reverse;
}

.chat-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.chat-message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
}

.chat-message.received .chat-message-bubble {
  background: white;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.chat-message.sent .chat-message-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.chat-input {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  background: white;
}

.chat-input-field {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
}

.chat-input-field:focus {
  border-color: var(--primary);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: #f3f4f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.empty-state-icon i {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* Grid */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .header {
    padding: 0 16px;
  }

  .page-content {
    padding: 16px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .chat-container {
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    height: auto;
    max-height: 200px;
  }

  /* Mobile menu button */
  #menuToggle {
    display: flex !important;
  }

  /* Mobile header adjustments */
  .header-title h1 {
    font-size: 16px;
  }

  .header-title p {
    display: none;
  }

  .header-right .btn span {
    display: none;
  }

  .header-right .btn {
    padding: 10px;
  }
}

/* Mobile overlay for sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

.sidebar-overlay.active {
  display: block;
}

/* Mobile bottom navigation */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e5e7eb;
  padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 40;
}

.mobile-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  color: var(--primary);
  background: rgba(138, 56, 245, 0.1);
}

.mobile-nav-item i {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .mobile-nav {
    display: block;
  }

  .page-content {
    padding-bottom: 80px;
  }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
