/* ============================================
   TRABAJO CIENTÍFICO — Sistema de Certificados
   Estilos CSS - Tema Oscuro & Glassmorphism
   ============================================ */

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

:root {
  --bg-deep: #0b0d17;
  --bg-surface: #131627;
  --bg-surface-2: #1a1e35;
  --bg-hover: #1f2442;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.2);
  --text-primary: #e4e4e7;
  --text-secondary: #8b8fa3;
  --text-muted: #555a70;
  --accent-cyan: #00d4ff;
  --accent-purple: #7b2ff7;
  --accent-gradient: linear-gradient(135deg, #00d4ff, #7b2ff7);
  --accent-gradient-h: linear-gradient(90deg, #00d4ff, #7b2ff7);
  --success: #22c55e;
  --error: #ef4444;
  --radius: 16px;
  --radius-sm: 12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* --- Animated Background --- */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-animation .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  animation: orbFloat 20s ease-in-out infinite;
}

.bg-animation .orb-1 {
  width: 600px;
  height: 600px;
  background: var(--accent-cyan);
  top: -10%;
  left: -10%;
}

.bg-animation .orb-2 {
  width: 500px;
  height: 500px;
  background: var(--accent-purple);
  bottom: -10%;
  right: -10%;
  animation-delay: -7s;
}

.bg-animation .orb-3 {
  width: 400px;
  height: 400px;
  background: #3b82f6;
  top: 40%;
  left: 45%;
  animation-delay: -14s;
  opacity: 0.08;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(50px, -30px) scale(1.08); }
  50% { transform: translate(-30px, 50px) scale(0.95); }
  75% { transform: translate(30px, 20px) scale(1.04); }
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

/* --- Container --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* --- Header / Navigation --- */
header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(11, 13, 23, 0.7);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.brand-badge {
  background: rgba(0, 212, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 212, 255, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

.back-link:hover {
  color: var(--accent-cyan);
}

/* --- Main Layout --- */
main {
  flex: 1;
  padding: 3rem 0;
}

.hero-section {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2.5rem;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.gradient-text {
  background: var(--accent-gradient-h);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
}

.event-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  border-radius: 30px;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.event-badge span.icon {
  font-size: 1.1rem;
}

/* --- Search Card --- */
.search-card {
  background: rgba(19, 22, 39, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 700px;
  margin: 0 auto 3rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  position: relative;
}

/* --- Selector de Evento --- */
.event-selector {
  margin-bottom: 1.25rem;
}

.event-selector label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.event-select {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 2.75rem 0.9rem 1.1rem;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2300d4ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.1rem center;
}

.event-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15);
}

.event-select option {
  background: var(--bg-surface-2);
  color: #fff;
}

.search-box {
  position: relative;
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .search-box {
    flex-direction: column;
  }
}

.input-wrapper {
  position: relative;
  flex: 1;
}

.search-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem 1rem 3rem;
  color: #fff;
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.15);
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.2rem;
  pointer-events: none;
}

/* --- Autocomplete Dropdown --- */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  display: none;
}

.autocomplete-list.active {
  display: block;
}

.autocomplete-item {
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s;
  font-size: 0.95rem;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.selected {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.95rem 1.75rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 212, 255, 0.45);
}

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* --- Status Messages --- */
.status-container {
  margin-top: 1.25rem;
}

.status-msg {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-loading {
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: var(--accent-cyan);
}

.status-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.status-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Certificate Section --- */
.certificate-section {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.certificate-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.cert-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
  margin-bottom: 2.5rem;
}

.cert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.cert-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.cert-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Canvas Wrapper */
.canvas-wrapper {
  width: 100%;
  overflow-x: auto;
  background: #000;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
}

#cert-canvas {
  width: 100%;
  max-width: 1000px;
  height: auto;
  display: block;
  border-radius: 8px;
  aspect-ratio: 1200 / 800;
}

/* --- Information Cards / FAQ --- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
}

.info-card {
  background: rgba(19, 22, 39, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.info-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: auto;
  background: rgba(11, 13, 23, 0.9);
}

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

footer a:hover {
  color: var(--accent-cyan);
}
