/* ============================================
   ORCOMA ACADEMY — TEMA ADMIN ESCURO
   Inspirado no estilo da página de Login
   ============================================ */

/* Back button row */
.back-button-row {
  margin-bottom: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  transition: background 0.2s, border-color 0.2s;
}

.back-link:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93bffb;
}

.back-link i {
  font-size: 12px;
}

:root {
  --bg-primary: #0a1628;
  --bg-surface: #0d1f3c;
  --bg-surface-2: #102542;
  --bg-card: #122a4a;
  --border-color: #1e3350;
  --text-primary: #ffffff;
  --text-secondary: #8b9ab5;
  --text-muted: #4a5568;
  --accent-blue: #1a3d6e;
  --accent-blue-hover: #234d8a;
  --accent-orange: #ff9d00;
  --accent-red: #dc2626;
  --font-display: 'Sora', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Override Django CSS variables — tema escuro */
  --primary: #1a3d6e;
  --secondary: #0d1f3c;
  --primary-fg: #ffffff;
  --body-fg: #ffffff;
  --body-bg: #0a1628;
  --body-quiet-color: #8b9ab5;
  --body-medium-color: #e0e6f0;
  --body-loud-color: #ffffff;
  --header-color: #ffffff;
  --header-branding-color: #ffffff;
  --header-bg: #0d1f3c;
  --header-link-color: #ffffff;
  --breadcrumbs-fg: #8b9ab5;
  --breadcrumbs-link-fg: #ffffff;
  --breadcrumbs-bg: #102542;
  --link-fg: #ffffff;
  --link-hover-color: #e0e6f0;
  --link-selected-fg: #ffffff;
  --hairline-color: #1e3350;
  --border-color: #1e3350;
  --error-fg: #f87171;
  --darkened-bg: #0d1f3c;
  --selected-bg: #1e3350;
  --selected-row: rgba(255, 157, 0, 0.08);
  --button-fg: #ffffff;
  --button-bg: #1a3d6e;
  --button-hover-bg: #234d8a;
  --default-button-bg: #1a3d6e;
  --default-button-hover-bg: #234d8a;
  --close-button-bg: #102542;
  --close-button-hover-bg: #1e3350;
  --delete-button-bg: #dc2626;
  --delete-button-hover-bg: #b91c1c;
  --object-tools-fg: #ffffff;
  --object-tools-bg: #1a3d6e;
  --object-tools-hover-bg: #234d8a;
}

/* Base */
html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
}

a:link, a:visited {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--text-secondary);
  text-decoration: none;
}

/* Cabeçalho / Header */
#header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: auto;
  box-sizing: border-box;
}

#branding h1, #branding h1 a:link, #branding h1 a:visited {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 600;
}

.admin-logo {
  height: 36px;
  width: auto;
  vertical-align: middle;
  margin-right: 10px;
}

.admin-brand-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  vertical-align: middle;
}

#site-name a {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 8px;
}

/* User tools (canto superior direito) */
#user-tools {
  font-size: 13px;
  color: var(--text-secondary);
}
#user-tools a {
  color: var(--text-primary);
  border-bottom: none;
}
#user-tools a:hover {
  color: var(--text-secondary);
}

/* Conteúdo principal */
#content {
  padding: 30px;
  background: var(--bg-primary);
}

#content h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Breadcrumbs */
div.breadcrumbs {
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 30px;
  font-size: 13px;
}
div.breadcrumbs a {
  color: var(--text-primary);
}

/* Módulos / Cards */
.module {
  background: linear-gradient(145deg, var(--bg-card), var(--bg-surface));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.2);
}

.module h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  padding: 0 0 12px 12px;
  margin: 0 0 16px 0;
  border-left: 3px solid var(--accent-orange);
}

