/* ─── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-deep:   #4338ca;
  --primary-light:  rgba(99, 102, 241, 0.10);
  --primary-glow:   rgba(99, 102, 241, 0.20);
  --success:        #22c55e;
  --danger:         #ef4444;
  --warning:        #f59e0b;

  /* light palette */
  --bg:             #f5f5f5;
  --surface:        #ffffff;
  --surface-mid:    #f9f9f9;
  --surface-high:   #f3f3f3;
  --border:         #e2e2e2;
  --border-glow:    rgba(99,102,241,0.40);
  --text:           #1a1a2e;
  --text-muted:     #6b7280;
  --text-faint:     #9ca3af;

  --radius:         10px;
  --radius-sm:      6px;
  --radius-xs:      4px;
  --shadow-card:    0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --transition:     .2s cubic-bezier(.4,0,.2,1);
}

html, body {
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ────────────────────────────────────────────────── */
.page-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 16px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 52px;
  width: 100%;
  max-width: 460px;
  text-align: center;
  animation: cardIn .5s cubic-bezier(.22,.68,0,1.2) both;
}

.card-wide {
  max-width: 1040px;
  padding: 40px 48px;
}


/* ─── Typography ────────────────────────────────────────────── */
.page-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 10px;
}

.page-subtitle {
  font-size: .95rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* ─── Error pages ───────────────────────────────────────────── */
.error-code {
  font-size: 6rem;
  font-weight: 900;
  letter-spacing: -4px;
  line-height: 1;
  color: var(--primary);
  margin-bottom: 12px;
}

.error-message {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.6;
  max-width: 320px;
  margin-inline: auto;
}

/* ─── Login page ────────────────────────────────────────────── */
.login-logo {
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
  font-size: 34px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,.30);
}

.login-hint {
  font-size: .78rem;
  color: var(--text-faint);
  margin-top: 16px;
}

.fingerprint-display {
  font-size: .68rem;
  color: var(--text-faint);
  word-break: break-all;
  margin-top: 18px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  opacity: .5;
}

/* ─── Telegram auth button ──────────────────────────────────── */
.tg-auth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-inline: auto;
  gap: 10px;
  background: #2AABEE;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  margin-top: 24px;
  box-shadow: 0 2px 8px rgba(42,171,238,.25);
  letter-spacing: .01em;
}

.tg-auth-button::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.447 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.12l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.461c.537-.194 1.006.131.833.941z'/%3E%3C/svg%3E") center/contain no-repeat;
  flex-shrink: 0;
}


.tg-auth-button:active {
  box-shadow: 0 1px 4px rgba(42,171,238,.20);
}

/* ─── Google auth button ────────────────────────────────────── */
.google-auth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-inline: auto;
  gap: 10px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  letter-spacing: .01em;
  white-space: nowrap;
}

.google-auth-button::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.18 1.48-4.97 2.31-8.16 2.31-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3Cpath fill='none' d='M0 0h48v48H0z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.google-auth-button:hover {
  background: #f8f9fa;
  border-color: #c6c6c6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.google-auth-button:active {
  background: #f1f3f4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ─── Admin header ──────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.admin-badge {
  background: var(--surface-high);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  border: 1px solid var(--border);
}

/* ─── Table ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead {
  background: var(--surface-mid);
  border-bottom: 2px solid var(--border);
}

thead th {
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  white-space: nowrap;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 13px 18px;
  vertical-align: middle;
  color: var(--text);
}

tbody td:first-child {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ─── Devices cell ──────────────────────────────────────────── */
.devices-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.devices-cell p {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  min-width: 1ch;
}

.devices-cell span {
  color: var(--text-faint);
}

/* ─── Number input ──────────────────────────────────────────── */
input[type="number"] {
  width: 64px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-high);
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.4;
}

input[type="number"]:focus {
  outline: none;
  border-color: #aaa;
}

/* ─── Radio groups ──────────────────────────────────────────── */
.radio-group {
  display: flex;
  gap: 14px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-muted);
  transition: color var(--transition);
}

.radio-label:has(input:checked) {
  color: var(--text);
  font-weight: 600;
}

.radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ─── Pulse animation ───────────────────────────────────────── */
.pulse {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }


/* ─── Lessons ───────────────────────────────────────────────── */
.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.lesson-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-mid);
  overflow: hidden;
}

.lesson-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.lesson-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.lesson-badge {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  background: rgba(34, 197, 94, .12);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, .25);
}

.lesson-badge-empty {
  background: var(--surface-high);
  color: var(--text-faint);
  border-color: var(--border);
}

.lesson-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.lesson-section:last-child {
  border-bottom: none;
}

.lesson-section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.lesson-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.lesson-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-high);
  cursor: zoom-in;
  transition: transform var(--transition), box-shadow var(--transition);
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.preview-media {
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.lesson-empty-hint {
  font-size: .82rem;
  color: var(--text-faint);
  margin-bottom: 8px;
}

/* ─── File upload ────────────────────────────────────────────── */
.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.file-upload-input {
  display: none;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .82rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  white-space: nowrap;
}

.file-upload-label:hover .file-upload-btn {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.file-upload-hint {
  font-size: .78rem;
  color: var(--text-faint);
}

/* ─── Lesson add form ────────────────────────────────────────── */
.lesson-add-form {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.lesson-add-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.lesson-add-input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-high);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.lesson-add-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.lesson-add-input::placeholder {
  color: var(--text-faint);
}

/* ─── Video row ──────────────────────────────────────────────── */
.lesson-video-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-watch {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}

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

/* ─── Preview modal ──────────────────────────────────────────── */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  backdrop-filter: blur(4px);
}

.preview-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.preview-box {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  background: #000;
  animation: previewIn .2s cubic-bezier(.22,.68,0,1.2) both;
}

@keyframes previewIn {
  from {  opacity: 0; }
  to   {   opacity: 1; }
}

.preview-media {
  display: block;
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
}

.preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background var(--transition);
}

.preview-close:hover {
  background: rgba(0,0,0,.8);
}


/* ─── Button ─────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}


.btn-primary:active {
}

/* ─── Secondary button ──────────────────────────────────────── */
.btn-secondary {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ─── Toggle row ─────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-mid);
  margin-bottom: 28px;
}

.toggle-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toggle-dot--on  { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.toggle-dot--off { background: var(--text-faint); }

.toggle-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Danger button ──────────────────────────────────────────── */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  box-shadow: none;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, .08);
}

/* ─── Conspect item ──────────────────────────────────────────── */
.conspect-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.conspect-item:last-of-type {
  margin-bottom: 12px;
}

.conspect-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.conspect-title {
  flex: 1;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Conspect add form ──────────────────────────────────────── */
.conspect-add-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.conspect-add-input {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-high);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.conspect-add-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.conspect-add-input::placeholder {
  color: var(--text-faint);
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .card        { padding: 32px 24px; }
  .card-wide   { padding: 24px 16px; }
  .page-title  { font-size: 1.5rem; }
  .error-code  { font-size: 4.5rem; }

  thead th, tbody td { padding: 10px 12px; }
}
