/* =============================================================
   Plataforma de Cursos - estilos globales
   ============================================================= */

@import url("./design-tokens.css");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at top left, rgba(212,101,42,.14), transparent 18%),
    radial-gradient(circle at bottom right, rgba(122,46,53,.08), transparent 20%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

:focus-visible {
  outline: 3px solid rgba(212,101,42,.33);
  outline-offset: 2px;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app-header {
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid rgba(224,216,204,.9);
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 18px 45px rgba(26,24,20,.08);
  backdrop-filter: blur(10px);
}
.app-header .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header .brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  background: var(--text);
  color: var(--bg);
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
}
.app-header nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.app-header .header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.app-header .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px 7px 8px;
  background: rgba(26,24,20,.06);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.user-chip .avatar {
  width: 26px; height: 26px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.container {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 24px;
}
.container.narrow { max-width: 720px; }

/* ---------- Card ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.02em; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}
.section-title h2 { margin: 0; }
.section-title .description {
  color: var(--muted);
  font-size: 14px;
}

.page-hero {
  background: var(--color-parchment);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 28px;
  margin-bottom: 28px;
}
.page-hero h1 {
  margin: 0 0 10px;
  font-size: 34px;
  color: var(--text);
  line-height: 1.1;
}
.page-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
  font-size: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.summary-card strong {
  display: block;
  font-size: 36px;
  margin-bottom: 8px;
}
.summary-card .muted {
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s, background .18s, box-shadow .18s;
  text-decoration: none;
  box-shadow: 0 16px 36px rgba(26,24,20,.08);
}
.btn:hover { background: var(--secondary); transform: translateY(-1px); }
.btn:disabled { opacity: .65; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--secondary-soft); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #7A2E35; }
.btn.success { background: var(--success); color: #fff; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.full { width: 100%; justify-content: center; }
.btn.ghost { background: transparent; color: var(--secondary); padding: 8px 12px; }
.btn.ghost:hover { background: var(--secondary-soft); }

/* ---------- Form ---------- */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row input[type="url"],
.form-row input[type="date"],
.form-row input[type="datetime-local"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 13px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}
.form-row textarea { min-height: 96px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(212,101,42,.12);
}
.form-row input::placeholder,
.form-row textarea::placeholder { color: rgba(107,101,96,.72); }
.upload-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  background: rgba(245,240,232,.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tab {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.tab.active {
  color: #fff;
  background: var(--text);
}
.tab:hover { color: var(--text); background: rgba(26,24,20,.06); }

/* ---------- Table ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}
.table tr:hover td { background: rgba(212,101,42,.04); }

/* ---------- Grid de cursos / clases ---------- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.tile {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s;
  color: var(--text);
  min-height: 168px;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(26,24,20,.08);
  text-decoration: none;
}
.tile .tile-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--secondary);
  background: var(--secondary-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.tile h3 { margin: 0 0 10px; font-size: 18px; color: var(--text); }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Lista vertical ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.list-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(26,24,20,.08);
  background: rgba(245,240,232,.65);
}
.list-item .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.list-item strong { font-weight: 700; }
.list-item .actions { display: flex; gap: 8px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge.gray { background: rgba(224,216,204,.6); color: var(--text); }
.badge.indigo { background: var(--secondary-soft); color: var(--secondary); }
.badge.green { background: rgba(122,139,111,.12); color: var(--success); }
.badge.orange { background: rgba(212,101,42,.12); color: var(--secondary); }
.badge.red { background: rgba(122,46,53,.12); color: var(--danger); }

/* ---------- Alerts ---------- */
.alert {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.6;
}
.alert.error { background: rgba(122,46,53,.12); color: var(--danger); border: 1px solid rgba(122,46,53,.18); }
.alert.success { background: rgba(122,139,111,.12); color: var(--success); border: 1px solid rgba(122,139,111,.18); }
.alert.info { background: rgba(212,101,42,.1); color: var(--text); border: 1px solid rgba(212,101,42,.18); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 36px rgba(26,24,20,.18);
  font-weight: 700;
  max-width: min(360px, calc(100vw - 32px));
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(212,101,42,.18);
  border-top-color: var(--secondary);
  border-radius: 999px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(212,101,42,.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(122,46,53,.08), transparent 22%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  padding: 40px;
  border-radius: 28px;
  box-shadow: 0 24px 70px rgba(26,24,20,.12);
  border: 1px solid rgba(224,216,204,.85);
}
.login-card .brand {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 10px;
}
.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 30px;
}
.login-card .form-row { margin-bottom: 18px; }
.login-card .form-row label { font-size: 14px; }
.login-card .btn.full { margin-top: 12px; }

/* ---------- Embed responsive ---------- */
.embed-wrapper {
  position: relative;
  padding-top: 56.25%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}
.embed-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- Exam ---------- */
.exam-question {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.exam-question h4 {
  margin: 0 0 14px;
  font-size: 16px;
}
.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.option-row:hover { background: rgba(212,101,42,.08); }
.option-row input { margin: 0; }

.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.match-left {
  padding: 12px 14px;
  background: rgba(245,240,232,.75);
  border-radius: var(--radius-sm);
}
.match-right select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
}

.exam-timer {
  position: sticky;
  top: 70px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 14px;
  font-weight: 700;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,24,20,.4);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 22px 60px rgba(26,24,20,.18);
}
.modal h3 { margin-top: 0; }
.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Helpers ---------- */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.space-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.mt-2 { margin-top: 12px; }
.mb-2 { margin-bottom: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 700px) {
  .app-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .app-header .brand { width: 100%; }
  .app-header .header-actions { width: 100%; justify-content: space-between; }
  .container { padding: 0 14px; margin: 18px auto; }
  .page-hero { padding: 22px 20px; border-radius: 16px; }
  .page-hero h1 { font-size: 28px; }
  .login-card { padding: 28px 22px; border-radius: 20px; }
  .section-title,
  .space-between,
  .list-item {
    align-items: stretch;
    flex-direction: column;
  }
  .list-item .actions,
  .modal .actions,
  .row {
    align-items: stretch;
  }
  .btn,
  .btn.small,
  .btn.ghost {
    justify-content: center;
  }
  .table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  .match-grid { grid-template-columns: 1fr; }
}
