@import "pico-theme-KxJ0Fr6.css";

/* App shell : sidebar + contenu principal */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.app-shell--no-sidebar {
  grid-template-columns: 1fr;
}

.app-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-content > main.container {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
  max-width: none;
  width: 100%;
}

@media (max-width: 768px) {
  .app-content > main.container {
    padding: 1rem 1rem 1.5rem;
  }
}

.app-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--pico-muted-border-color);
  text-align: center;
  color: var(--pico-muted-color);
}

/* Sidebar */
.sidebar {
  background: var(--pico-card-background-color);
  border-right: 1px solid var(--pico-muted-border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  font-size: 1.05rem;
}

.sidebar-brand-icon {
  font-size: 1.4rem;
}

.sidebar-close {
  display: none;
  background: transparent;
  border: 0;
  color: var(--pico-muted-color);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  width: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  margin: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: var(--pico-color);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus-visible {
  background: var(--pico-secondary-background);
  color: var(--pico-color);
}

.sidebar-nav a.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-left-color: var(--pico-primary);
  font-weight: 600;
}

.sidebar-icon {
  display: inline-flex;
  width: 1.5rem;
  justify-content: center;
  font-size: 1.05rem;
}

.sidebar-section-title {
  padding: 1rem 1rem 0.4rem;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--pico-del-color, #c0392b);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-footer {
  border-top: 1px solid var(--pico-muted-border-color);
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  color: var(--pico-muted-color);
  font-size: 0.85rem;
}

.sidebar-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  color: var(--pico-color);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-footer-link:hover,
.sidebar-footer-link:focus-visible {
  background: var(--pico-secondary-background);
  color: var(--pico-color);
}

.sidebar-footer-link.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-left-color: var(--pico-primary);
  font-weight: 600;
}

