/* ============================================================
   CUBIX Design System
   CUBO Sistemas y Tecnología — Paraguay
   ============================================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Custom Properties --- */
:root {
  /* Brand */
  --cx-primary: #6C3AE1;
  --cx-primary-light: #8B5CF6;
  --cx-primary-lighter: #A78BFA;
  --cx-primary-lightest: #EDE9FE;
  --cx-primary-dark: #5B21B6;
  --cx-primary-darker: #4C1D95;

  /* Accent */
  --cx-accent: #06B6D4;
  --cx-accent-light: #22D3EE;
  --cx-accent-dark: #0891B2;

  /* Semantic */
  --cx-success: #10B981;
  --cx-success-light: #D1FAE5;
  --cx-warning: #F59E0B;
  --cx-warning-light: #FEF3C7;
  --cx-danger: #EF4444;
  --cx-danger-light: #FEE2E2;
  --cx-info: #3B82F6;
  --cx-info-light: #DBEAFE;

  /* Neutrals */
  --cx-gray-50: #FAFAFA;
  --cx-gray-100: #F4F4F5;
  --cx-gray-200: #E4E4E7;
  --cx-gray-300: #D4D4D8;
  --cx-gray-400: #A1A1AA;
  --cx-gray-500: #71717A;
  --cx-gray-600: #52525B;
  --cx-gray-700: #3F3F46;
  --cx-gray-800: #27272A;
  --cx-gray-900: #18181B;
  --cx-gray-950: #09090B;

  /* Surfaces */
  --cx-bg: #FAFBFF;
  --cx-bg-alt: #F0EDFF;
  --cx-surface: #FFFFFF;
  --cx-surface-raised: #FFFFFF;
  --cx-text: #1A1A2E;
  --cx-text-secondary: #52525B;
  --cx-text-muted: #A1A1AA;
  --cx-border: #E4E4E7;
  --cx-border-light: #F4F4F5;

  /* Typography */
  --cx-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --cx-font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Scale */
  --cx-text-xs: 0.75rem;
  --cx-text-sm: 0.875rem;
  --cx-text-base: 1rem;
  --cx-text-lg: 1.125rem;
  --cx-text-xl: 1.25rem;
  --cx-text-2xl: 1.5rem;
  --cx-text-3xl: 1.875rem;
  --cx-text-4xl: 2.25rem;
  --cx-text-5xl: 3rem;
  --cx-text-6xl: 3.75rem;

  /* Spacing */
  --cx-space-1: 0.25rem;
  --cx-space-2: 0.5rem;
  --cx-space-3: 0.75rem;
  --cx-space-4: 1rem;
  --cx-space-5: 1.25rem;
  --cx-space-6: 1.5rem;
  --cx-space-8: 2rem;
  --cx-space-10: 2.5rem;
  --cx-space-12: 3rem;
  --cx-space-16: 4rem;
  --cx-space-20: 5rem;
  --cx-space-24: 6rem;

  /* Radius */
  --cx-radius-sm: 6px;
  --cx-radius: 10px;
  --cx-radius-lg: 14px;
  --cx-radius-xl: 20px;
  --cx-radius-2xl: 28px;
  --cx-radius-full: 9999px;

  /* Shadow */
  --cx-shadow-sm: 0 1px 3px rgba(108,58,225,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --cx-shadow: 0 4px 16px rgba(108,58,225,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --cx-shadow-lg: 0 12px 40px rgba(108,58,225,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --cx-shadow-xl: 0 20px 60px rgba(108,58,225,0.15), 0 8px 20px rgba(0,0,0,0.08);

  /* Transitions */
  --cx-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --cx-transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --cx-container: 1200px;
  --cx-nav-height: 72px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--cx-font);
  font-size: var(--cx-text-base);
  line-height: 1.6;
  color: var(--cx-text);
  background: var(--cx-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--cx-primary); text-decoration: none; transition: color var(--cx-transition); }
a:hover { color: var(--cx-primary-dark); }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* --- Container --- */
.container {
  width: 100%;
  max-width: var(--cx-container);
  margin: 0 auto;
  padding-inline: var(--cx-space-6);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.2; color: var(--cx-text); }
h1 { font-size: var(--cx-text-4xl); letter-spacing: -0.02em; }
h2 { font-size: var(--cx-text-3xl); letter-spacing: -0.01em; }
h3 { font-size: var(--cx-text-2xl); }
h4 { font-size: var(--cx-text-xl); }
h5 { font-size: var(--cx-text-lg); }
h6 { font-size: var(--cx-text-base); font-weight: 600; }

.text-gradient {
  background: linear-gradient(135deg, var(--cx-primary), var(--cx-primary-light), var(--cx-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cx-space-2);
  padding: 0.7em 1.5em;
  font-weight: 600;
  font-size: var(--cx-text-sm);
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--cx-radius);
  cursor: pointer;
  transition: all var(--cx-transition);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity var(--cx-transition);
}

.btn:hover::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, var(--cx-primary), var(--cx-primary-light));
  color: white;
  box-shadow: 0 4px 15px rgba(108,58,225,0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(108,58,225,0.4);
  color: white;
}

.btn-secondary {
  background: var(--cx-surface);
  color: var(--cx-primary);
  border-color: var(--cx-primary-lighter);
}
.btn-secondary:hover {
  background: var(--cx-primary-lightest);
  border-color: var(--cx-primary);
  color: var(--cx-primary);
}

.btn-accent {
  background: linear-gradient(135deg, var(--cx-accent), var(--cx-accent-light));
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--cx-text-secondary);
}
.btn-ghost:hover { background: var(--cx-gray-100); color: var(--cx-text); }