.module caption {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  padding: 14px 16px;
  margin: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Tabelas */
table {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

thead th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

td, th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
}

tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* Botões */
.button, input[type=submit], input[type=button], .submit-row input, a.button {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(26, 61, 110, 0.3);
}

.button:hover, input[type=submit]:hover, input[type=button]:hover, .submit-row input:hover, a.button:hover {
  background: linear-gradient(135deg, var(--accent-blue-hover), #2a5a9e);
  box-shadow: 0 4px 16px rgba(26, 61, 110, 0.5);
  transform: translateY(-1px);
}

.button.default, input[type=submit].default, .submit-row input.default {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
  font-weight: 700;
}

.button.default:hover, input[type=submit].default:hover {
  background: linear-gradient(135deg, var(--accent-blue-hover), #2a5a9e);
  box-shadow: 0 4px 16px rgba(26, 61, 110, 0.5);
  transform: translateY(-1px);
}

/* Botão deletar / ações perigosas */
.deletelink {
  background: var(--accent-red);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
}
.deletelink:hover {
  background: #b91c1c;
}

/* Formulários */
.form-row {
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
  overflow: visible;
}

label {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}

input, textarea, select {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  height: auto;
  min-height: 36px;
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent-orange);
  outline: none;
}

.vTextField, .vLargeTextField {
  width: 100%;
}

/* Filtros */
#changelist-filter {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
}

#changelist-filter h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  padding: 0 0 12px 10px;
  margin: 0 0 12px 0;
  border-left: 3px solid var(--accent-orange);
}

#changelist-filter li {
  border-bottom: none;
  padding: 4px 0;
}

#changelist-filter a {
  color: var(--text-secondary);
  font-size: 13px;
}

#changelist-filter li.selected a {
  color: var(--text-primary);
  font-weight: 600;
}

/* Paginação */
.paginator {
  color: var(--text-secondary);
  font-size: 13px;
  padding: 15px 0;
}
.paginator a {
  color: var(--text-primary);
}
.paginator .this-page {
  background: var(--accent-blue);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Links de ação nos resultados */
.action-counter {
  color: var(--text-secondary);
}

/* Dashboard */
.dashboard .module table th {
  width: auto;
}

.dashboard .module table td {
  white-space: nowrap;
}

.dashboard .module table td a {
  color: var(--text-primary);
  font-weight: 500;
}

/* Login page — customizado inline em login.html */

/* Erro / Mensagens */
.errornote, .errorlist {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-md);
  color: #fca5a5;
  padding: 10px 14px;
  font-size: 13px;
}

.success, .messagelist li.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  border-radius: var(--radius-md);
  color: #6ee7b7;
  padding: 10px 14px;
}

.warning, .messagelist li.warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

/* Footer */
.admin-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: 30px;
}

/* Help text */
.help, p.help, form p.help, div.help, .timezonewarning {
  color: var(--text-muted);
  font-size: 12px;
}

/* Inline groups */
.inline-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 900px;
}

.inline-group h2 {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 15px;
  padding: 12px 16px;
  margin: 0;
  border-bottom: 1px solid var(--border-color);
}

/* Selector (many-to-many widget) */
.selector {
  width: 100%;
}

.selector select {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.selector-chosen h2 {
  background: var(--accent-blue) !important;
  color: #fff !important;
}

/* Date picker */
.calendar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.calendar td, .calendar th {
  background: transparent;
  border: none;
  color: var(--text-primary);
}

.calendar td a {
  color: var(--text-primary);
}

.calendar td a:hover {
  background: var(--accent-blue);
  border-radius: var(--radius-sm);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   SIDEBAR COM MENUS EXPANSÍVEIS
   ============================================ */

.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.admin-sidebar__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.admin-sidebar__logo-img {
  height: 80px;
  width: auto;
}

.admin-sidebar__nav {
  padding: 12px 12px;
  flex: 1;
}

.admin-sidebar__nav ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ── Card item ── */
.admin-nav-item a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.admin-nav-item a:hover {
  border-color: var(--accent-blue);
}

.admin-nav-item.active > a {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
  color: #fff;
  font-weight: 600;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(26, 61, 110, 0.4);
}

.admin-nav-item .typing-nav i {
  font-size: 26px;
  width: 26px;
  text-align: center;
  transition: transform 0.2s ease;
}

.admin-nav-item .typing-nav:hover i {
  transform: scale(1.15);
}

.admin-nav-item .typing-nav .nav-text {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}

.admin-nav-item .typing-nav .nav-text.typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent-orange);
  margin-left: 2px;
  animation: cursor-blink 0.7s step-end infinite;
  vertical-align: text-bottom;
}

.admin-nav-item.active .typing-nav .nav-text.typing::after {
  display: none;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Submenu Lateral ── */
.admin-nav-item.has-submenu {
  position: relative;
}

.admin-nav-item.has-submenu > a {
  cursor: pointer;
}

.submenu-arrow {
  font-size: 10px !important;
  width: auto !important;
  transition: transform 0.3s ease;
}

.admin-nav-item.has-submenu.open .submenu-arrow {
  transform: rotate(-90deg);
}

.admin-submenu {
  position: fixed;
  list-style: none;
  padding: 10px;
  margin: 0;
  min-width: 180px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-50%) translateX(-8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.admin-nav-item.has-submenu.open .admin-submenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}

.admin-submenu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.admin-submenu li a::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s;
}

