/* Agenda compartida Uñas/Barbería · v34 · Creado por: Ángel Rojas */
/* Franjas horarias partidas = varias franjas reales por día. */

.ag-wrap { display: grid; gap: 1rem; width: 100%; max-width: 100%; min-width: 0; }
.ag-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; padding: 1rem;
  min-width: 0; box-shadow: 0 12px 28px -22px rgba(15,23,42,.4);
}
.ag-card > h3, .ag-card > .ag-titulo { margin: 0 0 .75rem; font-size: 1rem; color: #0f172a; }
.ag-eyebrow { margin: 0 0 .3rem; font-size: .63rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #475569; }
.ag-ayuda { margin: .35rem 0; font-size: .72rem; line-height: 1.5; color: #475569; }
.ag-estado { min-height: 1.1rem; margin: 0; font-size: .76rem; color: #0f172a; font-weight: 700; }
.ag-fila { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ag-acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.ag-espaciador { flex: 1 1 auto; }
.ag-vacio { margin: .6rem 0; padding: 1rem; text-align: center; font-size: .78rem; color: #475569; border: 1px dashed #cbd5e1; border-radius: 14px; }

/* ---------- Configuración de franjas horarias ---------- */
.ag-config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem; }
.ag-dia { border: 1px solid #e2e8f0; border-radius: 18px; padding: .85rem; background: #f8fafc; min-width: 0; }
.ag-dia.cerrado { opacity: .66; }
.ag-dia-cabecera { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ag-dia-cabecera h4 { margin: 0; font-size: .9rem; color: #0f172a; }
.ag-switch { display: inline-flex; align-items: center; gap: .4rem; font-size: .7rem; font-weight: 800; color: #0f172a; }
.ag-franjas { display: grid; gap: .55rem; }
.ag-franja {
  display: grid; grid-template-columns: minmax(115px, 130px) minmax(115px, 130px) auto;
  gap: .5rem; align-items: end; flex-wrap: wrap;
}
.ag-franja label { display: grid; gap: .2rem; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #475569; }
.ag-franja input[type="time"] {
  width: 115px; min-width: 115px; max-width: 150px; height: 40px; padding: 0 .5rem;
  font-size: .92rem; font-weight: 700; color: #0f172a; background: #fff;
  border: 1px solid #cbd5e1; border-radius: 10px; box-sizing: border-box;
}
.ag-franja button { min-height: 40px; }
.ag-franja-num { font-size: .62rem; font-weight: 800; color: #475569; }
.ag-festivos { display: flex; flex-wrap: wrap; gap: .4rem; }
.ag-festivo {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .6rem;
  border: 1px solid #fecdd3; border-radius: 999px; background: #fff1f2;
  font-size: .72rem; font-weight: 700; color: #9f1239;
}

/* ---------- Calendario semanal ---------- */
.ag-cal-barra { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.ag-cal-titulo { font-size: .9rem; font-weight: 800; color: #0f172a; }
.ag-cal-grid { display: grid; grid-template-columns: 74px repeat(7, minmax(0, 1fr)); border: 1px solid #e2e8f0; border-radius: 16px; overflow: hidden; background: #fff; }
.ag-cal-cab {
  display: grid; place-content: center; gap: .1rem; text-align: center; min-height: 48px;
  padding: .45rem .2rem; background: #0f172a; color: #fff; border-right: 1px solid rgba(255,255,255,.12);
}
.ag-cal-cab strong { font-size: .74rem; }
.ag-cal-cab span { font-size: .68rem; opacity: .85; }
.ag-cal-cab.hoy { background: #be185d; }
.ag-cal-hora {
  display: grid; place-content: center; min-height: 54px; padding: .2rem;
  font-size: .7rem; font-weight: 800; color: #475569; background: #f8fafc;
  border-top: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0;
}
.ag-cal-celda {
  min-width: 0; min-height: 54px; padding: .25rem; border-top: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0; display: grid; align-content: start; gap: .2rem;
}
.ag-cal-celda.ocupada { background: #fef2f2; }
.ag-cal-celda.libre { cursor: pointer; }
.ag-cal-celda.libre:hover { background: #f0f9ff; }
.ag-cita {
  display: grid; gap: .1rem; width: 100%; text-align: left; padding: .35rem .4rem;
  border: 1px solid #fbcfe8; border-radius: 10px; background: #fdf2f8; color: #831843;
  font-size: .66rem; font-weight: 800; cursor: pointer; overflow-wrap: anywhere;
}
.ag-cita small { font-size: .6rem; font-weight: 700; color: #9f1239; }
.ag-cita.confirmada { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.ag-cita.cancelada, .ag-cita.no-asistio { border-color: #e2e8f0; background: #f1f5f9; color: #64748b; text-decoration: line-through; }
.ag-cal-ocupada {
  display: block; font-size: .62rem; font-weight: 800; color: #b91c1c;
  text-decoration: line-through; text-decoration-thickness: 2px;
}
.ag-cal-libre { display: block; font-size: .62rem; font-weight: 700; color: #047857; }
.ag-dias-pastillas { display: none; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }
.ag-pastilla {
  min-height: 38px; padding: .35rem .6rem; border: 1px solid #cbd5e1; border-radius: 999px;
  background: #fff; color: #0f172a; font-size: .72rem; font-weight: 800; cursor: pointer;
}
.ag-pastilla.activa { background: #0f172a; border-color: #0f172a; color: #fff; }
.ag-lista-horas { display: grid; gap: .4rem; }
.ag-hora-fila {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-height: 44px;
  padding: .5rem .6rem; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff;
}
.ag-hora-fila.ocupada { background: #fef2f2; border-color: #fecaca; }
.ag-hora-fila strong { font-size: .82rem; color: #0f172a; }
.ag-hora-fila.ocupada strong { color: #b91c1c; text-decoration: line-through; }
.ag-hora-fila button { margin-left: auto; }

/* ---------- Formularios y listado ---------- */
.ag-form { display: grid; gap: .6rem; }
.ag-form label { display: grid; gap: .25rem; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #475569; }
.ag-form input, .ag-form select, .ag-form textarea {
  min-height: 42px; width: 100%; max-width: 100%; padding: .5rem .6rem;
  border: 1px solid #cbd5e1; border-radius: 10px; font-size: .84rem; color: #0f172a; background: #fff;
}
.ag-form textarea { min-height: 70px; resize: vertical; }
.ag-form-dos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.ag-slots { display: flex; flex-wrap: wrap; gap: .35rem; }
.ag-slot {
  min-width: 64px; min-height: 38px; padding: .35rem .5rem; border-radius: 10px;
  border: 1px solid #a7f3d0; background: #ecfdf5; color: #065f46;
  font-size: .74rem; font-weight: 800; cursor: pointer;
}
.ag-slot.activo { background: #065f46; color: #fff; border-color: #065f46; }
.ag-slot.ocupada { border-color: #fecaca; background: #fef2f2; color: #b91c1c; text-decoration: line-through; cursor: not-allowed; }
.ag-listado { display: grid; gap: .55rem; }
.ag-item {
  display: grid; gap: .45rem; padding: .7rem; border: 1px solid #e2e8f0;
  border-radius: 14px; background: #fff; min-width: 0;
}
.ag-item-cab { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ag-item-cab h4 { margin: 0; font-size: .88rem; color: #0f172a; }
.ag-item-datos { display: flex; flex-wrap: wrap; gap: .35rem .8rem; font-size: .72rem; color: #475569; }
.ag-tag { padding: .18rem .5rem; border-radius: 999px; font-size: .62rem; font-weight: 800; background: #f1f5f9; color: #334155; }
.ag-tag.confirmada { background: #d1fae5; color: #065f46; }
.ag-tag.cancelada, .ag-tag.no-asistio { background: #e2e8f0; color: #475569; }
.ag-tag.pendiente { background: #fef3c7; color: #92400e; }

/* ---------- Modal de cita ---------- */
.ag-modal {
  position: fixed; inset: 0; z-index: 130; display: none; place-items: center;
  padding: 1rem; background: rgba(10,15,28,.72);
}
.ag-modal.abierto { display: grid; }
.ag-modal-panel {
  width: min(100%, 520px); max-height: min(92dvh, 760px); overflow-y: auto;
  background: #fff; border-radius: 22px; padding: 1.1rem; box-shadow: 0 30px 70px -30px rgba(15,23,42,.7);
}
.ag-modal-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.ag-modal-cab h3 { margin: 0; font-size: 1.05rem; color: #0f172a; }
.ag-datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .8rem 0; }
.ag-dato { padding: .55rem .65rem; border-radius: 12px; background: #f8fafc; border: 1px solid #e2e8f0; }
.ag-dato span { display: block; font-size: .6rem; font-weight: 800; text-transform: uppercase; color: #475569; }
.ag-dato strong { display: block; margin-top: .15rem; font-size: .8rem; color: #0f172a; overflow-wrap: anywhere; }

/* ---------- WhatsApp real y CRM ---------- */
.ag-wa-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr); gap: .8rem; }
.ag-plantilla { display: grid; gap: .5rem; }
.ag-filtros { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.ag-filtro {
  min-height: 36px; padding: .3rem .65rem; border-radius: 999px; border: 1px solid #cbd5e1;
  background: #fff; color: #0f172a; font-size: .7rem; font-weight: 800; cursor: pointer;
}
.ag-filtro.activa { background: #0f172a; border-color: #0f172a; color: #fff; }
.ag-cliente {
  display: grid; gap: .3rem; padding: .6rem; border: 1px solid #e2e8f0;
  border-radius: 12px; background: #fff; min-width: 0;
}
.ag-cliente-cab { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ag-cliente-cab strong { font-size: .82rem; color: #0f172a; }
.ag-cliente small { font-size: .68rem; color: #475569; }
.ag-cola { display: grid; gap: .5rem; }
.ag-cola-item {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .55rem;
  border: 1px solid #a7f3d0; border-radius: 12px; background: #ecfdf5;
}
.ag-cola-item strong { font-size: .78rem; color: #065f46; }
.ag-wa-btn { min-height: 40px; border: 0; border-radius: 10px; background: #128c7e; color: #fff; font-weight: 800; cursor: pointer; }

/* Cabeceras reutilizadas por las vistas nuevas de Barbería. */
.bar-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin: 0 0 .9rem; min-width: 0; }
.bar-hero h2 { margin: .15rem 0 .3rem; font-size: 1.35rem; font-weight: 800; color: #1c1917; }
.bar-hero p { margin: 0; font-size: .74rem; line-height: 1.5; color: #7c7164; }
.unas-badge { display: inline-block; margin: .1rem; padding: .3rem .6rem; border: 1px solid #e9d9bf; border-radius: 999px; background: #fffcf6; font-size: .68rem; font-weight: 800; color: #b45309; }
.unas-aviso { min-height: 1.1rem; margin: 0 0 .7rem; font-size: .74rem; font-weight: 700; color: #b45309; overflow-wrap: anywhere; }
.ag-fila input[type="search"], .ag-fila input[type="date"] { min-height: 40px; min-width: 0; max-width: 100%; padding: .4rem .6rem; border: 1px solid #cbd5e1; border-radius: 10px; font-size: .78rem; }
.ag-fila input[type="search"] { flex: 1 1 220px; }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .ag-wa-layout { grid-template-columns: minmax(0, 1fr); }
  .ag-cal-grid {
    grid-template-columns: 60px repeat(7, minmax(64px, 1fr));
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }
}
@media (max-width: 640px) {
  .ag-wrap { gap: 12px; }
  .ag-config-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ag-card {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 14px;
    gap: 10px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 24px -18px rgba(15, 23, 42, .38);
  }
  .ag-franja { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ag-franja input[type="time"] {
    width: 100%;
    min-width: 128px;
    max-width: 100%;
    height: 44px;
    min-height: 44px;
    font-size: 16px;
    border-radius: 12px;
  }
  .ag-form input, .ag-form select, .ag-form textarea,
  .ag-fila input[type="search"], .ag-fila input[type="date"] {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .ag-dato strong {
    font-size: clamp(1.25rem, 5.5vw, 1.6rem);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
  }
  .ag-acciones .btn, .ag-franja button, .ag-pastilla, .ag-slot,
  .ag-filtro, .ag-wa-btn, .ag-hora-fila button {
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 800;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .ag-dias-pastillas { display: flex; }
  .ag-cal-grid { display: none; }
  .ag-lista-horas { display: grid; gap: 10px; }
  .ag-item, .ag-cliente, .ag-cola-item {
    content-visibility: auto;
    contain-intrinsic-size: auto 72px;
  }
}
@media (max-width: 389px) {
  .ag-franja { grid-template-columns: minmax(0, 1fr); }
  .ag-dia { padding: 12px; }
}
