/* ===== AGENDA (vista vertical tipo SalonXP) ===== */
:root {
  --ag-px: 1.6px;              /* alto de 1 minuto */
  --ag-web: #7c3aed;
  --ag-web-lt: #ede9fe;
  --ag-line: #eef0f3;
  --ag-line-h: #d9dde3;
}

.ag-body { background: #fdf6fb; }
.ag-app[hidden], .ag-modal-bg[hidden], .ag-warn[hidden], .ag-err[hidden] { display: none !important; }

/* PIN */
.ag-pin {
  position: fixed; inset: 0; background: #fdf6fb; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
}
.ag-pin[hidden] { display: none; }
.ag-pin h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.ag-pin p  { color: var(--gray); font-size: .9rem; margin-bottom: 24px; }
.ag-pin-input { letter-spacing: 8px; font-size: 1.4rem; text-align: center; width: 180px; margin-bottom: 16px; }
.ag-pin-error { color: var(--red) !important; margin: -8px 0 12px !important; min-height: 1em; text-align: center; }
.ag-pin-back { margin-top: 16px; color: var(--gray); font-size: .85rem; }

/* Barra superior */
.ag-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.ag-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: #fff;
  padding: 10px 16px;
}
.ag-link {
  color: #fff; text-decoration: none; background: rgba(255,255,255,.15);
  padding: 6px 14px; border-radius: 20px; font-size: .82rem; font-weight: 600;
}
.ag-nav { display: flex; align-items: center; gap: 6px; }
.ag-navbtn, .ag-today, .ag-refresh {
  background: rgba(255,255,255,.15); color: #fff; border: none; cursor: pointer;
  border-radius: 8px; font-weight: 700; font-size: 1rem; padding: 6px 12px;
}
.ag-today { font-size: .82rem; }
.ag-navbtn:hover, .ag-today:hover, .ag-refresh:hover { background: rgba(255,255,255,.28); }
.ag-date { width: auto; padding: 6px 10px; font-size: .9rem; border-radius: 8px; border: none; }
.ag-title { font-weight: 800; font-size: 1.05rem; text-transform: capitalize; flex: 1; min-width: 200px; }
.ag-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .75rem; opacity: .85; }
.ag-legend span { display: flex; align-items: center; gap: 5px; }
.ag-sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.ag-sw-local { background: var(--rose); }
.ag-sw-web   { background: var(--ag-web); }
.ag-sw-prod  { background: repeating-linear-gradient(135deg, #fde68a 0 3px, #fff7d6 3px 6px); }
.ag-refresh.spin { animation: agspin .8s linear infinite; }
@keyframes agspin { to { transform: rotate(360deg); } }

.ag-hint { font-size: .78rem; color: var(--gray); padding: 6px 16px; }

/* Grilla */
.ag-scroll { flex: 1; overflow: auto; padding: 0 16px 16px; }
.ag-grid {
  display: grid; grid-template-columns: 56px repeat(var(--ag-cols, 3), minmax(170px, 1fr));
  min-width: calc(56px + var(--ag-cols, 3) * 170px);
  background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.ag-head {
  position: sticky; top: 0; z-index: 5; background: #fff;
  padding: 10px 8px; text-align: center; font-weight: 800; font-size: .95rem;
  border-bottom: 2px solid var(--rose-lt);
}
.ag-head small { display: block; font-weight: 500; font-size: .72rem; color: var(--gray); }
.ag-head:first-child { border-top-left-radius: var(--radius-sm); }
.ag-head:last-child  { border-top-right-radius: var(--radius-sm); }

.ag-times { position: relative; }
.ag-time {
  position: absolute; right: 6px; transform: translateY(-50%);
  font-size: .72rem; color: var(--gray); font-weight: 600;
}
.ag-time:first-child { transform: none; }
.ag-time.half { font-weight: 400; opacity: .6; font-size: .66rem; }

.ag-col {
  position: relative; border-left: 1px solid var(--ag-line-h); cursor: crosshair;
  user-select: none; -webkit-user-select: none;
  background:
    repeating-linear-gradient(to bottom, var(--ag-line-h) 0 1px, transparent 1px calc(60 * var(--ag-px))),
    repeating-linear-gradient(to bottom, var(--ag-line) 0 1px, transparent 1px calc(15 * var(--ag-px)));
}
.ag-off {
  position: absolute; left: 0; right: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(107,114,128,.07) 0 6px, rgba(107,114,128,.13) 6px 12px);
}
.ag-off-label {
  position: absolute; top: 8px; left: 0; right: 0; text-align: center;
  font-size: .75rem; color: var(--gray); font-weight: 600;
}
.ag-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.ag-now::before {
  content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--red);
}

.ag-sel {
  position: absolute; left: 3px; right: 3px; z-index: 7; pointer-events: none;
  background: rgba(233,30,140,.15); border: 2px dashed var(--rose); border-radius: 6px;
  font-size: .75rem; font-weight: 700; color: var(--rose); padding: 2px 6px;
}

/* Bloques de turno */
.ag-block {
  position: absolute; z-index: 2; overflow: hidden; cursor: pointer;
  border-radius: 6px; padding: 2px 6px; font-size: .75rem; line-height: 1.25;
  background: var(--rose-lt); border-left: 4px solid var(--rose); color: var(--dark);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.ag-block:hover { box-shadow: 0 3px 10px rgba(0,0,0,.2); z-index: 6; }
.ag-block.web  { background: var(--ag-web-lt); border-left-color: var(--ag-web); }
.ag-block.done { opacity: .5; }
.ag-block.clash { outline: 2px solid var(--gold); outline-offset: -2px; }
.ag-block b { font-weight: 800; }
.ag-block .ag-bt { color: var(--gray); font-size: .68rem; }
.ag-block .ag-bs { display: block; color: var(--gray); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-block .ag-bn { display: block; font-style: italic; font-size: .68rem; color: #92400e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-prod {
  position: absolute; left: 0; right: 0; cursor: crosshair;
  background: repeating-linear-gradient(135deg, rgba(253,230,138,.85) 0 4px, rgba(255,247,214,.85) 4px 8px);
}
.ag-block > .ag-txt { position: relative; }

/* Modal */
.ag-modal-bg {
  position: fixed; inset: 0; background: rgba(26,26,46,.45); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.ag-modal {
  background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 520px;
  max-height: 92vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.ag-modal h3 { font-size: 1.15rem; font-weight: 800; }
.ag-origin { font-size: .78rem; color: var(--gray); margin: 2px 0 12px; min-height: 1em; }
.ag-modal label {
  display: block; font-size: .75rem; font-weight: 700; color: var(--gray);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 10px;
}
.ag-modal input, .ag-modal select { margin-top: 4px; text-transform: none; letter-spacing: 0; }
.ag-opt { text-transform: none; font-weight: 400; letter-spacing: 0; }
.ag-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 480px) { .ag-row { grid-template-columns: 1fr 1fr; } .ag-row label:first-child { grid-column: 1 / -1; } }
.ag-warn {
  background: #fef3c7; border: 1px solid var(--gold); color: #92400e;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: .84rem; margin-bottom: 10px;
}
.ag-err { color: var(--red); font-size: .85rem; margin-bottom: 10px; }
.ag-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ag-btn {
  border: 1px solid #e5e7eb; background: #fff; border-radius: var(--radius-sm);
  padding: 10px 14px; font-weight: 700; font-size: .88rem; cursor: pointer;
}
.ag-btn:disabled { opacity: .6; cursor: wait; }
.ag-btn-main { background: linear-gradient(135deg, var(--rose), var(--rose-dk)); color: #fff; border: none; flex: 1; }
.ag-btn-del  { color: var(--red); }
.ag-btn-ghost { color: var(--gray); }
@media (max-width: 600px) { .ag-legend { display: none; } .ag-title { font-size: .95rem; } }
