/**
 * Cal.pub Calendar Styles
 * Clean, modern, mobile-first calendar views
 *
 * Design principles:
 * - Minimal, uncluttered interface
 * - High contrast, readable typography
 * - Smooth transitions
 * - Dark mode support
 * - WCAG 2.1 AA accessible
 */

/* ============================================
   CSS Custom Properties (Theme System)
   ============================================ */

:root {
  /* Colors - Light Mode */
  --calpub-bg: #ffffff;
  --calpub-bg-secondary: #f8fafc;
  --calpub-bg-hover: #f1f5f9;
  --calpub-border: #e2e8f0;
  --calpub-text: #1e293b;
  --calpub-text-muted: #64748b;
  --calpub-text-light: #94a3b8;

  /* Accent Colors */
  --calpub-primary: #3b82f6;
  --calpub-primary-hover: #2563eb;
  --calpub-primary-light: #dbeafe;
  --calpub-success: #10b981;
  --calpub-warning: #f59e0b;
  --calpub-danger: #ef4444;

  /* Event Category Colors */
  --calpub-yoga: #8b5cf6;
  --calpub-fitness: #f97316;
  --calpub-workshop: #06b6d4;
  --calpub-course: #84cc16;
  --calpub-meeting: #6366f1;

  /* Spacing */
  --calpub-space-xs: 0.25rem;
  --calpub-space-sm: 0.5rem;
  --calpub-space-md: 1rem;
  --calpub-space-lg: 1.5rem;
  --calpub-space-xl: 2rem;

  /* Typography */
  --calpub-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --calpub-font-mono: ui-monospace, 'SF Mono', monospace;
  --calpub-text-xs: 0.75rem;
  --calpub-text-sm: 0.875rem;
  --calpub-text-base: 1rem;
  --calpub-text-lg: 1.125rem;
  --calpub-text-xl: 1.25rem;
  --calpub-text-2xl: 1.5rem;

  /* Borders & Shadows */
  --calpub-radius-sm: 0.25rem;
  --calpub-radius: 0.5rem;
  --calpub-radius-lg: 0.75rem;
  --calpub-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --calpub-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  --calpub-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

  /* Transitions */
  --calpub-transition: 150ms ease;
}

/* Dark Mode */
[data-theme="dark"],
.calpub-dark {
  --calpub-bg: #0f172a;
  --calpub-bg-secondary: #1e293b;
  --calpub-bg-hover: #334155;
  --calpub-border: #334155;
  --calpub-text: #f1f5f9;
  --calpub-text-muted: #94a3b8;
  --calpub-text-light: #64748b;
  --calpub-primary-light: #1e3a5f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --calpub-bg: #0f172a;
    --calpub-bg-secondary: #1e293b;
    --calpub-bg-hover: #334155;
    --calpub-border: #334155;
    --calpub-text: #f1f5f9;
    --calpub-text-muted: #94a3b8;
    --calpub-text-light: #64748b;
    --calpub-primary-light: #1e3a5f;
  }
}

/* ============================================
   Base Styles
   ============================================ */

.calpub-calendar {
  font-family: var(--calpub-font);
  color: var(--calpub-text);
  background: var(--calpub-bg);
  border-radius: var(--calpub-radius-lg);
  border: 1px solid var(--calpub-border);
  overflow: hidden;
}

/* ============================================
   Calendar Header
   ============================================ */

.calpub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--calpub-space-md) var(--calpub-space-lg);
  background: var(--calpub-bg-secondary);
  border-bottom: 1px solid var(--calpub-border);
}

.calpub-header__title {
  font-size: var(--calpub-text-xl);
  font-weight: 600;
  margin: 0;
}

.calpub-header__nav {
  display: flex;
  gap: var(--calpub-space-sm);
}

.calpub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--calpub-space-sm) var(--calpub-space-md);
  font-size: var(--calpub-text-sm);
  font-weight: 500;
  color: var(--calpub-text);
  background: var(--calpub-bg);
  border: 1px solid var(--calpub-border);
  border-radius: var(--calpub-radius);
  cursor: pointer;
  transition: all var(--calpub-transition);
}

.calpub-btn:hover {
  background: var(--calpub-bg-hover);
  border-color: var(--calpub-text-muted);
}

.calpub-btn--primary {
  color: white;
  background: var(--calpub-primary);
  border-color: var(--calpub-primary);
}

