/* Base reset and typography */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:   #e63946;
  --color-primary-d: #c1121f;
  --color-bg:        #ffffff;
  --color-surface:   #f8f9fa;
  --color-border:    #dee2e6;
  --color-text:      #212529;
  --color-text-muted:#6c757d;
  --color-success:   #198754;
  --color-danger:    #dc3545;
  --color-warning:   #ffc107;
  --radius:          6px;
  --shadow:          0 1px 3px rgba(0,0,0,.08);
  --container:       1100px;
  --nav-h:           56px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

/* Container */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 1rem; }

/* Nav */
nav {
  height: var(--nav-h);
  background: var(--color-text);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
nav a {
  color: #fff;
  text-decoration: none;
  font-size: .95rem;
  font-weight: 500;
  white-space: nowrap;
}
nav a:hover { color: var(--color-primary); }
nav .nav-spacer { flex: 1; }
nav form { display: inline; }
nav button {
  background: none;
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  padding: .35rem .9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
}
nav button:hover { background: rgba(255,255,255,.1); }

/* Main layout */
main { padding: 2rem 1.5rem; min-height: calc(100vh - var(--nav-h)); }

/* Typography */
h1 { font-size: 1.9rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.4rem; font-weight: 600; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 1.25rem 0 .5rem; }
p  { margin-bottom: .75rem; }
a  { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Forms */
form { max-width: 480px; }
label {
  display: block;
  font-size: .9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: .25rem;
  margin-top: 1rem;
}
label:first-of-type { margin-top: 0; }
input[type=text],
input[type=email],
input[type=password],
input[type=number],
select,
textarea {
  display: block;
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(230,57,70,.15);
}
input[type=checkbox] { width: auto; margin-right: .4rem; }
textarea { resize: vertical; min-height: 80px; }

/* Buttons */
button, .btn {
  display: inline-block;
  padding: .55rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  background: var(--color-primary);
  color: #fff;
}
button:hover, .btn:hover { background: var(--color-primary-d); text-decoration: none; }
button[type=submit] { margin-top: 1.25rem; }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: #fff; }
.btn-secondary { background: var(--color-text-muted); }
.btn-secondary:hover { background: #495057; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #b02a37; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-weight: 600; background: var(--color-surface); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
tr:hover td { background: var(--color-surface); }
table code { font-size: .85em; background: #f1f3f5; padding: .1em .3em; border-radius: 3px; }

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
}
.card h3 { margin-top: 0; }
.card p { flex: 1; color: var(--color-text-muted); font-size: .92rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--color-surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  text-align: center;
}
.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}
.stat-label {
  font-size: .85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}

/* Alerts / status */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .92rem;
}
.alert-success { background: #d1e7dd; color: #0a3622; }
.alert-error   { background: #f8d7da; color: #58151c; }
.alert-warn    { background: #fff3cd; color: #664d03; }
.alert-info    { background: #cff4fc; color: #055160; }
.error { color: var(--color-danger); font-size: .9rem; margin: .5rem 0; }

/* Badges */
.badge {
  display: inline-block;
  padding: .2em .55em;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: #d1e7dd; color: #0a3622; }
.badge-red    { background: #f8d7da; color: #58151c; }
.badge-yellow { background: #fff3cd; color: #664d03; }
.badge-gray   { background: #e9ecef; color: #495057; }

/* Progress bar */
.progress { height: 8px; background: var(--color-border); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--color-primary); transition: width .4s; }

/* Player wrapper */
#player-wrapper { border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); }
#player-frame   { aspect-ratio: 16/9; }

/* Breadcrumb */
.breadcrumb { font-size: .88rem; color: var(--color-text-muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb span::before { content: " / "; }

/* Admin nav strip */
.admin-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; font-size: .88rem; }
.admin-nav a { color: var(--color-text-muted); }
.admin-nav a:hover { color: var(--color-primary); }

/* Utilities */
.text-muted    { color: var(--color-text-muted); font-size: .88rem; }

/* Details / Summary (Instructor dashboard) */
details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .5rem 1rem;
  margin-bottom: .75rem;
  background: #fff;
}
summary {
  cursor: pointer;
  font-weight: 600;
  padding: .25rem 0;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "▸";
  margin-right: .5rem;
  color: var(--color-text-muted);
  display: inline-block;
  transition: transform .2s;
}
details[open] > summary::before { transform: rotate(90deg); }

.text-success  { color: var(--color-success); }
.text-danger   { color: var(--color-danger); }
.text-center   { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: .88em; background: #f1f3f5; padding: .1em .35em; border-radius: 3px; }
pre { background: #f1f3f5; padding: 1rem; border-radius: var(--radius); overflow-x: auto; font-size: .88rem; }

/* Responsive */
@media (max-width: 640px) {
  main { padding: 1.25rem 1rem; }
  nav { padding: 0 1rem; gap: 1rem; }
  h1 { font-size: 1.5rem; }
  table { font-size: .82rem; }
  th, td { padding: .5rem .6rem; }
  form { max-width: 100%; }
  .card-grid { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
  nav { flex-wrap: wrap; height: auto; padding: .5rem 1rem; }
}
