/* =============================================
   DiplomaNet - Painel de Gestão
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Great+Vibes&family=IM+Fell+English:ital@0;1&display=swap');

/* ---- RESET & TOKENS ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #1e2430;
  --bg-card: #21283a;
  --border: #30363d;
  --border-light: #3d4451;

  --gold: #d4a853;
  --gold-light: #f0c96e;
  --gold-dark: #a07830;
  --blue-acc: #1a6fbf;
  --blue-light: #58a6ff;

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  --success: #3fb950;
  --danger: #f85149;
  --warning: #d29922;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-w: 250px;
  --topbar-h: 64px;

  --transition: 0.2s ease;
}

html,
body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
}

/* =============================================
   LOGIN SCREEN
   ============================================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, #1a2a4a 0%, #0d1117 70%);
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4a853' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: min(420px, 92vw);
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(212, 168, 83, 0.08);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 3rem;
  line-height: 1;
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-top: 0.5rem;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.login-error {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.login-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* =============================================
   FORMS
   ============================================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.15);
}

.form-group input[type="file"] {
  padding: 0.5rem;
  cursor: pointer;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #1a1208;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(212, 168, 83, 0.3);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-gerar {
  font-size: 1rem;
  padding: 0.8rem 1.6rem;
}

/* =============================================
   APP LAYOUT
   ============================================= */
.app {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.logo-icon-sm {
  font-size: 1.4rem;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--transition);
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(212, 168, 83, 0.12);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 83, 0.2);
}

.nav-icon {
  font-size: 1.1rem;
}

.btn-logout {
  margin: 0.75rem;
  padding: 0.65rem 0.9rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition);
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(248, 81, 73, 0.07);
}

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
}

.topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #1a1208;
}

.page-content {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1200px;
}

/* =============================================
   PAGES
   ============================================= */
.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--transition);
}

.stat-card:hover {
  border-color: var(--gold);
}

.stat-icon {
  font-size: 2rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* RECENT LIST */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.recent-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
}

.recent-item .ri-name {
  font-weight: 600;
}

.recent-item .ri-meta {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.recent-item .ri-date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* FACULDADES GRID */
.faculdades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.faculdades-grid-sm {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.faculdade-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  transition: all var(--transition);
}

.faculdade-card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.faculdade-card-sm {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  font-size: 0.8rem;
}

.fc-color-bar {
  height: 4px;
  border-radius: 2px;
  margin-bottom: 1rem;
}

.fc-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-sm);
}

.fc-logo-placeholder {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.fc-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.fc-city {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.fc-reitor {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.fc-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.fc-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.fc-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.fc-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* GERAR DIPLOMA */
.gerar-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.gerar-form-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.form-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* PREVIEW */
.gerar-preview-col {
  position: sticky;
  top: calc(var(--topbar-h) + 1rem);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.preview-hint {
  font-size: 0.75rem;
  background: var(--bg-elevated);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
}

.preview-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 297 / 210;
  display: flex;
  align-items: center;
  justify-content: center;
}

#preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  transform-origin: top left;
}

/* HISTORICO TABLE */
.historico-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.historico-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.historico-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.historico-table tr:hover td {
  background: var(--bg-elevated);
}

.empty-td {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem !important;
}

#historico-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(700px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* LOGO PREVIEW */
.logo-preview-box {
  margin-top: 0.75rem;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.logo-preview-box img {
  max-height: 80px;
  max-width: 200px;
  object-fit: contain;
}

/* CONFIG */
.cfg-msg {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.cfg-msg.success {
  background: rgba(63, 185, 80, 0.12);
  color: var(--success);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.cfg-msg.error {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem 1.4rem;
  font-size: 0.9rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 999;
  transition: all 0.3s ease;
  max-width: 360px;
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* EMPTY */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* USER BADGES */
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-badge.admin {
  background: rgba(212, 168, 83, 0.15);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 83, 0.3);
}

.user-badge.user {
  background: rgba(88, 166, 255, 0.1);
  color: var(--blue-light);
  border: 1px solid rgba(88, 166, 255, 0.25);
}

/* TOPBAR BADGE */
.topbar-badge {
  margin-right: auto;
}

/* STATUS DOT */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.status-dot.ativo {
  background: var(--success);
  box-shadow: 0 0 6px rgba(63, 185, 80, 0.5);
}

.status-dot.inativo {
  background: var(--danger);
}

/* TOAST WARNING */
.toast.warning {
  border-color: var(--warning);
  color: var(--warning);
}

/* UTILITIES */
.hidden {
  display: none !important;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.5);
  }

  .sidebar-close {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .gerar-layout {
    grid-template-columns: 1fr;
  }

  .gerar-preview-col {
    position: static;
  }

  .form-row.two-col {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .page-content {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .faculdades-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn-full-mobile {
    width: 100%;
    justify-content: center;
  }
}