.btn-danger {
  background: var(--cx-danger);
  color: white;
}
.btn-danger:hover { background: #DC2626; }

.btn-lg { padding: 0.9em 2em; font-size: var(--cx-text-base); border-radius: var(--cx-radius-lg); }
.btn-sm { padding: 0.5em 1em; font-size: var(--cx-text-xs); }
.btn-icon { padding: 0.6em; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* --- Cards --- */
.card {
  background: var(--cx-surface);
  border: 1px solid var(--cx-border-light);
  border-radius: var(--cx-radius-lg);
  padding: var(--cx-space-6);
  box-shadow: var(--cx-shadow-sm);
  transition: all var(--cx-transition);
}

.card-interactive:hover {
  box-shadow: var(--cx-shadow);
  transform: translateY(-2px);
  border-color: var(--cx-primary-lighter);
}

.card-featured {
  border: 2px solid var(--cx-primary-lighter);
  background: linear-gradient(135deg, var(--cx-surface), var(--cx-primary-lightest));
}

/* --- Forms --- */
.form-group { margin-bottom: var(--cx-space-5); }

.form-label {
  display: block;
  font-size: var(--cx-text-sm);
  font-weight: 600;
  color: var(--cx-text);
  margin-bottom: var(--cx-space-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.7em 1em;
  font-size: var(--cx-text-base);
  color: var(--cx-text);
  background: var(--cx-surface);
  border: 2px solid var(--cx-border);
  border-radius: var(--cx-radius);
  transition: all var(--cx-transition);
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--cx-primary);
  box-shadow: 0 0 0 3px rgba(108,58,225,0.15);
}

.form-input::placeholder { color: var(--cx-text-muted); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-error { font-size: var(--cx-text-sm); color: var(--cx-danger); margin-top: var(--cx-space-1); }
.form-hint { font-size: var(--cx-text-sm); color: var(--cx-text-muted); margin-top: var(--cx-space-1); }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.7em;
  font-size: var(--cx-text-xs);
  font-weight: 600;
  border-radius: var(--cx-radius-full);
  letter-spacing: 0.02em;
}

.badge-primary { background: var(--cx-primary-lightest); color: var(--cx-primary-dark); }
.badge-success { background: var(--cx-success-light); color: #065F46; }
.badge-warning { background: var(--cx-warning-light); color: #92400E; }
.badge-danger { background: var(--cx-danger-light); color: #991B1B; }
.badge-info { background: var(--cx-info-light); color: #1E40AF; }
.badge-gray { background: var(--cx-gray-100); color: var(--cx-gray-600); }

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--cx-nav-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(228,228,231,0.6);
  z-index: 1000;
  transition: all var(--cx-transition);
}

.nav.scrolled {
  box-shadow: var(--cx-shadow-sm);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--cx-container);
  margin: 0 auto;
  padding-inline: var(--cx-space-6);
}

.nav-logo img { height: 36px; width: auto; }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--cx-space-1);
  list-style: none;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: var(--cx-space-2);
  padding: 0.5em 0.9em;
  font-size: var(--cx-text-sm);
  font-weight: 500;
  color: var(--cx-text-secondary);
  border-radius: var(--cx-radius);
  transition: all var(--cx-transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--cx-primary);
  background: var(--cx-primary-lightest);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  border: none;
  background: none;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--cx-text);
  border-radius: 2px;
  transition: all var(--cx-transition);
}

/* --- Section --- */
.section {
  padding: var(--cx-space-20) 0;
}

.section-header {
  text-align: center;
  margin-bottom: var(--cx-space-12);
}

.section-header h2 { margin-bottom: var(--cx-space-4); }

.section-header p {
  font-size: var(--cx-text-lg);
  color: var(--cx-text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* --- Grid --- */
.grid { display: grid; gap: var(--cx-space-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* --- Progress --- */
.progress {
  width: 100%;
  height: 8px;
  background: var(--cx-gray-200);
  border-radius: var(--cx-radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--cx-primary), var(--cx-primary-light));
  border-radius: var(--cx-radius-full);
  transition: width var(--cx-transition-slow);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--cx-space-6);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--cx-surface);
  border-radius: var(--cx-radius-xl);
  padding: var(--cx-space-8);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--cx-shadow-xl);
  animation: modalIn 300ms ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: calc(var(--cx-nav-height) + var(--cx-space-4));
  right: var(--cx-space-4);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--cx-space-3);
}

