@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens (sobreescritos dinámicamente desde tenant_settings) ──── */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #93c5fd;
  --primary-bg:     #eff6ff;
  --primary-rgb:    37, 99, 235;   /* r, g, b — para rgba() */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f5f9;
  opacity: 0;
  transition: opacity 0.18s ease;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}
body.loaded { opacity: 1; }

/* Prevent any element from creating horizontal overflow */
img, svg, video, canvas { max-width: 100%; }

/* Ocultar botón nativo X de inputs type="search" en webkit/Chrome */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { display: none; }

/* ── Top Header ─────────────────────────────────── */
#topHeader {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 16px; padding-right: 16px;
  box-sizing: border-box;
}

/* ── Bottom Navigation ──────────────────────────── */
#bottomNav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #e2e8f0;
  display: flex; align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(60px + env(safe-area-inset-bottom, 0px));
}
#bottomNav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 8px 4px;
  font-size: 10px; font-weight: 500; color: #94a3b8;
  text-decoration: none; transition: color 0.15s;
}
#bottomNav a svg { width: 22px; height: 22px; }
#bottomNav a.active { color: var(--primary); }
#bottomNav a.active svg { stroke-width: 2.5; }

/* ── Main content ───────────────────────────────── */
main {
  padding-top: 56px;
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px);
  min-height: 100vh;
}

/* ── FAB ────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 12px);
  right: 16px; z-index: 45;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: white; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(var(--primary-rgb),0.38);
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.93); box-shadow: 0 2px 10px rgba(var(--primary-rgb),0.3); }
.fab svg { width: 22px; height: 22px; }

/* ── Modal overlay ──────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-sheet {
  background: white; width: 100%; max-width: 600px;
  border-radius: 20px 20px 0 0;
  max-height: 92vh; overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: #e2e8f0; margin: 10px auto 0;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-sheet {
    border-radius: 20px; margin: 16px;
    max-height: 85vh; width: calc(100% - 32px);
    transform: scale(0.95) translateY(0);
  }
  .modal-overlay.open .modal-sheet { transform: scale(1); }
  .sheet-handle { display: none; }
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: white; border-radius: 16px;
  border: 1px solid #e8eef4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s, transform 0.12s;
}
.card:active { transform: scale(0.985); }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ── Form inputs ─────────────────────────────────── */
.input {
  width: 100%; border: 1.5px solid #e2e8f0; border-radius: 12px;
  padding: 11px 14px; font-size: 14px; font-family: inherit;
  background: white; color: #1e293b; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.12); }
.input::placeholder { color: #94a3b8; }

/* Evita el zoom automático en iOS al enfocar inputs (requiere font-size >= 16px) */
@media screen and (max-width: 768px) {
  .input, input, textarea, select {
    font-size: 16px !important;
  }
}

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  width: 100%; background: var(--primary); color: white; border: none;
  border-radius: 12px; padding: 13px 20px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background 0.15s, transform 0.12s;
  -webkit-appearance: none;
}
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }
.btn-primary:disabled { background: var(--primary-light); cursor: not-allowed; }