.admin-submenu li a:hover {
  background: rgba(26, 61, 110, 0.25);
  border-color: var(--accent-blue);
  color: var(--text-primary);
}

.admin-submenu li a:hover::before {
  background: var(--accent-blue);
}

.admin-submenu li.active a {
  background: rgba(26, 61, 110, 0.35);
  color: #fff;
  font-weight: 600;
  border-color: var(--accent-blue);
}

.admin-submenu li.active a::before {
  background: var(--accent-blue);
}

/* Divider */
.admin-sidebar__divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 16px;
}

/* Back link */
.admin-sidebar__back {
  padding: 8px 12px 16px;
}

.admin-sidebar__back-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #ef4444;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s;
}

.admin-sidebar__back-link:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Main content */
.admin-main {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-topbar__toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}

.admin-topbar__toggle:hover {
  background: var(--bg-surface-2);
}

.admin-topbar__brand-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-topbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-topbar__user {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-topbar__user i {
  font-size: 16px;
}

.admin-topbar__logout {
  color: var(--text-muted);
  font-size: 16px;
  text-decoration: none;
  transition: color 0.15s;
}

.admin-topbar__logout:hover {
  color: #ef4444;
}

/* Content wrapper */
.admin-content {
  padding: 24px 30px;
  flex: 1;
}

/* Overlay */
.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.admin-overlay.is-visible {
  display: block;
}

/* Alert messages */
.admin-alert {
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid var(--border-color);
}

.admin-alert--success {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.admin-alert--error,
.admin-alert--danger {
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
}

.admin-alert--warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.admin-alert--info {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

/* Popup */
.admin-popup-content {
  padding: 20px;
}

/* Footer */
.admin-footer {
  text-align: center;
  padding: 16px 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border-color);
}

/* Page title */
.admin-page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px 0;
}

/* Override Django default header */
body:not(.popup) #header {
  display: none;
}

/* Ajustar conteúdo Django dentro do nosso layout */
.admin-content #content {
  padding: 0;
  background: none;
}

.admin-content #content-main {
  width: 100%;
}

/* Responsivo */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-topbar__toggle {
    display: block;
  }

  .admin-content {
    padding: 16px;
  }
}

/* Remove todo sublinhado do admin */
* {
  text-decoration: none !important;
}

/* ============================================
   CURSO ADMIN — OCULTAR ÍCONE DE OLHO (VIEW)
   ============================================ */
.related-widget-wrapper .view-related,
.related-widget-wrapper .related-widget-wrapper-link:nth-child(4),
.related-widget-wrapper .related-widget-wrapper-link[title="View"],
.related-widget-wrapper .related-widget-wrapper-link[title="Visualizar"] {
  display: none !important;
}

/* ============================================
   CURSO ADMIN — OVERFLOW NOS INLINES
   (Videos e Módulos)
   ============================================ */
.inline-group .aligned label {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-group .aligned .fieldBox input,
.inline-group .aligned .fieldBox textarea,
.inline-group .aligned .fieldBox select {
  max-width: 100%;
  box-sizing: border-box;
}

.inline-group table {
  table-layout: auto;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.inline-group table th,
.inline-group table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.inline-group table th {
  white-space: normal;
  word-wrap: break-word;
  font-size: 12px;
  color: var(--text-secondary);
}

.inline-group table td input[type="text"],
.inline-group table td input[type="url"],
.inline-group table td input[type="number"],
.inline-group table td select,
.inline-group table td textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 13px;
}

.inline-group .row-form-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  max-width: 100%;
}

/* ============================================
   CURSO ADMIN — BOTÃO + VERDE (ADICIONAR)
   ============================================ */
.add-related {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 20px !important;
  height: 20px !important;
  border-radius: 4px !important;
  background: #16a34a !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  vertical-align: middle !important;
}

.add-related:hover {
  background: #15803d !important;
}

/* ============================================
   CURSO ADMIN — ÍCONES DE EDITAR / EXCLUIR
   ============================================ */
.related-widget-wrapper .related-widget-wrapper-link img {
  filter: brightness(0) invert(1);
  width: 14px;
  height: 14px;
}
