/**
 * Event Manager - Estilos Frontend
 * Version: 1.3.0
 */

/* ============================================
   VARIABLES CSS
   ============================================ */

:root {
  --event-primary-color: #2271b1;
  --event-upcoming-color: #2e7d32;
  --event-ongoing-color: #f57c00;
  --event-past-color: #c62828;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */

.event-manager-container {
  max-width: 80%;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 30px;
  align-items: start;
}

.event-manager-container:not(.has-calendar) {
  display: block;
}

/* ============================================
   CALENDARIO
   ============================================ */

.event-calendar-section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 20px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.calendar-month-year {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.calendar-nav {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-nav:hover {
  background: var(--event-primary-color);
  border-color: var(--event-primary-color);
  color: #fff;
}

.calendar-nav .dashicons {
  font-size: 18px;
  width: 18px;
  height: 18px;
}

#event-calendar {
  width: 100%;
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  table-layout: fixed;
}

.calendar-table th {
  padding: 8px 4px;
  text-align: center;
  font-weight: 600;
  color: #666;
  border-bottom: 2px solid #e0e0e0;
  font-size: 12px;
  width: 14.285714%; /* 100% / 7 días = 14.285714% */
}

.calendar-table td {
  padding: 8px 4px;
  text-align: center;
  border: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  height: 40px;
  width: 14.285714%; /* 100% / 7 días = 14.285714% */
  vertical-align: middle;
  font-size: 13px;
}

.calendar-table td:hover {
  background: #f9f9f9;
}

.calendar-table td.other-month {
  color: #ccc;
  background: #fafafa;
}

.calendar-table td.today {
  background: var(--event-primary-color) !important;
  font-weight: 600;
  color: #fff !important;
}

/* Puntito indicador de eventos */
.calendar-table td.has-events::after {
  content: "•";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
}

/* Día de hoy SIN eventos - fondo azul WordPress */
.calendar-table td.today:not(.has-events) {
  background: var(--event-primary-color) !important;
  color: #fff !important;
}

/* Día de hoy CON eventos - fondo naranja clarito */
.calendar-table td.today.has-events {
  background: color-mix(in srgb, var(--event-ongoing-color) 25%, white) !important;
  color: var(--event-ongoing-color) !important;
  font-weight: 700;
}

.calendar-table td.today.has-events::after {
  color: var(--event-ongoing-color);
  opacity: 1;
}

/* Días con eventos próximos - sin fondo por defecto */
.calendar-table td.has-events.upcoming {
  color: #333;
}

.calendar-table td.has-events.upcoming::after {
  color: var(--event-upcoming-color);
}

/* Días con eventos en curso - sin fondo por defecto */
.calendar-table td.has-events.ongoing {
  color: #333;
}

.calendar-table td.has-events.ongoing::after {
  color: var(--event-ongoing-color);
}

/* Días con eventos pasados */
.calendar-table td.has-events.past {
  background: color-mix(in srgb, var(--event-past-color) 15%, white);
  color: var(--event-past-color);
}

.calendar-table td.has-events.past::after {
  color: var(--event-past-color);
}

/* Día seleccionado (al hacer clic) - color azul WordPress */
.calendar-table td.selected {
  background: var(--event-primary-color) !important;
  color: #fff !important;
}

.calendar-table td.selected::after {
  color: #fff !important;
}

/* ============================================
   LISTA DE EVENTOS
   ============================================ */

.events-list-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.events-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
  gap: 20px;
}

.events-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  color: #333;
  flex: 1;
}

.events-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 15px;
  min-width: 280px;
  transition: all 0.3s ease;
}

.events-search-box:focus-within {
  background: #fff;
  border-color: var(--event-primary-color);
  box-shadow: 0 0 0 2px
    color-mix(in srgb, var(--event-primary-color) 10%, white);
}

.events-search-box .dashicons {
  color: #666;
  font-size: 20px;
  width: 20px;
  height: 20px;
}

#event-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  flex: 1;
  padding: 0;
}

#event-search-input::placeholder {
  color: #999;
}

/* ============================================
   MODOS DE VISUALIZACIÓN
   ============================================ */

/* Modo Grid */
.events-grid.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
}

/* Modo Lista */
.events-grid.list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.events-grid.list .event-card {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 20px;
}