.sidebar-footer-link--danger {
  color: var(--pico-del-color, #c0392b);
}

.sidebar-footer-link--danger:hover {
  color: #fff;
  background: var(--pico-del-color, #c0392b);
}

/* Topbar : mobile only quand logged, sinon public */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--pico-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar--mobile {
  display: none;
  justify-content: space-between;
}

.topbar--public {
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-brand {
  font-size: 1.1rem;
}

.topbar-spacer {
  width: 2rem;
}

.topbar-theme {
  padding: 0.4rem 0.7rem;
  width: auto;
  margin: 0;
}

/* Bouton Ajouter dans la sidebar */
.sidebar-actions {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.sidebar-add {
  margin: 0;
}

.sidebar-add > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border: 0;
  border-radius: var(--pico-border-radius);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.sidebar-add > summary::-webkit-details-marker {
  display: none;
}

.sidebar-add > summary::after {
  display: none;
}

.sidebar-add > summary:hover {
  background: var(--pico-primary-hover-background);
}

.sidebar-add ul {
  margin: 0.25rem 0 0;
}

.sidebar-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: var(--pico-color);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  width: auto;
  margin: 0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.sidebar-backdrop.open {
  display: block;
}

.impersonation-banner {
  background: #f59e0b;
  color: #000;
  padding: 0.5rem 1rem;
  text-align: center;
}

/* Mobile : sidebar en drawer + topbar visible */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 80vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .topbar--mobile {
    display: flex;
  }

  body.sidebar-locked {
    overflow: hidden;
  }
}

/* Calendrier */
.calendar-page {
  max-width: 1400px;
  margin: 0 auto;
}

.calendar-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.calendar-header h1 {
  margin-bottom: 1rem;
}

.calendar-nav {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.calendar-nav-btn,
.calendar-nav-today {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--pico-border-radius);
  text-decoration: none;
  font-size: 0.95rem;
  background: var(--pico-secondary-background);
  color: var(--pico-color);
  border: 1px solid var(--pico-muted-border-color);
}

.calendar-nav-today {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  border-color: var(--pico-primary-border);
  font-weight: 600;
}

.calendar-nav-btn:hover,
.calendar-nav-today:hover {
  filter: brightness(1.05);
}

.calendar-actions {
  margin: 0;
}

/* Grille mensuelle */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--pico-muted-border-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  overflow: hidden;
}

.weekday-header {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  padding: 0.6rem 0.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.calendar-day {
  background: var(--pico-card-background-color);
  min-height: 110px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.calendar-day.empty {
  background: var(--pico-background-color);
}

.calendar-day.today {
  outline: 2px solid var(--pico-primary);
  outline-offset: -2px;
}

.day-number {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--pico-color);
}

.calendar-day.today .day-number {
  color: var(--pico-primary);
}

.day-events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

/* Items événement (utilisés grille + agenda) */
.event-item {
  display: block;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--pico-color);
  background: var(--pico-secondary-background);
  border-left: 3px solid var(--pico-muted-color);
  line-height: 1.3;
  transition: filter 0.15s ease;
}

.event-item:hover {
  filter: brightness(1.1);
}

.event-time {
  font-weight: 700;
  margin-right: 0.3rem;
}

.event-title {
  display: inline;
}

.event-event { border-left-color: #2196f3; }
.event-team_match { border-left-color: #4caf50; }
.event-tournament { border-left-color: #ff9800; }
.event-tournament_match { border-left-color: #9c27b0; }

[data-theme="light"] .event-event { background: #e3f2fd; }
[data-theme="light"] .event-team_match { background: #e8f5e9; }
[data-theme="light"] .event-tournament { background: #fff3e0; }
[data-theme="light"] .event-tournament_match { background: #f3e5f5; }

/* Vue agenda (mobile) */
.calendar-agenda {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.agenda-day {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

.agenda-day.today {
  border-left: 4px solid var(--pico-primary);
}

.agenda-day-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0;
  background: transparent;
  border: 0;
}

.agenda-day-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--pico-primary);
  line-height: 1;
}

.agenda-day-name {
  color: var(--pico-muted-color);
  font-size: 0.95rem;
}

.agenda-day-badge {
  margin-left: auto;
  background: var(--pico-primary);
  color: var(--pico-primary-inverse);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.agenda-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.agenda-events .event-item {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.agenda-events .event-title {
  display: block;
  font-weight: 600;
  margin-top: 0.1rem;
}

.event-details {
  display: block;
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  margin-top: 0.15rem;
}

.agenda-empty {
  text-align: center;
  color: var(--pico-muted-color);
  padding: 2rem 1rem;
  background: var(--pico-card-background-color);
  border-radius: var(--pico-border-radius);
}

/* Légende */
.calendar-legend {
  margin-top: 2rem;
  padding: 1rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

.calendar-legend strong {
  display: block;
  margin-bottom: 0.6rem;
}

.legend-items {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.legend-color {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--pico-secondary-background);
  border-left: 3px solid var(--pico-muted-color);
}

/* Mobile : agenda visible, grille cachée */
@media (max-width: 768px) {
  .calendar-grid {
    display: none;
  }

  .calendar-agenda {
    display: flex;
  }

  .calendar-nav-label {
    display: none;
  }

  .calendar-nav-btn {
    padding: 0.5rem 0.8rem;
  }
}

/* Page "événements à venir" - timeline */
.upcoming-page {
  max-width: 900px;
  margin: 0 auto;
}

.upcoming-page h1 {
  margin-bottom: 1.5rem;
}

.no-events {
  text-align: center;
  padding: 2rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  color: var(--pico-muted-color);
}

.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--pico-muted-border-color);
}

.timeline-date {
  margin: 1.5rem 0 0.75rem;
}

.timeline-date h3 {
  color: var(--pico-primary);
  font-size: 1.05rem;
  margin: 0;
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
  padding-left: 1.25rem;
}

.timeline-marker {
  position: absolute;
  left: -1.65rem;
  top: 0.5rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pico-muted-color);
  border: 2px solid var(--pico-background-color);
}

.timeline-event .timeline-marker { background: #2196f3; }
.timeline-team_match .timeline-marker { background: #4caf50; }
.timeline-tournament .timeline-marker { background: #ff9800; }
.timeline-tournament_match .timeline-marker { background: #9c27b0; }

.timeline-content {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
}

.timeline-time {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.timeline-title {
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.timeline-title a {
  color: var(--pico-color);
  text-decoration: none;
  font-weight: 600;
}

.timeline-title a:hover {
  color: var(--pico-primary);
}

.timeline-details {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge,
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--pico-secondary-background);
  color: var(--pico-color);
}

.badge {
  text-transform: uppercase;
}

.badge-event,
.status-scheduled { background: rgba(33, 150, 243, 0.18); color: #2196f3; }
.badge-team_match { background: rgba(76, 175, 80, 0.18); color: #4caf50; }
.badge-tournament,
.status-in_progress { background: rgba(255, 152, 0, 0.18); color: #ff9800; }
.badge-tournament_match { background: rgba(156, 39, 176, 0.18); color: #9c27b0; }
.status-completed,
.status-registration_open { background: rgba(76, 175, 80, 0.18); color: #4caf50; }

@media (max-width: 768px) {
  .timeline {
    padding-left: 1.25rem;
  }

  .timeline-item {
    padding-left: 0.75rem;
  }

  .timeline-marker {
    left: -1.4rem;
  }
}

/* Tablette : grille compacte */
@media (min-width: 769px) and (max-width: 1024px) {
  .calendar-day {
    min-height: 90px;
    padding: 0.3rem;
  }

  .event-item {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
  }

  .event-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--pico-muted-color); }

/* Danger button */
.btn-danger {
  background-color: #c0392b !important;
  border-color: #c0392b !important;
  color: #fff !important;
}
.btn-danger:hover,
.btn-danger:focus {
  background-color: #a93226 !important;
  border-color: #a93226 !important;
}

/* Form actions bar */
.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

/* Filters bar */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

.filters label {
  margin-bottom: 0;
  flex: 1;
  min-width: 150px;
}

.filters label:has(input[type="checkbox"]) {
  flex: 0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.filters button,
.filters a[role="button"] {
  flex: 0;
  white-space: nowrap;
}

/* Danger zone (delete area) */
.danger-zone {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--pico-muted-border-color);
  display: flex;
  justify-content: flex-end;
}
