/* Basic Theme and Layout */
:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --border: #e5e7eb;
  --shadow: 0 6px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", "Noto Sans", sans-serif;
  color: var(--text); background: linear-gradient(180deg, #ffffff, var(--bg));
}

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand { padding: 16px 18px; font-weight: 700; letter-spacing: .2px; color: var(--text); border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #ffffff, #f8fafc); }
.menu { padding: 12px; }
.menu-group { margin-bottom: 12px; }
.menu-title { padding: 10px 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.menu-item { display: block; padding: 10px 12px; color: var(--text); text-decoration: none; border-radius: 8px; margin: 4px 0; border: 1px solid transparent; }
.menu-item:hover { background: var(--panel-2); border-color: var(--border); }
.menu-item.active { background: rgba(91, 140, 255, 0.15); border-color: #3558b7; box-shadow: inset 0 0 0 1px rgba(91,140,255,.25); }

/* Main Area */
.main { display: grid; grid-template-rows: 56px 1fr; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.breadcrumbs { font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 18px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-body { padding: 14px 16px; }
.panel-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* New Layout Helpers */
.layout-2col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 72px; }

/* Forms/Buttons */
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.input, .select { height: 34px; padding: 0 10px; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; outline: none; }
.input::placeholder { color: #8b95a5; }
.btn { height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent; background: var(--primary); color: #fff; cursor: pointer; }
.btn:hover { background: var(--primary-600); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.warning { background: var(--warning); color: #1a1a1a; }
.btn.secondary { background: #e5e7eb; color: #111827; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); background: var(--panel-2); }
.badge.success { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.badge.gray { color: #334155; background: #f1f5f9; border-color: #e2e8f0; }
.badge.warning { color: #92400e; background: #fef3c7; border-color: #fde68a; }
.badge.danger { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.badge.role.super { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.badge.role.course { color: #1e40af; background: #dbeafe; border-color: #bfdbfe; }
.badge.role.ops { color: #166534; background: #dcfce7; border-color: #bbf7d0; }

/* Tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
.table th { color: var(--muted); font-weight: 600; position: sticky; top: 56px; background: var(--panel); z-index: 1; }
.table tbody tr:hover { background: #f9fafb; }

/* Pagination */
.pagination { display: flex; justify-content: flex-end; gap: 6px; padding: 12px 0; }
.page-btn { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer; }
.page-btn.active { background: rgba(91,140,255,.15); border-color: #3558b7; }

/* Tabs */
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab { padding: 10px 12px; border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--panel-2); cursor: pointer; }
.tab.active { background: rgba(91,140,255,.15); border-color: #3558b7; }

/* Modals */
.modal-root { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); z-index: 1000; }
.modal-root.hidden { display: none; }
.modal { width: min(980px, 96vw); background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }

/* Notifications */
.toast-root { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); }

/* Login Page Simple Styles */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 92vw); }
.login-card .panel-body { display: grid; gap: 12px; }

/* Draggable Upload Dropzone */
.dropzone { display: grid; place-items: center; gap: 8px; padding: 16px; border: 2px dashed var(--border); background: var(--panel-2); border-radius: 12px; color: var(--muted); cursor: pointer; min-height: 120px; text-align: center; }
.dropzone.hover { border-color: #93c5fd; background: rgba(37,99,235,0.08); color: #1e40af; }
.dropzone .dz-instructions { font-size: 13px; }
.dropzone input[type=file] { display: none; }
.dropzone .dz-preview { width: 100%; display: grid; place-items: center; gap: 8px; }
.dropzone .dz-preview img, .dropzone .dz-preview video { max-width: 100%; max-height: 240px; border-radius: 8px; background: #000; }
.dropzone .dz-actions { display: flex; gap: 8px; }

/* Description Text */
.caption { color: var(--muted); font-size: 12px; text-align: left; margin-top: 6px; }

/* Login mode: Hide sidebar and top navigation, show only login content */
.login-mode .sidebar,
.login-mode .topbar { display: none; }
.login-mode .app { grid-template-columns: 1fr; }
.login-mode .content { padding: 0; }

/* When modal is open, avoid background hover highlights (safety measure) */
.modal-open .table tbody tr:hover { background: inherit; }
.modal-open .menu-item:hover { background: inherit; border-color: transparent; }

/* Small Screen Optimization */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
}

/* Modern Login Page Styles */
.login-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 9999;
}

.login-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.floating-shapes {
  position: absolute;
  width: 100%;
  height: 100%;
}

.shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  animation: float 6s ease-in-out infinite;
}

.shape-1 {
  width: 120px;
  height: 120px;
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.shape-2 {
  width: 80px;
  height: 80px;
  top: 70%;
  left: 80%;
  animation-delay: 1s;
}

.shape-3 {
  width: 60px;
  height: 60px;
  top: 20%;
  right: 20%;
  animation-delay: 2s;
}

.shape-4 {
  width: 100px;
  height: 100px;
  bottom: 20%;
  left: 30%;
  animation-delay: 3s;
}

.shape-5 {
  width: 40px;
  height: 40px;
  top: 60%;
  right: 40%;
  animation-delay: 4s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

.login-content {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: white;
}

.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
}

.brand-section {
  text-align: center;
  max-width: 400px;
}

.brand-logo {
  margin-bottom: 32px;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  color: #667eea;
  margin-bottom: 24px;
}

.brand-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.brand-subtitle {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 48px;
}

.features-list {
  display: grid;
  gap: 24px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.feature-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.login-header {
  text-align: center;
  padding: 32px 32px 24px;
}

.login-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 8px;
}

.login-header p {
  color: #718096;
  font-size: 14px;
}

.login-form {
  padding: 0 32px 32px;
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2d3748;
  font-size: 14px;
}

.input-wrapper {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: #f7fafc;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: #a0aec0;
}

.password-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #a0aec0;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.password-toggle:hover {
  background: #f7fafc;
  color: #667eea;
}

.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #4a5568;
}

.checkbox-wrapper input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  position: relative;
  transition: all 0.3s ease;
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkmark {
  background: #667eea;
  border-color: #667eea;
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.forgot-link {
  color: #667eea;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.3s ease;
}

.forgot-link:hover {
  color: #764ba2;
}

.login-btn {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.login-btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-text {
  transition: opacity 0.3s ease;
}

.btn-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.login-footer {
  text-align: center;
  padding: 24px 32px;
  border-top: 1px solid #e2e8f0;
}

.login-footer p {
  color: #a0aec0;
  font-size: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .login-content {
    flex-direction: column;
  }

  .login-left {
    display: none;
  }

  .login-right {
    flex: 1;
    padding: 20px;
  }

  .login-card {
    max-width: 100%;
  }

  .shape {
    display: none;
  }
}

@media (max-width: 480px) {
  .login-right {
    padding: 10px;
  }

  .login-header {
    padding: 24px 24px 20px;
  }

  .login-form {
    padding: 0 24px 24px;
  }

  .login-footer {
    padding: 20px 24px;
  }
}

/* Login Error States */
.login-form.error {
  animation: shake 0.5s ease-in-out;
}

.form-group input.error {
  border-color: #e53e3e;
  background-color: #fff5f5;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.form-group input.error:focus {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.2);
}

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}
