/**
 * Servify Design System
 * Generado con UI/UX Pro Max — Marketplace / Directory + Trust & Authority
 * Tipografía: Poppins (headings) + Open Sans (body)
 * Patrón: Mobile-first, WCAG AA, touch targets 44px mínimo
 */

/* ============================================================
   1. GOOGLE FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700;800&display=swap');

/* ============================================================
   2. TOKENS — Marca Servify (dark navy + gold)
   ============================================================ */
:root {
  /* Brand primarios */
  --srv-primary:        #ffc107;   /* gold — CTAs, badges, highlights */
  --srv-primary-dark:   #e0a800;   /* gold oscuro — hover */
  --srv-primary-light:  #fff3cd;   /* gold claro — fondos suaves */
  --srv-bg-dark:        #0d0d12;   /* fondo hero / header */
  --srv-bg-card:        #1a1a2e;   /* cards oscuras */
  --srv-bg-section:     #252540;   /* secciones oscuras secundarias */

  /* Semánticos */
  --srv-success:        #16a34a;   /* verde confirmación */
  --srv-danger:         #dc2626;   /* rojo error/eliminar */
  --srv-warning:        #f59e0b;   /* naranja advertencia */
  --srv-info:           #3b82f6;   /* azul info */

  /* Texto */
  --srv-text-primary:   #111111;
  --srv-text-secondary: #555555;
  --srv-text-muted:     #888888;
  --srv-text-on-dark:   #ffffff;
  --srv-text-on-gold:   #111111;

  /* Superficies (light mode) */
  --srv-surface:        #ffffff;
  --srv-surface-2:      #f8f9fa;
  --srv-surface-3:      #f0f2f5;
  --srv-border:         #e5e7eb;
  --srv-border-focus:   #ffc107;

  /* Spacing scale */
  --srv-space-xs:   4px;
  --srv-space-sm:   8px;
  --srv-space-md:   16px;
  --srv-space-lg:   24px;
  --srv-space-xl:   32px;
  --srv-space-2xl:  48px;
  --srv-space-3xl:  64px;

  /* Border radius */
  --srv-radius-sm:  6px;
  --srv-radius-md:  10px;
  --srv-radius-lg:  14px;
  --srv-radius-xl:  20px;
  --srv-radius-full: 9999px;

  /* Sombras */
  --srv-shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --srv-shadow-md:  0 4px 12px rgba(0,0,0,0.10);
  --srv-shadow-lg:  0 10px 24px rgba(0,0,0,0.12);
  --srv-shadow-xl:  0 20px 40px rgba(0,0,0,0.16);
  --srv-shadow-gold: 0 4px 18px rgba(255,193,7,0.30);

  /* Tipografía */
  --srv-font-heading: 'Poppins', system-ui, sans-serif;
  --srv-font-body:    'Open Sans', system-ui, sans-serif;
  --srv-font-mono:    'JetBrains Mono', monospace;

  /* Tamaños de fuente (fluid) */
  --srv-text-xs:   0.75rem;   /* 12px */
  --srv-text-sm:   0.875rem;  /* 14px */
  --srv-text-base: 1rem;      /* 16px */
  --srv-text-lg:   1.125rem;  /* 18px */
  --srv-text-xl:   1.25rem;   /* 20px */
  --srv-text-2xl:  1.5rem;    /* 24px */
  --srv-text-3xl:  1.875rem;  /* 30px */
  --srv-text-4xl:  2.25rem;   /* 36px */

  /* Transiciones */
  --srv-ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --srv-duration-xs: 100ms;
  --srv-duration-sm: 150ms;
  --srv-duration-md: 200ms;
  --srv-duration-lg: 300ms;

  /* Touch */
  --srv-touch-min:  44px;  /* mínimo táctil WCAG */
}

/* ============================================================
   3. RESET ACCESIBLE + MEJORAS MOBILE
   ============================================================ */

/* Elimina tap delay en móvil */
* {
  -webkit-tap-highlight-color: transparent;
}

/* touch-action: manipulation elimina 300ms delay */
button,
a,
input,
select,
textarea,
[role="button"],
[tabindex] {
  touch-action: manipulation;
}

