/* ============================================================
   GLOBALMEDIA PULSE — main.css
   Sistema de diseño: variables, reset y componentes base
   ============================================================ */

/* ── Variables de diseño ─────────────────────────────────── */
:root {
  /* Colores primarios */
  --color-primary        : #1a73e8;
  --color-primary-dark   : #1557b0;
  --color-primary-light  : #e8f0fe;

  /* Semánticos */
  --color-success        : #34a853;
  --color-success-light  : #e6f4ea;
  --color-warning        : #fbbc04;
  --color-warning-light  : #fef7e0;
  --color-danger         : #ea4335;
  --color-danger-light   : #fce8e6;
  --color-info           : #1a73e8;
  --color-info-light     : #e8f0fe;

  /* Roles — colores distintivos para el badge de rol */
  --color-cerrador       : #8430ce;
  --color-cerrador-light : #f3e8fd;
  --color-admin          : #0f9d58;
  --color-admin-light    : #e6f4ea;
  --color-credito        : #f4511e;
  --color-credito-light  : #fbe9e7;
  --color-gerente        : #1a73e8;
  --color-gerente-light  : #e8f0fe;

  /* Grises */
  --gray-50  : #f8f9fa;
  --gray-100 : #f1f3f4;
  --gray-200 : #e8eaed;
  --gray-300 : #dadce0;
  --gray-400 : #bdc1c6;
  --gray-500 : #9aa0a6;
  --gray-600 : #80868b;
  --gray-700 : #5f6368;
  --gray-800 : #3c4043;
  --gray-900 : #202124;

  /* Tipografía */
  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size-xs  : 11px;
  --font-size-sm  : 13px;
  --font-size-md  : 15px;
  --font-size-lg  : 17px;
  --font-size-xl  : 20px;
  --font-size-2xl : 24px;

  /* Espaciado */
  --space-xs : 4px;
  --space-sm : 8px;
  --space-md : 16px;
  --space-lg : 24px;
  --space-xl : 32px;

  /* Bordes */
  --radius-sm : 6px;
  --radius-md : 10px;
  --radius-lg : 16px;
  --radius-xl : 24px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm : 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md : 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg : 0 4px 16px rgba(0,0,0,0.12);

  /* Inputs — regla de negocio: siempre visibles */
  --input-bg     : #f5f5f5;
  --input-border : #d0d0d0;
  --input-focus  : #1a73e8;
  --input-height : 48px;

  /* Transiciones */
  --transition: 0.18s ease;

  /* Altura header */
  --header-height: 56px;

  /* Altura nav inferior */
  --nav-height: 60px;
}

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

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Tipografía ──────────────────────────────────────────── */
h1 { font-size: var(--font-size-2xl); font-weight: 600; }
h2 { font-size: var(--font-size-xl);  font-weight: 600; }
h3 { font-size: var(--font-size-lg);  font-weight: 500; }
h4 { font-size: var(--font-size-md);  font-weight: 500; }
p  { line-height: 1.6; }
a  { color: var(--color-primary); text-decoration: none; }

/* ── Inputs — REGLA: siempre con bordes y fondo visible ─── */
input, textarea, select {
  width: 100%;
  height: var(--input-height);
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  font-size: var(--font-size-md);
  font-family: var(--font-family);
  color: var(--gray-900);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  height: auto;
  min-height: 96px;
  padding: var(--space-md);
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
  background: #ffffff;
}

input::placeholder, textarea::placeholder {
  color: var(--gray-500);
}

input:disabled, textarea:disabled, select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Select con flecha personalizada */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235f6368' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

/* ── Botones ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: var(--input-height);
  padding: 0 var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
  border: 1.5px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}
.btn-ghost:hover { background: var(--color-primary-light); }

/* Botón de ancho completo */
.btn-block { width: 100%; }

/* Botón grande para trabajo de campo */
.btn-xl {
  height: 56px;
  font-size: var(--font-size-lg);
  border-radius: var(--radius-lg);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--gray-100);
}

/* ── Badges de etapa ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-prospecto        { background: var(--gray-100);         color: var(--gray-700); }
.badge-contactado       { background: #e8f0fe;                 color: #1557b0; }
.badge-presentacion     { background: #fef7e0;                 color: #b06000; }
.badge-propuesta        { background: #f3e8fd;                 color: #6200ea; }
.badge-cierre           { background: #fff3e0;                 color: #e65100; }
.badge-ganado           { background: var(--color-success-light); color: #1e7e34; }
.badge-perdido          { background: var(--color-danger-light);  color: #c62828; }
.badge-icebox           { background: #e3f2fd;                 color: #0d47a1; }
.badge-renovado         { background: var(--color-success-light); color: #1b5e20; }
.badge-no-renovado      { background: var(--gray-100);         color: var(--gray-600); }

/* ── Form groups ─────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
}

.form-label.required::after {
  content: " *";
  color: var(--color-danger);
}

.form-error {
  font-size: var(--font-size-sm);
  color: var(--color-danger);
  display: none;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
  border-color: var(--color-danger);
}

.form-group.has-error .form-error { display: block; }

/* ── Toasts / Notificaciones ─────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: calc(100% - 32px);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
  pointer-events: all;
}

.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-warning { background: #e37400; }

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

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-primary {
  border-color: var(--color-primary-light);
  border-top-color: var(--color-primary);
}

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

/* ── Pantalla de carga global ────────────────────────────── */
#app-loading {
  position: fixed;
  inset: 0;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  z-index: 10000;
}

#app-loading .logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
}

#app-loading p {
  color: var(--gray-500);
  font-size: var(--font-size-sm);
}

/* ── Layout principal con nav inferior ───────────────────── */
#app-shell {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

#app-shell.visible { display: flex; }

#app-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  gap: var(--space-md);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

#app-header .app-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
  flex: 1;
}

#app-header .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}

#app-content {
  flex: 1;
  padding: var(--space-md);
  padding-bottom: calc(var(--nav-height) + var(--space-md));
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

#app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: white;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  color: var(--gray-500);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--color-primary); }
.nav-item.active svg { stroke: var(--color-primary); }

/* ── Broadcast banner ────────────────────────────────────── */
.broadcast-banner {
  background: var(--color-danger);
  color: white;
  padding: 10px var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

/* ── Utilidades ──────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--gray-500); }
.text-sm     { font-size: var(--font-size-sm); }
.text-xs     { font-size: var(--font-size-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.gap-sm { gap: var(--space-sm); }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