.calpub-btn--primary:hover {
  background: var(--calpub-primary-hover);
}

.calpub-btn--icon {
  padding: var(--calpub-space-sm);
  min-width: 2.5rem;
}

/* View Switcher */
.calpub-view-switcher {
  display: flex;
  background: var(--calpub-bg);
  border: 1px solid var(--calpub-border);
  border-radius: var(--calpub-radius);
  overflow: hidden;
}

.calpub-view-switcher__btn {
  padding: var(--calpub-space-sm) var(--calpub-space-md);
  font-size: var(--calpub-text-sm);
  font-weight: 500;
  color: var(--calpub-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--calpub-transition);
}

.calpub-view-switcher__btn:hover {
  color: var(--calpub-text);
  background: var(--calpub-bg-hover);
}

.calpub-view-switcher__btn--active {
  color: var(--calpub-primary);
  background: var(--calpub-primary-light);
}

/* ============================================
   Month View
   ============================================ */

.calpub-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calpub-month__weekday {
  padding: var(--calpub-space-sm) var(--calpub-space-xs);
  font-size: var(--calpub-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--calpub-text-muted);
  text-align: center;
  background: var(--calpub-bg-secondary);
  border-bottom: 1px solid var(--calpub-border);
}

.calpub-month__day {
  min-height: 100px;
  padding: var(--calpub-space-xs);
  border-right: 1px solid var(--calpub-border);
  border-bottom: 1px solid var(--calpub-border);
  transition: background var(--calpub-transition);
}

.calpub-month__day:nth-child(7n) {
  border-right: none;
}

.calpub-month__day:hover {
  background: var(--calpub-bg-hover);
}

.calpub-month__day--other-month {
  background: var(--calpub-bg-secondary);
  opacity: 0.6;
}

.calpub-month__day--today {
  background: var(--calpub-primary-light);
}

.calpub-month__day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  font-size: var(--calpub-text-sm);
  font-weight: 500;
  border-radius: 50%;
}

.calpub-month__day--today .calpub-month__day-number {
  color: white;
  background: var(--calpub-primary);
}

/* ============================================
   Week View
   ============================================ */

.calpub-week {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
}

.calpub-week__time-col {
  border-right: 1px solid var(--calpub-border);
}

.calpub-week__time-slot {
  height: 60px;
  padding: var(--calpub-space-xs);
  font-size: var(--calpub-text-xs);
  color: var(--calpub-text-muted);
  text-align: right;
  border-bottom: 1px solid var(--calpub-border);
}

.calpub-week__day-col {
  border-right: 1px solid var(--calpub-border);
  position: relative;
}

.calpub-week__day-col:last-child {
  border-right: none;
}

.calpub-week__day-header {
  padding: var(--calpub-space-sm);
  text-align: center;
  background: var(--calpub-bg-secondary);
  border-bottom: 1px solid var(--calpub-border);
}

.calpub-week__day-name {
  font-size: var(--calpub-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--calpub-text-muted);
}

.calpub-week__day-date {
  font-size: var(--calpub-text-lg);
  font-weight: 600;
}

.calpub-week__hour-slot {
  height: 60px;
  border-bottom: 1px solid var(--calpub-border);
}

/* ============================================
   Day View
   ============================================ */

.calpub-day {
  display: grid;
  grid-template-columns: 60px 1fr;
}

.calpub-day__header {
  grid-column: span 2;
  padding: var(--calpub-space-lg);
  text-align: center;
  background: var(--calpub-bg-secondary);
  border-bottom: 1px solid var(--calpub-border);
}

.calpub-day__title {
  font-size: var(--calpub-text-2xl);
  font-weight: 600;
  margin: 0;
}

.calpub-day__subtitle {
  font-size: var(--calpub-text-sm);
  color: var(--calpub-text-muted);
  margin-top: var(--calpub-space-xs);
}

/* ============================================
   List View
   ============================================ */

.calpub-list {
  padding: var(--calpub-space-md);
}

.calpub-list__date-group {
  margin-bottom: var(--calpub-space-lg);
}

.calpub-list__date-header {
  display: flex;
  align-items: center;
  gap: var(--calpub-space-md);
  padding: var(--calpub-space-sm) 0;
  margin-bottom: var(--calpub-space-sm);
  border-bottom: 2px solid var(--calpub-border);
}

