/* ===== CSS Variables ===== */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff6ff;
  --secondary: #8b5cf6;
  --success: #10b981;
  --success-light: #ecfdf5;
  --error: #ef4444;
  --error-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

/* ===== Layout ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header ===== */
.site-header {
  background: #ffffff;
  color: var(--text);
  padding: 20px 0;
  box-shadow: var(--shadow-md);
  border-bottom: 2px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 56px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.site-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 2px;
}

.site-header p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.card-icon.blue { background: var(--primary-light); }
.card-icon.green { background: var(--success-light); }
.card-icon.purple { background: #f5f3ff; }

/* ===== Form ===== */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

label .required {
  color: var(--error);
  margin-left: 2px;
}

label .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

input[type="password"] {
  letter-spacing: 4px;
  font-size: 18px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  cursor: pointer;
}

/* ===== File Upload ===== */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
  position: relative;
}

.file-upload-area:hover, .file-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-upload-icon { font-size: 32px; margin-bottom: 8px; }
.file-upload-text { font-size: 14px; color: var(--text-muted); }
.file-upload-text strong { color: var(--primary); }

.image-preview {
  display: none;
  margin-top: 12px;
  position: relative;
}

.image-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: contain;
}

.preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

.btn-loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== Alert / Toast ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--error-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== Toast Notification ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  font-size: 14px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--primary);
  animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.fade-out { animation: fadeOut 0.3s ease forwards; }

/* ===== Announcement Cards ===== */
.announcement-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.announcement-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 3px solid var(--primary);
  transition: background 0.15s;
}

.announcement-item.pinned {
  border-left-color: var(--warning);
  background: var(--warning-light);
}

.announcement-item h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.announcement-item p {
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-line;
}

.announcement-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: #065f46; }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-gray { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-red { background: var(--error-light); color: #991b1b; }

/* ===== My Submissions ===== */
.my-submission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.submission-thumb {
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.submission-thumb:hover { box-shadow: var(--shadow-md); }

.submission-thumb img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.submission-thumb .thumb-info {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.submission-thumb .thumb-week {
  font-weight: 600;
  color: var(--primary);
  font-size: 12px;
}

/* ===== Week Checklist ===== */
.week-checklist {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.week-chip {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

.week-chip.done {
  background: var(--success-light);
  border-color: var(--success);
  color: #065f46;
}

/* ===== Admin Layout ===== */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #1e293b;
  color: white;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
  font-size: 15px;
  font-weight: 700;
  color: white;
  margin-bottom: 2px;
}

.sidebar-header p {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  transition: all 0.15s;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover, .nav-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.admin-content {
  flex: 1;
  margin-left: 220px;
  padding: 24px;
  min-height: 100vh;
  background: var(--bg);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-topbar h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-unit {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 2px;
}

/* ===== Week Filter ===== */
.week-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.week-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: white;
  color: var(--text-muted);
  transition: all 0.15s;
  font-family: inherit;
}

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

.week-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== Submission Grid (Admin) ===== */
.submissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.sub-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.sub-card:hover { box-shadow: var(--shadow-md); }

.sub-card-image {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  cursor: zoom-in;
  background: var(--bg);
  display: block;
}

.sub-card-body {
  padding: 12px;
}

.sub-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.sub-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sub-card-note {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 8px;
  border-radius: 4px;
  margin-top: 8px;
  white-space: pre-line;
}

.sub-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.sub-card-file-thumb {
  width: 100%;
  aspect-ratio: 16/10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
}

/* ===== Student Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg); }

/* ===== Announcements Admin ===== */
.announcement-admin-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.announcement-admin-body h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.announcement-admin-body p {
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-line;
  max-height: 60px;
  overflow: hidden;
}

.announcement-admin-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Image zoom modal */
.img-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}

.img-modal-overlay.open { display: flex; }
.img-modal-overlay img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 4px; }

/* ===== Login Page ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ===== Animations ===== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.25s ease; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-header { display: none; }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 8px;
    gap: 4px;
    flex-direction: row;
  }

  .nav-item { padding: 8px 12px; font-size: 12px; }
  .sidebar-footer { padding: 8px; }

  .admin-content { margin-left: 0; padding: 16px; }
  .admin-wrapper { flex-direction: column; }

  .form-row { grid-template-columns: 1fr; }
  .week-checklist { grid-template-columns: repeat(5, 1fr); }
  .submissions-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .container { padding: 0 12px; }
  .card { padding: 16px; }
  .week-checklist { grid-template-columns: repeat(3, 1fr); }
  .my-submission-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Sort buttons (submissions) ===== */
.sort-btn {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: var(--text-muted);
  transition: all 0.15s;
  font-family: inherit;
}
.sort-btn:hover { border-color: var(--primary); color: var(--primary); }
.sort-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ===== Sortable table headers ===== */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover { background: #e2e8f0; }
.sort-indicator { font-size: 11px; margin-left: 2px; color: var(--primary); }

/* ===== Utility ===== */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-center { text-align: center; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.hidden { display: none !important; }
