/* ==========================================================
   AGENDA DE CITAS (Mes / Semana / Día)
   ========================================================== */
.agenda-card { padding: 18px; }

.agenda-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 12px; margin-bottom: 12px;
}
.agenda-nav, .agenda-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agenda-title {
  font-size: 1.2rem; font-weight: 700; color: var(--dark-text);
  flex: 1; text-align: center; min-width: 180px;
}
.agenda-btn {
  background: #fff; border: 1px solid #ced4da; border-radius: 8px;
  padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; color: var(--dark-text);
}
.agenda-btn:hover { background: var(--light-bg); }
.agenda-btn.icon { padding: 7px 12px; }

.agenda-views { display: inline-flex; border: 1px solid #ced4da; border-radius: 8px; overflow: hidden; }
.agenda-views button {
  background: #fff; border: 0; border-right: 1px solid #ced4da;
  padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; color: var(--dark-text);
}
.agenda-views button:last-child { border-right: 0; }
.agenda-views button.active { background: var(--primary-color); color: #fff; }

.agenda-legend {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  font-size: .82rem; color: var(--secondary-color); margin-bottom: 10px;
}
.agenda-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.agenda-legend label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 500; cursor: pointer; }
#agenda-count { margin-left: auto; font-weight: 600; color: var(--dark-text); }

/* ---- colores por estado ---- */
.st-pendiente  { --c: #007bff; --bg: #e7f1ff; --tx: #0a4a96; }
.st-confirmada { --c: #e0a800; --bg: #fff4d1; --tx: #7a5b00; }
.st-completada { --c: #28a745; --bg: #e2f5e7; --tx: #1b6b2f; }
.st-cancelada  { --c: #6c757d; --bg: #eceff1; --tx: #555e66; }

/* ---- Semana / Día ---- */
.ag-scroll {
  overflow: auto; max-height: calc(100vh - 280px); min-height: 420px;
  border: 1px solid var(--border-color); border-radius: 10px; background: #fff; position: relative;
}
.ag-inner {
  display: grid;
  grid-template-columns: 56px repeat(var(--cols), minmax(var(--colmin), 1fr));
  min-width: calc(56px + var(--cols) * var(--colmin));
}
.ag-corner, .ag-dayhead {
  position: sticky; top: 0; z-index: 6; background: #fff;
  border-bottom: 2px solid var(--border-color); height: 44px;
}
.ag-corner { left: 0; z-index: 8; }
.ag-dayhead {
  border: 0; border-bottom: 2px solid var(--border-color); border-left: 1px solid var(--border-color);
  font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--dark-text);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.ag-dayhead:hover { background: var(--light-bg); }
.ag-dayhead.today { background: #e7f1ff; color: var(--primary-color); border-bottom-color: var(--primary-color); }
.ag-daycount {
  background: var(--primary-color); color: #fff; border-radius: 10px;
  font-size: .7rem; padding: 1px 7px; font-weight: 700;
}

.ag-gutter { position: sticky; left: 0; z-index: 5; background: #fff; border-right: 1px solid var(--border-color); }
.ag-hlabel {
  height: var(--hour); font-size: .72rem; color: var(--secondary-color);
  text-align: right; padding-right: 8px; transform: translateY(-.5em);
}
.ag-hlabel:first-child { transform: translateY(2px); }

.ag-col {
  position: relative; border-left: 1px solid var(--border-color); cursor: pointer;
  background-image:
    linear-gradient(to bottom, #dee2e6 1px, transparent 1px),
    linear-gradient(to bottom, #f1f3f5 1px, transparent 1px);
  background-size: 100% var(--hour), 100% calc(var(--hour) / 2);
}
.ag-col.today { background-color: #f3f8ff; }

.ag-closed {
  position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(108,117,125,.10) 0 6px, rgba(108,117,125,.04) 6px 12px);
  display: flex; align-items: center; justify-content: center;
}
.ag-closed span { font-size: .75rem; color: var(--secondary-color); text-transform: uppercase; letter-spacing: 1px; }
.ag-past { position: absolute; left: 0; right: 0; top: 0; background: rgba(255,255,255,.55); z-index: 1; pointer-events: none; }

.ag-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger-color); z-index: 4; pointer-events: none; }
.ag-now::before {
  content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--danger-color);
}

.ag-ghost {
  display: none; position: absolute; left: 2px; right: 2px; z-index: 2; pointer-events: none;
  border: 1px dashed var(--primary-color); background: rgba(0,123,255,.08); color: var(--primary-color);
  border-radius: 6px; font-size: .74rem; font-weight: 600; padding: 2px 6px;
}

.ag-event {
  position: absolute; z-index: 3; text-align: left; overflow: hidden; cursor: pointer;
  background: var(--bg); color: var(--tx); border: 1px solid var(--c); border-left: 4px solid var(--c);
  border-radius: 6px; padding: 2px 6px; font: inherit; font-size: .76rem; line-height: 1.25;
  display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.ag-event:hover { filter: brightness(.97); box-shadow: 0 3px 8px rgba(0,0,0,.18); z-index: 4; }
.ag-ev-time { font-weight: 700; font-size: .7rem; }
.ag-ev-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev-service { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.ag-event.st-cancelada { opacity: .65; }
.ag-event.st-cancelada .ag-ev-name { text-decoration: line-through; }

/* ---- Mes ---- */
.ag-month {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden; background: #fff;
}
.ag-mhead {
  background: var(--light-bg); text-align: center; padding: 8px 0; font-weight: 700;
  font-size: .8rem; border-bottom: 1px solid var(--border-color); color: var(--secondary-color);
}
.ag-mcell {
  min-height: 112px; padding: 4px; border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color); cursor: pointer; overflow: hidden;
}
.ag-mcell:nth-child(7n) { border-right: 0; }
.ag-mcell:hover { background: #f8fbff; }
.ag-mcell.other { background: #fafbfc; }
.ag-mcell.other .ag-mnum { color: #adb5bd; }
.ag-mcell.closed { background: repeating-linear-gradient(135deg, rgba(108,117,125,.08) 0 6px, transparent 6px 12px); }
.ag-mnum { font-size: .82rem; font-weight: 700; margin: 0 0 3px 2px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.ag-mcell.today .ag-mnum { background: var(--primary-color); color: #fff; border-radius: 50%; }
.ag-chip {
  display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--c);
  background: var(--bg); color: var(--tx); border-radius: 4px; padding: 1px 5px; margin-bottom: 2px;
  font: inherit; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.ag-chip:hover { filter: brightness(.95); }
.ag-more { font-size: .72rem; color: var(--primary-color); font-weight: 600; padding-left: 4px; }

/* ---- Modales ---- */
body.ag-noscroll { overflow: hidden; }
.ag-modal { display: none; position: fixed; inset: 0; z-index: 3000; align-items: center; justify-content: center; padding: 16px; }
.ag-modal.open { display: flex; }
.ag-modal-backdrop { position: absolute; inset: 0; background: rgba(33,37,41,.55); }
.ag-modal-box {
  position: relative; background: #fff; border-radius: 14px; padding: 24px;
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.ag-modal-close {
  position: absolute; top: 10px; right: 12px; border: 0; background: transparent;
  font-size: 1.1rem; cursor: pointer; color: var(--secondary-color); width: 32px; height: 32px; border-radius: 50%;
}
.ag-modal-close:hover { background: var(--light-bg); }
.ag-form-box .form-grid { margin: 0; display: block; }
.ag-form-box .form-card { border: 0; box-shadow: none; padding: 0; }

.ag-detail-box { max-width: 440px; }
.ag-badge {
  display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: .75rem; font-weight: 700;
  background: var(--bg); color: var(--tx); border: 1px solid var(--c);
}
.ag-detail-name { margin: 10px 0 14px; font-size: 1.35rem; }
.ag-detail-row { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border-color); font-size: .93rem; }
.ag-detail-row i { width: 18px; text-align: center; color: var(--primary-color); margin-top: 3px; }
.ag-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.ag-detail-actions .btn { width: auto; flex: 1 1 auto; margin: 0; }

/* ---- Móvil ---- */
@media (max-width: 768px) {
  .agenda-card { padding: 12px; }
  .agenda-title { order: -1; flex-basis: 100%; font-size: 1.05rem; }
  .agenda-actions { width: 100%; justify-content: space-between; }
  #agenda-count { margin-left: 0; width: 100%; }
  .ag-scroll { max-height: calc(100vh - 230px); }
  .ag-mcell { min-height: 64px; padding: 2px; }
  .ag-chip { display: inline-block; width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: var(--c); margin: 1px; }
  .ag-chip b, .ag-chip-text { display: none; }
  .ag-modal-box { padding: 18px; }
}

/* ---- Filtro por doctor / sillón + color del doctor ---- */
.agenda-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px;
}
.agenda-filters-label { font-size: .82rem; font-weight: 700; color: var(--secondary-color); }
.agenda-filters select {
  width: auto; min-width: 170px; margin: 0; padding: 6px 10px; font-size: .85rem;
}
.agenda-filters .agenda-btn { align-items: center; gap: 6px; padding: 6px 12px; font-size: .82rem; }

/* El estado sigue marcando el color del bloque; el doctor se ve como franja discreta a la derecha */
.ag-event.has-doc { box-shadow: inset -5px 0 0 var(--doc), 0 1px 2px rgba(0,0,0,.08); }
.ag-ev-doc {
  display: flex; align-items: center; gap: 5px;
  font-size: .68rem; font-weight: 600; opacity: .9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-ev-doc::before {
  content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%;
  background: var(--doc, #adb5bd); border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.ag-chip.has-doc { box-shadow: inset -4px 0 0 var(--doc); }

@media (max-width: 768px) {
  .agenda-filters select { flex: 1 1 140px; min-width: 0; }
}
