/* =====================================================
   TÊXTIL DIGITAL — CSS Principal
   ===================================================== */
:root {
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-bg: #f8fafc;
  --color-bg-card: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

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

img { max-width: 100%; display: block; }

/* ---- Sidebar Layout ---- */
.layout-admin, .layout-empresa {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px 20px 20px;
  border-bottom: 1px solid #334155;
  gap: 4px;
}

.brand-icon { font-size: 24px; }
.brand-logo { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; }
.brand-name { font-size: 15px; font-weight: 700; color: #f1f5f9; }
.sidebar-brand small { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-radius: 0;
  cursor: pointer;
}
.nav-item:hover { background: #334155; color: #f1f5f9; text-decoration: none; }
.nav-item.active { background: var(--color-primary); color: #fff; }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item.logout:hover { background: #7f1d1d; color: #fca5a5; }

.sidebar-footer { border-top: 1px solid #334155; padding: 8px 0; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title { font-size: 18px; font-weight: 700; color: var(--color-text); }

.topbar-user { font-size: 13px; color: var(--color-text-muted); }

.content-body { padding: 28px; flex: 1; }

/* ---- Cards ---- */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text);
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-text); }
.stat-sub   { font-size: 12px; color: var(--color-text-muted); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--color-text); }
.btn-danger  { background: var(--color-danger); color: #fff; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--color-text); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  font-size: 14px;
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fef08a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f1f5f9; color: #64748b; }

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

/* ---- Login page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  padding: 20px;
}

.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--color-text); }
.login-logo p { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }
.login-logo img { width: 72px; height: 72px; object-fit: contain; margin: 0 auto 12px; border-radius: 10px; }

.token-display {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}
.token-input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s;
}
.token-input:focus { border-color: var(--color-primary); }

/* ---- Área do usuário ---- */
.layout-usuario { min-height: 100vh; display: flex; flex-direction: column; }

.user-header {
  background: var(--color-primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.user-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.user-brand { font-weight: 700; font-size: 16px; white-space: nowrap; }

.user-nav { display: flex; gap: 4px; flex: 1; }
.user-nav a {
  padding: 6px 14px;
  border-radius: 6px;
  color: rgba(255,255,255,.8);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.user-nav a:hover { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
.user-nav a.active { background: rgba(255,255,255,.2); color: #fff; }

.user-info { display: flex; align-items: center; gap: 12px; white-space: nowrap; font-size: 13px; }
.btn-logout {
  background: rgba(255,255,255,.15);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.btn-logout:hover { background: rgba(255,255,255,.25); text-decoration: none; }

.user-main { flex: 1; max-width: 1100px; margin: 0 auto; width: 100%; padding: 32px 20px; }

.user-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* ---- Cursos ---- */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.course-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
}
.course-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }

.course-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #e2e8f0;
}
.course-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.5);
  font-size: 40px;
}

.course-body { padding: 16px; flex: 1; }
.course-title { font-size: 15px; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.course-desc { font-size: 13px; color: var(--color-text-muted); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--color-text-muted); }

/* ---- Vídeo Player ---- */
.video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.video-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}

/* ---- Aulas list ---- */
.aulas-list { display: flex; flex-direction: column; gap: 4px; }
.aula-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  transition: background .15s;
}
.aula-item:hover { background: #f8fafc; text-decoration: none; }
.aula-item.active { border-color: var(--color-primary); background: rgba(99,102,241,.04); }
.aula-item.locked { opacity: .5; cursor: not-allowed; }
.aula-num { font-size: 12px; font-weight: 700; color: var(--color-text-muted); width: 24px; flex-shrink: 0; }
.aula-info { flex: 1; }
.aula-title { font-size: 14px; font-weight: 500; color: var(--color-text); }
.aula-dur { font-size: 12px; color: var(--color-text-muted); }
.aula-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--color-border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.aula-check.done { background: var(--color-success); border-color: var(--color-success); color: #fff; font-size: 11px; }

/* ---- PDFs grid ---- */
.pdfs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.pdf-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: center;
  transition: box-shadow .2s, transform .2s;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.pdf-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.pdf-card-cover {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.pdf-card-no-cover {
  width: 100%;
  height: 160px;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
}
.pdf-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.pdf-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.pdf-icon { font-size: 40px; }
.pdf-title { font-size: 14px; font-weight: 600; color: var(--color-text); }
.pdf-size { font-size: 12px; color: var(--color-text-muted); }

/* ---- Canvas editor ---- */
.canvas-editor-wrap {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
.canvas-stage-wrap {
  background: transparent;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}
#canvas-stage { display: block; }
.canvas-controls { display: flex; flex-direction: column; gap: 12px; }
.canvas-controls .card { margin-bottom: 0; }

/* ---- Fotos collection ---- */
.fotos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.foto-thumb {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.foto-thumb:hover { transform: scale(1.03); }
.foto-thumb.selected { border-color: var(--color-primary); }

/* ---- Premiações ---- */
.premiacoes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.premiacao-card {
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  border: 1px solid #fde047;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.premiacao-icon { font-size: 48px; margin-bottom: 8px; }
.premiacao-title { font-size: 16px; font-weight: 700; color: #854d0e; }
.premiacao-desc { font-size: 13px; color: #92400e; margin-top: 4px; }
.premiacao-date { font-size: 11px; color: #a16207; margin-top: 8px; }

/* ---- Actions bar ---- */
.actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.actions-bar-left { display: flex; align-items: center; gap: 10px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .canvas-editor-wrap { grid-template-columns: 1fr; }
  .user-nav { display: none; }
}

/* ---- Toggle switch ---- */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #cbd5e1; border-radius: 22px; cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---- Upload zone ---- */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(99,102,241,.04);
}
.upload-zone-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone p { font-size: 14px; }
.upload-zone span { color: var(--color-primary); font-weight: 600; }