.events-grid.list .event-thumbnail {
  margin-bottom: 0;
  height: 100%;
  min-height: 180px;
}

/* ============================================
   TARJETA DE EVENTO
   ============================================ */

.event-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.event-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* Insignia de estado del evento */
.event-status-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  width: auto;
  white-space: nowrap;
}

.events-grid.list .event-status-badge {
  left: 15px;
  right: auto;
}

.event-card.upcoming .event-status-badge {
  background: color-mix(in srgb, var(--event-upcoming-color) 20%, white);
  color: var(--event-upcoming-color);
}

.event-card.ongoing .event-status-badge {
  background: color-mix(in srgb, var(--event-ongoing-color) 20%, white);
  color: var(--event-ongoing-color);
}

.event-card.past .event-status-badge {
  background: color-mix(in srgb, var(--event-past-color) 20%, white);
  color: var(--event-past-color);
}

/* Insignia de evento recurrente */
.event-recurring-badge {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(33, 113, 177, 0.95);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: help;
}

.event-recurring-indicator {
  display: inline-block;
  margin-left: 8px;
  font-size: 16px;
  cursor: help;
  vertical-align: middle;
}

/* Miniatura del evento */
.event-thumbnail {
  width: 100%;
  height: 200px;
  overflow: hidden;
  margin-bottom: 15px;
  cursor: pointer;
  position: relative;
}

.event-thumbnail a {
  display: block;
  width: 100%;
  height: 100%;
}

.event-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.event-card:hover .event-thumbnail img {
  transform: scale(1.05);
}

/* Contenido de la tarjeta */
.event-content {
  padding: 20px;
}

.event-title {
  margin: 0 0 15px 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}

.event-title a {
  color: #333;
  text-decoration: none;
  transition: color 0.2s ease;
}

.event-title a:hover {
  color: #2271b1;
}

.event-excerpt {
  color: #666;
  line-height: 1.6;
  font-size: 14px;
  margin-bottom: 15px;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
}

.event-meta > div {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #666;
}

.event-meta .dashicons {
  color: var(--event-primary-color);
  font-size: 18px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============================================
   PAGINACIÓN
   ============================================ */

.events-pagination {
  margin-top: 40px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.events-pagination span[aria-current="page"],
.events-pagination a.page-link-ajax,
.events-pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-decoration: none;
  color: #333;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
  cursor: pointer;
  box-sizing: border-box;
}

.events-pagination a:hover {
  background: #f5f5f5;
  border-color: var(--event-primary-color);
  color: var(--event-primary-color);
}

.events-pagination span[aria-current="page"] {
  background: var(--event-primary-color);
  border-color: var(--event-primary-color);
  color: #fff;
  cursor: default;
}

.events-pagination span.dots {
  cursor: default;
  pointer-events: none;
}

.events-pagination span.dots:hover {
  background: #fff;
  border-color: #ddd;
  color: #333;
}

.events-pagination a span.dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.events-pagination a:has(span.dashicons) {
  min-width: 32px;
  padding: 0;
}

/* Estados de carga */
.events-grid.loading {
  opacity: 0.5;
  pointer-events: none;
}

.events-loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.events-loading .dashicons {
  font-size: 32px;
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   MENSAJE SIN EVENTOS
   ============================================ */

.no-events-message {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.no-events-message .dashicons {
  font-size: 64px;
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.no-events-message p {
  font-size: 18px;
  margin: 0;
}

/* ============================================
   DISEÑO RESPONSIVE
   ============================================ */

@media screen and (max-width: 768px) {
  .event-manager-container {
    max-width: 90%;
    padding: 10px;
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .event-calendar-section {
    position: static;
  }

  .events-list-section {
    padding: 20px 10px;
  }

  .events-grid.grid {
    grid-template-columns: 1fr;
  }

  .events-grid.list .event-card {
    grid-template-columns: 1fr;
  }

  .calendar-month-year {
    font-size: 16px;
  }

  .calendar-table td {
    height: 35px;
    padding: 5px 2px;
    font-size: 12px;
  }

  .calendar-table th {
    font-size: 11px;
  }

  .events-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .events-header h2 {
    font-size: 22px;
  }

  .events-search-box {
    width: calc(100% - 20px);
    min-width: auto;
  }
}
