/* REDGAR UI — Certificados */

:root {
  --rg-primary: #2563EB;
  --rg-primary-hover: #1D4ED8;
  --rg-background: #FFFFFF;
  --rg-surface: #F8FAFC;
  --rg-text: #0F172A;
  --rg-text-secondary: #64748B;
  --rg-success: #16A34A;
  --rg-success-bg: #DCFCE7;
  --rg-warning: #F59E0B;
  --rg-warning-bg: #FEF3C7;
  --rg-danger: #DC2626;
  --rg-danger-bg: #FEE2E2;
  --rg-border: #E2E8F0;
  --rg-accent: #06B6D4;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 4px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 4px 16px rgba(15, 23, 42, 0.1);
  --transition: 150ms ease;
  --sidebar-width: 260px;
  --navbar-height: 56px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --max-width: 1280px;

  /* aliases legacy */
  --rl-primary: var(--rg-text);
  --rl-secondary: var(--rg-primary);
  --rl-secondary-hover: var(--rg-primary-hover);
  --rl-bg: var(--rg-background);
  --rl-bg-muted: var(--rg-surface);
  --rl-border: var(--rg-border);
  --rl-muted: var(--rg-text-secondary);
  --rl-success: var(--rg-success);
  --rl-success-bg: var(--rg-success-bg);
  --rl-error: var(--rg-danger);
  --rl-error-bg: var(--rg-danger-bg);
  --rl-warning: var(--rg-warning);
  --rl-warning-bg: var(--rg-warning-bg);
  --navy: var(--rg-text);
  --gold: var(--rg-primary);
  --bg: var(--rg-surface);
  --surface: var(--rg-background);
  --surface2: var(--rg-surface);
  --border: var(--rg-border);
  --muted: var(--rg-text-secondary);
  --green: var(--rg-success);
  --green-bg: var(--rg-success-bg);
  --red: var(--rg-danger);
  --red-bg: var(--rg-danger-bg);
  --yellow: var(--rg-warning);
  --yellow-bg: var(--rg-warning-bg);
  --radius: var(--radius-md);
  --radius-sm: var(--radius-sm);
  --radius-card: var(--radius-lg);
  --shadow: var(--shadow-md);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--rg-text);
  background: var(--rg-surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--rg-primary);
  outline-offset: 2px;
}

/* —— App shell —— */
.rg-app {
  display: flex;
  min-height: 100vh;
}

