:root {
  --bg-body: #0f172a;
  --bg-card: #0b1120;
  --bg-elevated: #020617;
  --border-subtle: #1e293b;
  --primary: #38bdf8;
  --primary-soft: rgba(56, 189, 248, 0.12);
  --danger: #f97373;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --radius-lg: 12px;
  --radius-full: 999px;
  --shadow-soft: 0 18px 35px rgba(15, 23, 42, 0.75);
  --shadow-light: 0 10px 25px rgba(15, 23, 42, 0.7);
  --transition-fast: 150ms ease-out;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937, #020617 55%);
  color: var(--text-main);
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e5e7eb;
}

/* Layout - login */

.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.app-title {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.75rem;
  letter-spacing: 0.04em;
}

.card {
  background: radial-gradient(circle at top left, #111827, #020617);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: var(--shadow-soft);
}

.login-card h2 {
  margin-top: 0;
  margin-bottom: 1.2rem;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
}

.login-hint {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Layout - app */

.page-midia {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(to right, #020617, #020617, #020617, #020617);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e5e7eb;
}

.topbar-subtitle {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-info {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.layout-single {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

.panel {
  background: radial-gradient(circle at top left, #020617, #020617 45%, #020617 100%);
  border-radius: 18px;
  padding: 1.25rem 1.3rem 1.35rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: var(--shadow-soft);
}

.panel-filters {
  align-self: flex-start;
  position: sticky;
  top: 5.25rem;
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cbd5f5;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.panel-header h2 {
  margin: 0;
}

.panel-header-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.panel-divider {
  height: 1px;
  background: radial-gradient(circle at left, rgba(248, 250, 252, 0.16), transparent 65%);
  margin: 1.15rem 0 1.1rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  border-radius: 10px;
  border: 1px solid rgba(30, 64, 175, 0.7);
  background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.25), rgba(15, 23, 42, 0.95));
  color: var(--text-main);
  padding: 0.55rem 0.65rem;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background 120ms ease-out;
}

input[type="file"] {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45);
}

/* Botões */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.1;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 110ms ease-out, box-shadow 110ms ease-out;
  background: #020617;
  color: var(--text-main);
}

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: linear-gradient(to right, #0ea5e9, #22c55e);
  border-color: rgba(59, 130, 246, 0.7);
  color: #0f172a;
  font-weight: 600;
  box-shadow: var(--shadow-light);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.9);
}

.btn-secondary {
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.22), rgba(15, 23, 42, 0.96));
  border-color: rgba(59, 130, 246, 0.7);
  color: #e5e7eb;
}

.btn-secondary:hover {
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.85);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.75);
  color: #fecaca;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.22);
  box-shadow: 0 15px 30px rgba(127, 29, 29, 0.7);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--text-muted);
  padding-inline: 0.8rem;
}

.btn-ghost:hover {
  background: rgba(15, 23, 42, 0.9);
}

/* Alerts */

.alert {
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  border-width: 1px;
  border-style: solid;
}

.alert-success {
  background: var(--accent-soft);
  border-color: rgba(34, 197, 94, 0.7);
  color: #bbf7d0;
}

.alert-error {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.85);
  color: #fee2e2;
}

/* Grid de imagens */

.panel-results {
  min-height: 300px;
}

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

.image-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.75rem;
  border-radius: 16px;
  background: radial-gradient(circle at top left, #020617, #020617 40%, #020617);
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: var(--shadow-soft);
}

.image-thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.55rem;
  background: #020617;
  border: 1px solid rgba(15, 23, 42, 0.9);
  min-height: 120px;
  max-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-thumb img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 150ms ease-out, opacity 150ms ease-out;
}

.image-card:hover .image-thumb img {
  transform: scale(1.02);
  opacity: 0.98;
}

.image-thumb-placeholder {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.image-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.image-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e5e7eb;
}

.image-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.7rem;
}

.badge {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.55);
  color: #9ca3af;
}

.image-credit {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.image-tags {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.7rem;
}

.tag {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.7);
  color: #bfdbfe;
}

.latex-label {
  margin-top: 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.latex-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.latex-input {
  flex: 1;
  font-size: 0.75rem;
}

.image-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
  align-items: center;
}

.image-actions-row form {
  margin: 0;
}

.image-actions {
}

.empty-state {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Responsividade */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 1rem;
  }

  .panel-filters {
    position: static;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .topbar-right {
    align-self: stretch;
    justify-content: space-between;
  }
}

@media (max-width: 600px) {
  .page-login {
    padding: 1.2rem;
  }

  .card {
    padding-inline: 1.25rem;
  }
}


/* Preview background toggle */
.preview-bg-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-size: 0.8rem;
}

.preview-bg-toggle label {
  color: var(--text-muted);
}

.preview-bg-toggle select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
}

/* Light / dark background for image thumbs */
body.page-midia.thumb-bg-light .image-thumb {
  background: #f9fafb;
  border-color: rgba(15, 23, 42, 0.1);
}

body.page-midia.thumb-bg-dark .image-thumb {
  background: #020617;
  border-color: rgba(15, 23, 42, 0.9);
}


/* Medium background for image thumbs */
body.page-midia.thumb-bg-medium .image-thumb {
  background: #e5e7eb; /* cinza claro */
  border-color: rgba(15, 23, 42, 0.15);
}

/* --- Questões (prévia): tabela simples --- */
.topbar-nav{margin-top:10px; display:flex; gap:8px; flex-wrap:wrap;}
.table-wrap{overflow:auto; border:1px solid rgba(255,255,255,.10); border-radius:14px;}
.table{width:100%; border-collapse:collapse; min-width:980px;}
.table th,.table td{padding:10px 12px; border-bottom:1px solid rgba(255,255,255,.10); vertical-align:top;}
.table thead th{position:sticky; top:0; background:rgba(0,0,0,.22); backdrop-filter:blur(6px); text-align:left; font-weight:700;}
.table tbody tr:hover{background:rgba(255,255,255,.03);}
