/* ENVIA LMS | Components CSS: Buttons, Cards, Pills, Forms, Tables, Modals */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.78rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.card,
.metric-card,
.final-cta,
.dash-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.card {
  padding: 16px;
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #cdd8ea;
}

.card h3 { margin: 0; font-size: 1rem; }
.card p { margin: 8px 0 0; color: var(--text-soft); font-size: 0.9rem; }

.metric-card {
  padding: 16px;
}

.metric-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.metric-card h3 {
  margin: 8px 0 0;
  font-size: 1.3rem;
}

.pill {
  background: #e0ecff;
  color: #1e40af;
  border-radius: 999px;
  padding: 0.26rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
}

.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }

/* Profile dropdown in top-right */
.profile-menu { position: relative; }
.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}
.profile-meta {
  display: grid;
  gap: 1px;
  text-align: left;
  min-width: 0;
}
.profile-meta strong,
.profile-meta small {
  line-height: 1.1;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15,23,42,0.12);
  padding: 10px;
  z-index: 100;
}
.profile-dropdown .profile-summary { padding: 8px 4px; }
.profile-dropdown ul { list-style: none; margin: 6px 0 0; padding: 0; }
.profile-dropdown li { margin: 6px 0; }
.profile-dropdown a,
.profile-dropdown .button-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  text-decoration: none;
}
.profile-dropdown a:hover,
.profile-dropdown .button-link:hover { background: #f3f6ff; }

.button-link {
  font: inherit;
  cursor: pointer;
}

.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;
}


.tags {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags span {
  border: 1px solid #dbe6ff;
  border-radius: 999px;
  background: #edf3ff;
  color: #334155;
  font-size: 0.75rem;
  padding: 0.3rem 0.55rem;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.open { display: flex; }

.modal[style*="display: block"],
.modal[style*="display:block"] { display: flex !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(860px, calc(100% - 28px));
  max-height: min(84vh, 920px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  padding: 20px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: #eef4ff;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 1rem;
}

.modal-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-meta span {
  border: 1px solid var(--border);
  background: #f8fbff;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.modal-body {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.modal-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfdff;
  padding: 14px;
}

.modal-block h4 { margin: 0 0 10px; }

.modal-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
}

.modal-list li { margin-bottom: 6px; }

.form-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 0.9rem;
  color: var(--text-soft);
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.16);
  border-color: var(--primary);
}

.table-base {
  width: 100%;
  border-collapse: collapse;
}

.table-base th,
.table-base td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}

.table-base th {
  background: #f8fbff;
  font-weight: 600;
  color: var(--text);
}

.progress {
  height: 8px;
  width: 100%;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 999px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.role-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.role-card strong {
  display: block;
  margin-bottom: 4px;
}

.nav-link,
.sidebar-link {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  color: var(--text-soft);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.side-nav a:hover,
.side-nav a.active,
.nav-link:hover,
.nav-link.active,
.sidebar-link:hover,
.sidebar-link.active {
  background: #edf3ff;
  border-color: #dbe6ff;
  color: var(--primary);
}

.table-wrap {
  overflow-x: auto;
}

.table,
.table-base {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td,
.table-base th,
.table-base td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
}

.table th,
.table-base th {
  background: #f8fbff;
  font-weight: 600;
  color: var(--text);
}

.table tbody tr:hover,
.table-base tbody tr:hover {
  background: #f8fbff;
}

.progress {
  height: 8px;
  width: 100%;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 999px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.mini-bars,
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 120px;
}

.mini-bars i,
.chart-bars i {
  width: 18px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #93c5fd 0%, #2563eb 100%);
  display: block;
}

.chart-bars i { width: 20px; }

.empty-state,
.empty-box {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: #fbfdff;
}

.empty-state h3,
.empty-box h3 { margin: 10px 0 0; font-size: 1rem; }
.empty-state p,
.empty-box p { margin-top: 8px; color: var(--text-soft); }

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric-row article {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
}

.metric-row h4 {
  margin: 0;
  font-size: 1.2rem;
}

.metric-row p {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.final-cta {
  padding: 20px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: #fff;
}

.final-cta .btn-secondary,
.final-cta .button.secondary {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.sticky-cta {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
  padding: 14px;
  display: none;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.sticky-cta.show { display: flex; }

.sticky-actions { display: flex; align-items: center; gap: 8px; }

.sticky-actions button:last-child {
  border: 0;
  background: #eef4ff;
  color: var(--text-soft);
  border-radius: 999px;
  width: 34px;
  height: 34px;
}

.chart-shell,
.dash-preview { overflow: hidden; }

.chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.chart-title small { color: var(--text-soft); }

@media (max-width: 900px) {
  .hero-grid,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 84px;
  }
}

/* Backward-compatible button aliases used by older pages/modules */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.78rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--primary);
  color: #fff;
}
.button.primary { background: var(--primary); color:#fff; box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22); }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button:hover { transform: translateY(-1px); }


.modal-panel.compact { max-width: 560px; }
.modal-panel.wide { max-width: 960px; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.form-grid {
  display: grid;
  gap: 12px;
}
.filter-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}
@media (max-width: 980px) { .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .filter-bar { grid-template-columns: 1fr; } }
.activity-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  padding: 6px 10px;
  font-weight: 700;
  font-size: .82rem;
}