.calpub-list__date-day {
  font-size: var(--calpub-text-2xl);
  font-weight: 700;
  color: var(--calpub-primary);
}

.calpub-list__date-info {
  font-size: var(--calpub-text-sm);
  color: var(--calpub-text-muted);
}

/* ============================================
   Event Cards
   ============================================ */

.calpub-event {
  display: flex;
  gap: var(--calpub-space-sm);
  padding: var(--calpub-space-sm);
  margin-bottom: var(--calpub-space-xs);
  background: var(--calpub-bg);
  border-radius: var(--calpub-radius);
  border-left: 3px solid var(--calpub-primary);
  cursor: pointer;
  transition: all var(--calpub-transition);
}

.calpub-event:hover {
  background: var(--calpub-bg-hover);
  box-shadow: var(--calpub-shadow-sm);
  transform: translateX(2px);
}

.calpub-event--yoga { border-left-color: var(--calpub-yoga); }
.calpub-event--fitness { border-left-color: var(--calpub-fitness); }
.calpub-event--workshop { border-left-color: var(--calpub-workshop); }
.calpub-event--course { border-left-color: var(--calpub-course); }
.calpub-event--meeting { border-left-color: var(--calpub-meeting); }

.calpub-event__time {
  flex-shrink: 0;
  font-size: var(--calpub-text-xs);
  font-weight: 600;
  color: var(--calpub-text-muted);
  font-family: var(--calpub-font-mono);
}

.calpub-event__content {
  flex: 1;
  min-width: 0;
}

.calpub-event__title {
  font-size: var(--calpub-text-sm);
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calpub-event__meta {
  font-size: var(--calpub-text-xs);
  color: var(--calpub-text-muted);
  margin-top: 2px;
}

/* Event Card - Expanded (List View) */
.calpub-event--expanded {
  padding: var(--calpub-space-md);
  border: 1px solid var(--calpub-border);
  border-left-width: 4px;
}

.calpub-event--expanded .calpub-event__title {
  font-size: var(--calpub-text-base);
}

.calpub-event--expanded .calpub-event__description {
  font-size: var(--calpub-text-sm);
  color: var(--calpub-text-muted);
  margin-top: var(--calpub-space-sm);
  line-height: 1.5;
}

.calpub-event__actions {
  display: flex;
  gap: var(--calpub-space-sm);
  margin-top: var(--calpub-space-md);
}

/* ============================================
   Mini Event (Month View)
   ============================================ */

.calpub-mini-event {
  display: block;
  padding: 2px var(--calpub-space-xs);
  margin-bottom: 2px;
  font-size: var(--calpub-text-xs);
  font-weight: 500;
  color: white;
  background: var(--calpub-primary);
  border-radius: var(--calpub-radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity var(--calpub-transition);
}

.calpub-mini-event:hover {
  opacity: 0.85;
}

.calpub-mini-event--yoga { background: var(--calpub-yoga); }
.calpub-mini-event--fitness { background: var(--calpub-fitness); }
.calpub-mini-event--workshop { background: var(--calpub-workshop); }
.calpub-mini-event--course { background: var(--calpub-course); }
.calpub-mini-event--meeting { background: var(--calpub-meeting); }

.calpub-more-events {
  font-size: var(--calpub-text-xs);
  color: var(--calpub-text-muted);
  padding: 2px var(--calpub-space-xs);
  cursor: pointer;
}

.calpub-more-events:hover {
  color: var(--calpub-primary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .calpub-header {
    flex-direction: column;
    gap: var(--calpub-space-md);
  }

  .calpub-month__day {
    min-height: 60px;
  }

  .calpub-month__weekday {
    font-size: 0.65rem;
  }

  .calpub-mini-event {
    font-size: 0.65rem;
    padding: 1px 2px;
  }

  /* Hide week view on mobile, show list instead */
  .calpub-week {
    display: none;
  }
}

/* ============================================
   Loading & Empty States
   ============================================ */

.calpub-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--calpub-space-xl);
  color: var(--calpub-text-muted);
}

.calpub-empty {
  text-align: center;
  padding: var(--calpub-space-xl);
  color: var(--calpub-text-muted);
}

.calpub-empty__icon {
  font-size: 3rem;
  margin-bottom: var(--calpub-space-md);
  opacity: 0.5;
}

.calpub-empty__text {
  font-size: var(--calpub-text-sm);
}

/* ============================================
   Utilities
   ============================================ */

.calpub-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