.toast {
  padding: var(--cx-space-4) var(--cx-space-5);
  border-radius: var(--cx-radius);
  font-size: var(--cx-text-sm);
  font-weight: 500;
  box-shadow: var(--cx-shadow-lg);
  animation: toastIn 300ms ease-out;
  max-width: 380px;
}

.toast-success { background: var(--cx-success); color: white; }
.toast-error { background: var(--cx-danger); color: white; }
.toast-info { background: var(--cx-info); color: white; }
.toast-warning { background: var(--cx-warning); color: white; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* --- Loading --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--cx-primary-lightest);
  border-top-color: var(--cx-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

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

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* --- Footer --- */
.footer {
  background: var(--cx-gray-950);
  color: var(--cx-gray-400);
  padding: var(--cx-space-16) 0 var(--cx-space-8);
}

.footer a { color: var(--cx-gray-300); }
.footer a:hover { color: white; }

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--cx-space-10);
  margin-bottom: var(--cx-space-10);
}

.footer-brand p { margin-top: var(--cx-space-4); line-height: 1.7; font-size: var(--cx-text-sm); }

.footer-col h4 {
  color: white;
  font-size: var(--cx-text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--cx-space-4);
}

.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: var(--cx-space-2); }
.footer-col a { font-size: var(--cx-text-sm); }

.footer-bottom {
  padding-top: var(--cx-space-8);
  border-top: 1px solid var(--cx-gray-800);
  text-align: center;
  font-size: var(--cx-text-sm);
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-sm { font-size: var(--cx-text-sm); }
.text-lg { font-size: var(--cx-text-lg); }
.text-muted { color: var(--cx-text-muted); }
.text-primary { color: var(--cx-primary); }
.text-success { color: var(--cx-success); }
.text-danger { color: var(--cx-danger); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: var(--cx-space-1); }
.mt-2 { margin-top: var(--cx-space-2); }
.mt-4 { margin-top: var(--cx-space-4); }
.mt-6 { margin-top: var(--cx-space-6); }
.mt-8 { margin-top: var(--cx-space-8); }
.mb-2 { margin-bottom: var(--cx-space-2); }
.mb-4 { margin-bottom: var(--cx-space-4); }
.mb-6 { margin-bottom: var(--cx-space-6); }
.mb-8 { margin-bottom: var(--cx-space-8); }
.p-4 { padding: var(--cx-space-4); }
.p-6 { padding: var(--cx-space-6); }
.p-8 { padding: var(--cx-space-8); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--cx-space-2); }
.gap-4 { gap: var(--cx-space-4); }
.gap-6 { gap: var(--cx-space-6); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --cx-nav-height: 64px; }

  h1 { font-size: var(--cx-text-3xl); }
  h2 { font-size: var(--cx-text-2xl); }
  h3 { font-size: var(--cx-text-xl); }

  .container { padding-inline: var(--cx-space-4); }
  .section { padding: var(--cx-space-12) 0; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }

  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed;
    top: var(--cx-nav-height);
    left: 0;
    right: 0;
    background: var(--cx-surface);
    flex-direction: column;
    padding: var(--cx-space-4);
    box-shadow: var(--cx-shadow-lg);
    transform: translateY(-110%);
    transition: transform var(--cx-transition);
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links a { width: 100%; padding: var(--cx-space-3) var(--cx-space-4); }

  .footer-grid { grid-template-columns: 1fr; gap: var(--cx-space-6); }

  .modal { padding: var(--cx-space-6); }
}

@media (max-width: 480px) {
  h1 { font-size: var(--cx-text-2xl); }
  .btn-lg { padding: 0.8em 1.5em; font-size: var(--cx-text-sm); }
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fadeInUp { animation: fadeInUp 600ms ease-out both; }
.animate-fadeIn { animation: fadeIn 400ms ease-out both; }
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* --- Tables --- */
.table-container { overflow-x: auto; border-radius: var(--cx-radius-lg); border: 1px solid var(--cx-border-light); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--cx-text-sm);
}

.table th {
  padding: var(--cx-space-3) var(--cx-space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--cx-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cx-text-secondary);
  background: var(--cx-gray-50);
  border-bottom: 2px solid var(--cx-border);
}

.table td {
  padding: var(--cx-space-3) var(--cx-space-4);
  border-bottom: 1px solid var(--cx-border-light);
  vertical-align: middle;
}

.table tr:hover td { background: var(--cx-gray-50); }

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--cx-space-1);
  margin-top: var(--cx-space-8);
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--cx-space-2);
  font-size: var(--cx-text-sm);
  font-weight: 500;
  border-radius: var(--cx-radius);
  transition: all var(--cx-transition);
}

.pagination a:hover { background: var(--cx-primary-lightest); color: var(--cx-primary); }
.pagination .active { background: var(--cx-primary); color: white; }