.rg-sidebar {
  width: var(--sidebar-width);
  background: var(--rg-text);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 120;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.rg-sidebar-head {
  padding: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.rg-sidebar-brand {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  width: fit-content;
  text-decoration: none;
}

.rg-sidebar-brand img {
  height: 67px;
  width: auto;
  object-fit: contain;
  display: block;
}

.rg-sidebar-app {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rg-accent);
}

.rg-sidebar-course {
  padding: var(--space-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.rg-sidebar-course label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.rg-sidebar-course select {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
}

.rg-sidebar-course select option {
  color: var(--rg-text);
  background: #fff;
}

.rg-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rg-sidebar-user {
  padding: var(--space-2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rg-sidebar-user #userLabel {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  padding: 4px 12px 8px;
  line-height: 1.4;
}

/* Nav items (tabs) */
.tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.tab svg, .tab i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.tab.active {
  background: var(--rg-primary);
  color: #fff;
}

.rg-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rg-topbar {
  display: none;
  align-items: center;
  gap: var(--space-2);
  height: var(--navbar-height);
  padding: 0 var(--space-2);
  background: var(--rg-text);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 110;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rg-menu-btn {
  background: transparent;
  border: none;
  color: #fff;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
}

.rg-menu-btn:hover { background: rgba(255, 255, 255, 0.1); }

.rg-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 115;
}

.rg-overlay.show { display: block; }

main {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

/* —— Buttons (REDGAR UI) —— */
button.btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 40px;
  padding: 8px var(--space-2);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

button.btn, .btn-primary { background: var(--rg-primary); color: #fff; }
button.btn:hover, .btn-primary:hover { background: var(--rg-primary-hover); }

.btn-secondary {
  background: var(--rg-surface);
  color: var(--rg-text);
  border: 1px solid var(--rg-border);
}
.btn-secondary:hover { background: var(--rg-border); }

button.btn.secondary, .btn-outline {
  background: transparent;
  color: var(--rg-text);
  border: 1px solid var(--rg-border);
}
button.btn.secondary:hover, .btn-outline:hover {
  background: var(--rg-surface);
  border-color: var(--rg-primary);
  color: var(--rg-primary);
}

.btn-ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  border: none;
  height: 36px;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.btn-danger, button.btn.danger { background: var(--rg-danger); color: #fff; }
.btn-danger:hover, button.btn.danger:hover { background: #B91C1C; }

.btn-success { background: var(--rg-success); color: #fff; }
.btn-success:hover { background: #15803D; }

.btn-block { width: 100%; }

/* —— Panels / Cards —— */
.panel {
  display: none;
  background: var(--rg-background);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  border: 1px solid var(--rg-border);
  box-shadow: var(--shadow-sm);
}

.panel.active { display: block; }

.panel > h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--rg-text);
  margin-bottom: var(--space-1);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  align-items: center;
}

/* —— Forms —— */
input, select, textarea {
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 14px;
  background: var(--rg-background);
  font-family: inherit;
  color: var(--rg-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input::placeholder, textarea::placeholder { color: var(--rg-text-secondary); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--rg-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea { width: 100%; min-height: 80px; resize: vertical; }

.form-row { margin-bottom: var(--space-2); }

.form-row label, .rg-label {
  display: block;
  font-size: 14px;
  color: var(--rg-text);
  margin-bottom: 6px;
  font-weight: 500;
}

.hint { font-size: 12px; color: var(--rg-text-secondary); margin-top: 4px; }

/* —— Tables —— */
table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td {
  padding: 12px var(--space-1);
  border-bottom: 1px solid var(--rg-border);
  text-align: left;
}

th {
  background: var(--rg-surface);
  font-weight: 600;
  color: var(--rg-text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:hover td { background: var(--rg-surface); }
.null { color: var(--rg-text-secondary); }
tr.row-active td { background: #EFF6FF; }
tr.row-active td:first-child { border-left: 3px solid var(--rg-primary); }

/* —— Badges —— */
.badge {
  display: inline-block;
  padding: 2px var(--space-1);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
}
.badge.ok { background: var(--rg-success-bg); color: var(--rg-success); }
.badge.pending { background: var(--rg-warning-bg); color: var(--rg-warning); }
.badge.info { background: rgba(37, 99, 235, 0.1); color: var(--rg-primary); }
.badge.danger { background: var(--rg-danger-bg); color: var(--rg-danger); }

/* —— Accordion —— */
.accordion {
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-1);
  overflow: hidden;
  background: var(--rg-background);
}
.accordion summary {
  padding: var(--space-2);
  cursor: pointer;
  font-weight: 600;
  background: var(--rg-surface);
  transition: background var(--transition);
}
.accordion summary:hover { background: #F1F5F9; }
.accordion .body { padding: var(--space-2); }

.section-card {
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  margin-bottom: var(--space-1);
  background: var(--rg-surface);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }

/* —— Modal —— */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: rgFadeIn var(--transition);
}
.modal.show { display: flex; }
.modal-box {
  background: var(--rg-background);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  width: min(520px, 92vw);
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--rg-border);
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { font-size: 18px; font-weight: 600; margin-bottom: var(--space-2); }

/* —— Misc —— */
.sticky-bar {
  position: sticky;
  bottom: 0;
  background: var(--rg-text);
  color: #fff;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  margin-top: var(--space-2);
  display: none;
  gap: var(--space-1);
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}
.sticky-bar.show { display: flex; }
.sticky-bar .btn.secondary {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.sticky-bar .btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #fff;
  color: #fff;
}

.log {
  background: var(--rg-surface);
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-size: 12px;
  max-height: 160px;
  overflow: auto;
  margin-top: var(--space-2);
}

.empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--rg-text-secondary);
}

.pdf-preview {
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-md);
  min-height: 400px;
  margin-top: var(--space-2);
}

.preview-info {
  background: var(--rg-surface);
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  margin-bottom: var(--space-2);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.preview-info img { height: 52px; max-width: 120px; object-fit: contain; }

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-2);
}
.asset-card {
  border: 1px dashed var(--rg-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  text-align: center;
  background: var(--rg-surface);
}
.asset-card img {
  max-width: 100%;
  max-height: 72px;
  object-fit: contain;
  margin: var(--space-1) auto;
  display: block;
}

.color-row { display: flex; align-items: center; gap: var(--space-1); }
.color-row input[type=color] {
  width: 42px;
  height: 32px;
  padding: 2px;
  border-radius: var(--radius-sm);
}

/* —— Footer —— */
.app-footer {
  background: var(--rg-text);
  color: #fff;
  padding: var(--space-3);
  margin-top: auto;
}
.app-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.app-footer-logo {
  display: inline-flex;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  text-decoration: none;
}
.app-footer-logo img { height: 28px; width: auto; }
.app-footer-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
}
.app-footer a, .app-footer a:visited {
  color: rgba(255, 255, 255, 0.85);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.app-footer a:hover { color: #fff; }
.app-footer svg, .footer-icon { width: 16px; height: 16px; stroke: currentColor; }
.app-footer-copy {
  width: 100%;
  text-align: center;
  padding-top: var(--space-2);
  margin-top: var(--space-1);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

/* —— Login —— */
body.login-page {
  background: var(--rg-surface);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-brand { text-align: center; margin-bottom: var(--space-4); }
.login-brand img { width: min(280px, 80vw); height: auto; }
.login-card {
  background: var(--rg-background);
  border: 1px solid var(--rg-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-3);
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 20px; font-weight: 600; margin-bottom: var(--space-1); }
.login-card .subtitle { color: var(--rg-text-secondary); font-size: 14px; margin-bottom: var(--space-3); }
.login-card label { font-size: 14px; font-weight: 500; margin-bottom: 6px; display: block; }
.login-card input { width: 100%; margin-bottom: var(--space-2); }
.login-card button[type=submit] {
  width: 100%;
  height: 44px;
  background: var(--rg-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--space-1);
  transition: background var(--transition);
}
.login-card button[type=submit]:hover { background: var(--rg-primary-hover); }
.login-err { color: var(--rg-danger); font-size: 14px; margin-top: var(--space-1); min-height: 1.2em; }
.login-footer-note { margin-top: var(--space-3); text-align: center; font-size: 12px; color: var(--rg-text-secondary); }

@keyframes rgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* —— Responsive —— */
@media (max-width: 1024px) {
  .rg-sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  .rg-sidebar.open { transform: translateX(0); }
  .rg-main { margin-left: 0; }
  .rg-topbar { display: flex; }
}

@media (max-width: 800px) {
  .grid2 { grid-template-columns: 1fr; }
  main { padding: var(--space-2); }
}