/* Tipografía base con Open Sans */
body {
  font-family: var(--srv-font-body);
  font-size: var(--srv-text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings con Poppins */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--srv-font-heading);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* Tamaños fluid para headings */
h1 { font-size: clamp(1.6rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3.5vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
h4 { font-size: clamp(1rem, 2vw, 1.25rem); }

/* ============================================================
   4. FOCUS VISIBLE (accesibilidad teclado)
   ============================================================ */
:focus-visible {
  outline: 3px solid var(--srv-primary);
  outline-offset: 3px;
  border-radius: var(--srv-radius-sm);
}

/* Quitar outline default solo cuando hay :focus-visible */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   5. TOUCH TARGETS MÍNIMOS (44×44px WCAG)
   ============================================================ */
.srv-btn,
.btn,
button:not([hidden]),
[type="button"],
[type="submit"],
[type="reset"] {
  min-height: var(--srv-touch-min);
  min-width: var(--srv-touch-min);
  cursor: pointer;
}

/* Links de navegación táctiles */
nav a,
.mobile-nav-item,
.header-nav-link {
  min-height: var(--srv-touch-min);
  display: inline-flex;
  align-items: center;
}

/* ============================================================
   6. COMPONENTES BASE — Botones
   ============================================================ */
.srv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--srv-space-sm);
  padding: 12px 24px;
  border-radius: var(--srv-radius-md);
  font-family: var(--srv-font-heading);
  font-size: var(--srv-text-base);
  font-weight: 600;
  text-decoration: none;
  border: none;
  transition: all var(--srv-duration-md) var(--srv-ease);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.srv-btn-primary {
  background: var(--srv-primary);
  color: var(--srv-text-on-gold);
  box-shadow: var(--srv-shadow-gold);
}
.srv-btn-primary:hover {
  background: var(--srv-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(255,193,7,0.40);
}
.srv-btn-primary:active { transform: translateY(0); }

.srv-btn-dark {
  background: linear-gradient(135deg, #0d0d12, #1a1a2e);
  color: var(--srv-primary);
  border: 1px solid rgba(255,193,7,0.35);
}
.srv-btn-dark:hover {
  border-color: rgba(255,193,7,0.6);
  color: #ffcd38;
  transform: translateY(-1px);
  box-shadow: var(--srv-shadow-md);
}

.srv-btn-ghost {
  background: transparent;
  color: var(--srv-text-secondary);
  border: 1.5px solid var(--srv-border);
}
.srv-btn-ghost:hover {
  border-color: var(--srv-primary);
  color: var(--srv-primary-dark);
}

.srv-btn-danger {
  background: var(--srv-danger);
  color: #fff;
}
.srv-btn-danger:hover { filter: brightness(1.1); }

.srv-btn-sm {
  padding: 8px 16px;
  font-size: var(--srv-text-sm);
  min-height: var(--srv-touch-min);
}
.srv-btn-lg {
  padding: 16px 32px;
  font-size: var(--srv-text-lg);
}
.srv-btn-full { width: 100%; }

/* Loading state */
.srv-btn[data-loading="true"] {
  opacity: 0.7;
  pointer-events: none;
  cursor: not-allowed;
}

/* ============================================================
   7. COMPONENTES BASE — Cards
   ============================================================ */
.srv-card {
  background: var(--srv-surface);
  border-radius: var(--srv-radius-lg);
  border: 1px solid var(--srv-border);
  box-shadow: var(--srv-shadow-sm);
  transition: box-shadow var(--srv-duration-md) var(--srv-ease),
              transform var(--srv-duration-md) var(--srv-ease);
  overflow: hidden;
}
.srv-card:hover {
  box-shadow: var(--srv-shadow-md);
  transform: translateY(-2px);
}
.srv-card-body { padding: var(--srv-space-lg); }

.srv-card-dark {
  background: var(--srv-bg-card);
  border-color: rgba(255,193,7,0.12);
  color: var(--srv-text-on-dark);
}

/* ============================================================
   8. COMPONENTES BASE — Formularios
   ============================================================ */
.srv-label {
  display: block;
  font-family: var(--srv-font-heading);
  font-size: var(--srv-text-sm);
  font-weight: 600;
  color: var(--srv-text-secondary);
  margin-bottom: var(--srv-space-xs);
}

.srv-input,
.srv-select,
.srv-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--srv-border);
  border-radius: var(--srv-radius-md);
  font-family: var(--srv-font-body);
  font-size: var(--srv-text-base); /* mínimo 16px — evita zoom en iOS */
  color: var(--srv-text-primary);
  background: var(--srv-surface);
  transition: border-color var(--srv-duration-sm) var(--srv-ease),
              box-shadow var(--srv-duration-sm) var(--srv-ease);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.srv-input:focus,
.srv-select:focus,
.srv-textarea:focus {
  border-color: var(--srv-border-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,193,7,0.20);
}

.srv-input::placeholder { color: var(--srv-text-muted); }

.srv-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--srv-space-xs);
  margin-bottom: var(--srv-space-md);
}

.srv-form-error {
  font-size: var(--srv-text-sm);
  color: var(--srv-danger);
  display: flex;
  align-items: center;
  gap: var(--srv-space-xs);
  margin-top: var(--srv-space-xs);
}

.srv-form-helper {
  font-size: var(--srv-text-sm);
  color: var(--srv-text-muted);
  margin-top: var(--srv-space-xs);
}

/* ============================================================
   9. BADGES / PILLS
   ============================================================ */
.srv-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--srv-radius-full);
  font-size: var(--srv-text-xs);
  font-weight: 700;
  font-family: var(--srv-font-heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.srv-badge-gold    { background: var(--srv-primary-light); color: #92710a; }
.srv-badge-success { background: #dcfce7; color: #166534; }
.srv-badge-danger  { background: #fee2e2; color: #991b1b; }
.srv-badge-info    { background: #dbeafe; color: #1d4ed8; }
.srv-badge-muted   { background: var(--srv-surface-3); color: var(--srv-text-muted); }

/* ============================================================
   10. NOTIFICACIÓN / TOAST BUBBLE
   ============================================================ */
.srv-notif-bubble {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: var(--srv-radius-full);
  background: var(--srv-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  font-family: var(--srv-font-heading);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--srv-bg-dark);
  pointer-events: none;
  animation: srv-pulse 2s infinite;
}

@keyframes srv-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ============================================================
   11. SKELETON LOADER (mobile performance UX)
   ============================================================ */
.srv-skeleton {
  background: linear-gradient(90deg, var(--srv-surface-3) 25%, #e8eaed 50%, var(--srv-surface-3) 75%);
  background-size: 200% 100%;
  animation: srv-shimmer 1.4s infinite;
  border-radius: var(--srv-radius-md);
}

@keyframes srv-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   12. LAYOUT HELPERS
   ============================================================ */
.srv-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--srv-space-md); }
.srv-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--srv-space-md); }
.srv-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--srv-space-md); }