.btn-secondary {
  width: 100%; background: #f1f5f9; color: #475569; border: none;
  border-radius: 12px; padding: 13px 20px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background 0.15s;
  -webkit-appearance: none;
}
.btn-secondary:active { background: #e2e8f0; }

/* ── Filter chips ───────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid #e2e8f0;
  font-size: 12px; font-weight: 500; color: #64748b;
  background: white; white-space: nowrap; cursor: pointer;
  transition: all 0.15s;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: white; }
.chip:active { transform: scale(0.96); }

/* ── Section header ─────────────────────────────── */
.section-title {
  font-size: 13px; font-weight: 600; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0 4px; margin-bottom: 8px;
}

/* ── Status dot ─────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  margin-top: 5px;
}

/* ── Empty state ────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px; text-align: center;
}
.empty-state svg { width: 48px; height: 48px; color: #cbd5e1; margin-bottom: 12px; }
.empty-state p { font-size: 14px; color: #94a3b8; }

/* ── Progress bar ───────────────────────────────── */
.progress-bar { height: 5px; border-radius: 3px; background: #f1f5f9; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }

/* ── Scrollbar thin ─────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* ── Desktop sidebar ─────────────────────────────── */
@media (min-width: 768px) {
  #bottomNav { display: none; }
  #desktopNav { display: flex !important; }
  main { padding-bottom: 32px; padding-left: 220px; }
  #topHeader { padding-left: 236px; }
  .fab { bottom: 24px; }
}

/* ── Responsive 2-col → 1-col grid ──────────────── */
@media (max-width: 400px) {
  .grid-2col { grid-template-columns: 1fr !important; }
}

/* ── Wide screen: cap and center content ─────────── */
@media (min-width: 1024px) {
  main {
    /* Center content after sidebar */
    padding-right: max(24px, calc((100vw - 220px - 860px) / 2));
    padding-left: calc(220px + max(24px, (100vw - 220px - 860px) / 2));
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  main { padding-left: 236px; padding-right: 24px; }
}

#desktopNav {
  display: none;
  position: fixed; left: 0; top: 56px; bottom: 0; width: 204px; z-index: 40;
  background: white; border-right: 1px solid #e2e8f0;
  flex-direction: column; padding: 12px 8px 8px; gap: 2px; overflow-y: hidden;
}
#desktopNav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: #64748b;
  text-decoration: none; transition: all 0.15s;
}
#desktopNav a:hover { background: #f8fafc; color: #1e293b; }
#desktopNav a.active { background: var(--primary-bg); color: var(--primary); }
#desktopNav a svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Swipe hint ─────────────────────────────────── */
@media (hover: none) {
  .card:active { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
}

/* ── Spinner animation (quick task button) ───────── */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Card entrance animation ─────────────────────── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-in { animation: cardIn 0.22s ease both; }

/* ── Bar grow animation (dashboard charts) ───────── */
@keyframes barGrow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
.bar-grow {
  transform-origin: bottom;
  animation: barGrow 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ── Skeleton loading ─────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
.skeleton-text  { height: 13px; border-radius: 4px; margin-bottom: 6px; }
.skeleton-title { height: 17px; border-radius: 4px; margin-bottom: 8px; }
.skeleton-card  {
  background: white; border-radius: 16px;
  border: 1px solid #e8eef4;
  padding: 16px;
}

/* ── Back-to-top button ──────────────────────────── */
#backToTop {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 70px);
  right: 16px; z-index: 44;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.92);
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  opacity: 0; pointer-events: none;
  backdrop-filter: blur(8px);
}
#backToTop.visible { opacity: 1; pointer-events: all; }
#backToTop:active  { transform: scale(0.92); }
@media (min-width: 768px) {
  #backToTop { bottom: 32px; right: 32px; }
}

/* ── Celebrate burst ──────────────────────────────── */
@keyframes burst {
  0%   { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx),var(--ty)) scale(0); }
}
.celebrate-particle {
  position: fixed; width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none; z-index: 9999;
  animation: burst 0.7s ease-out forwards;
}

/* ── Creation pop ─────────────────────────────────── */
@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.5) translateY(20px); }
  60%  { opacity: 1; transform: scale(1.12) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.pop-in { animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both; }

/* ── Celebrate check ──────────────────────────────── */
@keyframes celebCheck {
  0%   { opacity: 0; transform: scale(0); }
  60%  { transform: scale(1.12); }
  80%  { transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1); }
}
.celeb-check {
  position: fixed; z-index: 9999; pointer-events: none;
  width: 64px; height: 64px; border-radius: 50%;
  background: #16a34a; display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: white;
  animation: celebCheck 0.5s cubic-bezier(.22,1.4,.36,1) both;
}

/* ── Pull-to-refresh ──────────────────────────────── */
@keyframes ptrSpin { to { transform: rotate(360deg); } }
#ptrSpinner {
  position: fixed; top: calc(56px + env(safe-area-inset-top,0px) + 8px);
  left: 50%; transform: translateX(-50%) scale(0);
  z-index: 49; width: 36px; height: 36px; border-radius: 50%;
  background: white; box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
#ptrSpinner.pulling { transform: translateX(-50%) scale(1); }
#ptrSpinner svg { animation: ptrSpin 0.8s linear infinite; }

/* ── Bottom nav fade indicators ──────────────────── */
.bottomNavFade {
  position: absolute; top: 0; bottom: 0; width: 28px; pointer-events: none;
  z-index: 1; transition: opacity 0.2s; display: flex; align-items: center;
}
.bottomNavFade.left  { left: 0;  background: linear-gradient(to right, rgba(255,255,255,0.95), transparent); }
.bottomNavFade.right { right: 0; background: linear-gradient(to left,  rgba(255,255,255,0.95), transparent); }
.bottomNavFade.hidden { opacity: 0; }
.bottomNavFade span { font-size: 10px; color: #94a3b8; }
.bottomNavFade.left  span { margin-left: 2px; }
.bottomNavFade.right span { margin-right: 2px; margin-left: auto; }

/* ── IA typing dots ───────────────────────────────── */
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7c3aed; display: inline-block;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 8px 4px; }

/* ── Mic pulse ────────────────────────────────────── */
@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.mic-recording {
  background: #ef4444 !important;
  animation: micPulse 1.2s ease-out infinite;
}

/* ── Bar horizontal grow (permisos/avances) ───────── */
@keyframes barGrowH {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.bar-animate {
  transform-origin: left;
  animation: barGrowH 0.7s ease-out both;
}
