@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --color-primary: #00A0DF;
  --color-primary-dark: #0070B8;
  --color-primary-light: #E6F7FF;
  --color-secondary: #5C6BC0;
  --color-background: #FFFFFF;
  --color-surface: #F5F7FA;
  --color-sidebar-bg: #FFFFFF;
  --color-sidebar-text: #333333;
  --color-sidebar-section: #00A0DF;
  --color-text: #333333;
  --color-text-secondary: #666666;
  --color-text-muted: #999999;
  --color-border: #E0E5EC;
  --color-success: #4CAF50;
  --color-warning: #FF9800;
  --color-error: #F44336;
  --border-radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--color-text);
  background: var(--color-surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }

button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---------- Shell layout ---------- */
.layout { display: flex; min-height: 100vh; }
.layout-main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; transition: margin-left 0.2s ease; }
.layout-content { flex: 1; padding: 24px; overflow-y: auto; }

.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--color-surface); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width); height: 100vh;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; z-index: 100;
  transition: width 0.2s ease;
}
html[data-sidebar-collapsed="1"] .sidebar { width: 64px; }
html[data-sidebar-collapsed="1"] .sidebar .sidebar-logo { justify-content: center; padding: 20px 8px; }
html[data-sidebar-collapsed="1"] .sidebar .sidebar-logo-text { display: none; }
html[data-sidebar-collapsed="1"] .sidebar .sidebar-nav-item { justify-content: center; padding: 10px 0; }
html[data-sidebar-collapsed="1"] .sidebar .sidebar-nav-item span:not(.sidebar-nav-icon) { display: none; }
html[data-sidebar-collapsed="1"] .sidebar .sidebar-section {
  height: 1px; padding: 0; margin: 12px 8px; background: var(--color-border); color: transparent;
}
.sidebar-toggle {
  position: absolute; top: 22px; right: -12px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--color-border); background: white;
  color: var(--color-text-secondary); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 101;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  padding: 0; line-height: 1;
}
.sidebar-toggle:hover { border-color: var(--color-primary); color: var(--color-primary); }
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px; border-bottom: 1px solid var(--color-border);
}
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 20px 8px; }
.sidebar-logo-icon {
  width: 32px; height: 32px; background: var(--color-primary); color: white;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar-logo-text { font-size: 14px; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-section {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-sidebar-section); padding: 16px 12px 6px;
  white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .sidebar-section {
  height: 1px; padding: 0; margin: 12px 8px; background: var(--color-border); color: transparent;
}
.sidebar-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px;
  color: var(--color-sidebar-text); font-size: 14px; font-weight: 400;
  transition: background 0.15s, color 0.15s; text-decoration: none;
  white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-nav-item span:not(.sidebar-nav-icon) { display: none; }
.sidebar-nav-item:hover { background: var(--color-surface); color: var(--color-primary); }
.sidebar-nav-item.active { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 500; }
.sidebar-nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-version {
  padding: 8px 16px 12px; font-size: 10px; letter-spacing: 0.4px;
  color: var(--color-text-muted); text-align: center; border-top: 1px solid var(--color-border);
  user-select: all;
}
html[data-sidebar-collapsed="1"] .sidebar-version { padding: 8px 4px 12px; font-size: 9px; }

/* ---------- Top bar ---------- */
.topbar {
  height: 56px; background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar-title { font-size: 18px; font-weight: 600; color: var(--color-text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; position: relative; }
.topbar-avatar {
  width: 32px; height: 32px; background: var(--color-primary); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; cursor: pointer; border: none;
}
.topbar-menu {
  position: absolute; top: 40px; right: 0;
  min-width: 200px; background: var(--color-background);
  border: 1px solid var(--color-border); border-radius: var(--border-radius);
  box-shadow: var(--shadow-md); padding: 6px; display: none; z-index: 200;
}
.topbar-menu.open { display: block; }
.topbar-menu a, .topbar-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; color: var(--color-text); background: transparent; border: none; text-decoration: none;
}
.topbar-menu a:hover, .topbar-menu button:hover { background: var(--color-surface); color: var(--color-primary); }
.topbar-menu-divider { height: 1px; background: var(--color-border); margin: 6px 0; }

/* ---------- Cards / stats / grids ---------- */
.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.quick-link {
  display: flex; align-items: center; gap: 14px;
  padding: 20px; background: var(--color-background);
  border: 1px solid var(--color-border); border-radius: var(--border-radius);
  transition: box-shadow 0.15s, border-color 0.15s; text-decoration: none; color: inherit;
}
.quick-link:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.quick-link-icon {
  width: 40px; height: 40px; background: var(--color-primary-light); color: var(--color-primary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.quick-link-title { font-weight: 600; font-size: 14px; color: var(--color-text); }
.quick-link-desc { font-size: 12px; color: var(--color-text-secondary); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--color-background); border: 1px solid var(--color-border);
  border-radius: var(--border-radius); padding: 20px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: 12px; color: var(--color-text-secondary); margin-top: 4px; }

.panel {
  background: var(--color-background); border: 1px solid var(--color-border);
  border-radius: var(--border-radius); padding: 20px;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.panel-header h2 { font-size: 16px; font-weight: 600; }
.panel-header a { font-size: 13px; font-weight: 500; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--color-text-secondary); padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}
.data-table td { padding: 12px; font-size: 14px; border-bottom: 1px solid var(--color-border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .empty { text-align: center; color: var(--color-text-muted); padding: 24px !important; }

/* ---------- Forms ---------- */
.form-card {
  background: var(--color-background); border: 1px solid var(--color-border);
  border-radius: var(--border-radius); padding: 32px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow);
}
.form-card-wide { max-width: 640px; }
.form-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; }
.form-brand-icon {
  width: 40px; height: 40px; background: var(--color-primary); color: white;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.form-brand-text { font-size: 16px; font-weight: 600; color: var(--color-text); }
.form-title { font-size: 20px; font-weight: 600; margin-bottom: 6px; text-align: center; }
.form-subtitle { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 24px; text-align: center; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--color-text); }
.form-control {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--color-border); border-radius: 6px;
  background: white; color: var(--color-text); transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(0, 160, 223, 0.12); }
.form-control.is-invalid { border-color: var(--color-error); }
.form-error { color: var(--color-error); font-size: 12px; margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-text-secondary); }
.form-check input { width: 16px; height: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.form-hint { font-size: 12px; color: var(--color-text-secondary); text-align: center; margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); color: white; }
.btn-secondary { background: white; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-block { width: 100%; }
.btn-danger { background: var(--color-error); color: white; }
.btn-danger:hover { background: #C62828; color: white; }

/* ---------- Flash messages ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; font-size: 13px; border-radius: 6px;
  border: 1px solid var(--color-border); background: var(--color-background);
}
.flash-success { border-color: #C8E6C9; background: #E8F5E9; color: #256029; }
.flash-error   { border-color: #FFCDD2; background: #FFEBEE; color: #B71C1C; }
.flash-info    { border-color: #B3E5FC; background: #E1F5FE; color: #01579B; }
.flash-warning { border-color: #FFE0B2; background: #FFF3E0; color: #7A4A00; }
.flash-close { background: transparent; border: none; font-size: 16px; color: inherit; opacity: 0.7; }
.flash-close:hover { opacity: 1; }

/* ---------- Profile ---------- */
.profile-header {
  display: flex; align-items: center; gap: 20px; padding: 24px;
  background: var(--color-background); border: 1px solid var(--color-border);
  border-radius: var(--border-radius); margin-bottom: 20px;
}
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--color-primary-light); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 18px; font-weight: 600; }
.profile-meta { font-size: 13px; color: var(--color-text-secondary); }

/* ---------- Save-status toast ---------- */
.tutorial-toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.tutorial-toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 360px;
  padding: 12px 14px; border-radius: 6px;
  font-size: 14px; font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-background);
  box-shadow: var(--shadow-md);
  transform: translateY(20px); opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.tutorial-toast.show { transform: translateY(0); opacity: 1; }
.tutorial-toast-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; flex-shrink: 0;
}
.tutorial-toast-success { border-color: #C8E6C9; background: #F1F8E9; color: #256029; }
.tutorial-toast-success .tutorial-toast-icon { background: #2E7D32; }
.tutorial-toast-error { border-color: #FFCDD2; background: #FFEBEE; color: #B71C1C; }
.tutorial-toast-error .tutorial-toast-icon { background: #C62828; }
.wp-msg-toast { border-color: #B3E5FC; background: #E1F5FE; color: #01579B; min-width: 300px; max-width: 420px; align-items: flex-start; }
.wp-msg-toast .tutorial-toast-icon { background: #0277BD; margin-top: 2px; }
.wp-msg-toast .wp-msg-body { flex: 1; }
.wp-msg-toast .wp-msg-label { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; opacity: 0.75; margin-bottom: 2px; }
.wp-msg-toast .wp-msg-time { text-transform: none; letter-spacing: 0; opacity: 0.7; }
.wp-msg-toast .wp-msg-text { white-space: pre-wrap; line-height: 1.4; }
.tutorial-toast-msg { flex: 1; }
.tutorial-toast-close {
  background: transparent; border: none; color: inherit; opacity: 0.5;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.tutorial-toast-close:hover { opacity: 1; }

/* ---------- Sticky lab-timer badge ---------- */
.wp-timer-badge {
  position: fixed;
  top: 80px; right: 24px;
  z-index: 5000;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 190px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-background);
  box-shadow: var(--shadow-md);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  pointer-events: none;
}
.wp-timer-badge.is-visible { display: flex; }
.wp-timer-row { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.wp-timer-row + .wp-timer-row { border-top: 1px solid var(--color-border); padding-top: 6px; }
.wp-timer-status {
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--color-text-secondary);
}
.wp-timer-value {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 22px; font-weight: 700; color: var(--color-primary-dark);
  line-height: 1;
}
.wp-timer-label {
  font-size: 11px; color: var(--color-text-secondary);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wp-timer-row.is-warning .wp-timer-value { color: var(--color-warning); }
.wp-timer-row.is-warning .wp-timer-status { color: var(--color-warning); }
.wp-timer-row.is-expired .wp-timer-value { color: var(--color-error); }
.wp-timer-row.is-expired .wp-timer-status { color: var(--color-error); }
.wp-timer-row.is-paused .wp-timer-value { color: var(--color-text-secondary); }

/* ---------- Lab attachments (SE editor + WP view) ---------- */
.lab-materials {
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  padding: 12px 14px;
  background: #FAFBFD;
}
.lab-materials-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.lab-materials-list { list-style: none; padding: 0; margin: 0 0 8px; }
.lab-materials-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.lab-materials-list li a { color: var(--color-primary); text-decoration: none; }
.lab-materials-list li a:hover { text-decoration: underline; }
.btn-remove-attachment {
  background: transparent; border: 1px solid transparent; color: var(--color-text-muted);
  cursor: pointer; padding: 2px 8px; font-size: 16px; border-radius: 4px; line-height: 1;
}
.btn-remove-attachment:hover { border-color: var(--color-error); color: var(--color-error); }
.lab-materials-upload { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.lab-materials-upload input[type="file"] { flex: 1; font-size: 13px; }

.wp-lab-materials {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--color-primary-light);
  margin-bottom: 16px;
}
.wp-lab-materials-header {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--color-primary-dark); font-weight: 700; margin-bottom: 6px;
}
.wp-lab-materials-list { list-style: none; padding: 0; margin: 0; }
.wp-lab-materials-list li { padding: 4px 0; font-size: 14px; }
.wp-lab-materials-list a { color: var(--color-primary-dark); text-decoration: none; font-weight: 500; }
.wp-lab-materials-list a:hover { text-decoration: underline; }

/* ---------- Editor.js Delimiter (horizontal rule) ---------- */
.ce-delimiter, .content-hr {
  border: none;
  border-top: 2px dashed var(--color-border);
  margin: 20px 0;
  height: 0;
}

/* ---------- Editor.js container ---------- */
.editorjs-holder {
  min-height: 320px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-background);
  padding: 12px 16px;
}
.editorjs-holder .ce-block__content,
.editorjs-holder .ce-toolbar__content {
  max-width: 100%;
}

/* Custom callout blocks (Hint + AdminNotes) */
.callout {
  border-left: 4px solid;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--color-background);
}
.callout-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.callout-body {
  font-size: 14px;
  color: var(--color-text);
  outline: none;
}
.callout-body[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
}
.callout-hint {
  border-left-color: #F9A825;
  background: #FFF8E1;
}
.callout-hint .callout-label { color: #B07300; }
.callout-admin {
  border-left-color: #C62828;
  background: #FFEBEE;
}
.callout-admin .callout-label { color: #B71C1C; }
.callout-admin .callout-label::after {
  content: ' \00b7 SE only — hidden from participants';
  font-weight: 500;
  opacity: 0.75;
}

/* ---------- Row actions kebab menu ---------- */
.row-actions { position: relative; display: inline-block; }
.row-actions-btn {
  background: transparent; border: 1px solid transparent; color: var(--color-text-secondary);
  width: 28px; height: 28px; border-radius: 4px; font-size: 18px; line-height: 1; cursor: pointer; padding: 0;
}
.row-actions-btn:hover { border-color: var(--color-border); color: var(--color-primary); background: var(--color-surface); }
.row-actions-menu {
  display: none; position: absolute; right: 0; top: 32px; z-index: 30;
  min-width: 160px; background: var(--color-background);
  border: 1px solid var(--color-border); border-radius: 6px; box-shadow: var(--shadow-md); padding: 4px;
}
.row-actions.open .row-actions-menu { display: block; }
.row-actions-menu.flip-up { top: auto; bottom: 32px; }
.row-actions-menu a,
.row-actions-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px;
  background: transparent; border: none; border-radius: 4px;
  font-size: 13px; color: var(--color-text); text-decoration: none; cursor: pointer;
}
.row-actions-menu a:hover,
.row-actions-menu button:hover { background: var(--color-surface); color: var(--color-primary); }
.row-actions-menu .row-menu-admin { color: var(--color-primary-dark); font-weight: 500; }
.row-actions-menu .row-menu-danger { color: var(--color-error); }
.row-actions-menu .row-menu-danger:hover { background: #FFEBEE; color: var(--color-error); }
.row-actions-header {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--color-text-muted); padding: 6px 10px 4px;
  border-bottom: 1px solid var(--color-border); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
.row-actions-divider { height: 1px; background: var(--color-border); margin: 4px 0; }
.row-menu-form { margin: 0; }

/* ---------- Small utils ---------- */
.muted { color: var(--color-text-secondary); }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 20px; font-weight: 600; }