@media (max-width: 768px) {
  .srv-grid-2,
  .srv-grid-3,
  .srv-grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .srv-grid-3,
  .srv-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.srv-flex      { display: flex; }
.srv-flex-col  { flex-direction: column; }
.srv-items-center { align-items: center; }
.srv-justify-between { justify-content: space-between; }
.srv-gap-sm    { gap: var(--srv-space-sm); }
.srv-gap-md    { gap: var(--srv-space-md); }
.srv-gap-lg    { gap: var(--srv-space-lg); }

.srv-section   { padding: var(--srv-space-2xl) 0; }
.srv-container { width: 92%; max-width: 1100px; margin: 0 auto; }

/* ============================================================
   13. MOBILE UX — Fixes específicos
   ============================================================ */

/* Prevent horizontal scroll en cualquier viewport */
html, body { overflow-x: hidden; }

/* Imágenes responsivas por defecto */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Evita zoom automático en iOS al hacer focus en inputs */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: max(16px, 1rem) !important;
  }
}

/* Contenido no cortado por navbar fixed */
.srv-page-content {
  padding-top: calc(68px + env(safe-area-inset-top, 0px));
}

/* Safe area para el bottom nav en iOS */
.srv-bottom-nav {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Overscroll behavior: evita pull-to-refresh en touch, pero NO bloquea scroll de mouse en desktop */
@media (pointer: coarse) {
  body {
    overscroll-behavior-y: contain;
  }
}

/* Mejora scroll en iOS */
.srv-scroll-container {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* ============================================================
   14. ACCESIBILIDAD — Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .srv-skeleton {
    animation: none;
    background: var(--srv-surface-3);
  }

  .srv-notif-bubble {
    animation: none;
  }
}

/* ============================================================
   15. DARK MODE — Tokens adaptativos
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --srv-surface:        #1a1a2e;
    --srv-surface-2:      #252540;
    --srv-surface-3:      #2d2d4a;
    --srv-border:         rgba(255,255,255,0.10);
    --srv-text-primary:   #f1f5f9;
    --srv-text-secondary: #94a3b8;
    --srv-text-muted:     #64748b;
  }

  .srv-card {
    background: var(--srv-surface);
    border-color: var(--srv-border);
  }

  .srv-input,
  .srv-select,
  .srv-textarea {
    background: var(--srv-surface-2);
    color: var(--srv-text-primary);
    border-color: var(--srv-border);
  }
}

/* ============================================================
   16. UTILIDADES DE VISIBILIDAD / ACCESIBILIDAD
   ============================================================ */

/* Screen reader only */
.srv-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Skip to content link (accesibilidad teclado) */
.srv-skip-link {
  position: absolute;
  top: -100%;
  left: var(--srv-space-md);
  background: var(--srv-primary);
  color: var(--srv-text-on-gold);
  padding: var(--srv-space-sm) var(--srv-space-md);
  border-radius: var(--srv-radius-md);
  font-weight: 700;
  z-index: 10000;
  text-decoration: none;
  transition: top var(--srv-duration-sm);
}
.srv-skip-link:focus { top: var(--srv-space-md); }

/* Contraste alto forzado (Windows) */
@media (forced-colors: active) {
  .srv-btn-primary { forced-color-adjust: none; }
}
