/**
 * Event Modal Styles
 * イベント詳細モーダルのスタイル - レスポンシブ対応
 */

/* Modal Base */
.event-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  pointer-events: none;
}

.event-modal.is-open {
  display: block;
  pointer-events: auto;
}

/* Overlay */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.event-modal.is-open .modal-overlay {
  opacity: 1;
}

/* Container */
.modal-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
}

/* Content */
.modal-content {
  position: relative;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--color-surface, #ffffff);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: translateY(30px) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.event-modal.is-open .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.event-modal.is-closing .modal-content {
  transform: translateY(30px) scale(0.95);
  opacity: 0;
}

/* Close Button */
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--color-surface-variant, #f5f5f5);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close:hover {
  background: var(--color-error, #ef4444);
  color: white;
  transform: scale(1.1);
}

.modal-close:focus {
  outline: 2px solid var(--color-primary, #22c55e);
  outline-offset: 2px;
}

/* Header */
.modal-header {
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.event-status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  margin-bottom: 0.5rem;
}

.status-upcoming {
  background: #dbeafe;
  color: #1e40af;
}

.status-ongoing {
  background: #fef3c7;
  color: #92400e;
}

.status-past {
  background: #e5e7eb;
  color: #4b5563;
}

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text-primary, #1f2937);
  line-height: 1.2;
}

.event-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
}

/* Tabs (Mobile) */
.modal-tabs {
  display: none;
  padding: 0 1rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-button {
  flex: 1;
  padding: 1rem;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.tab-button.active {
  color: var(--color-primary, #22c55e);
}

.tab-button::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-primary, #22c55e);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.tab-button.active::after {
  transform: scaleX(1);
}

/* Body */
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  -webkit-overflow-scrolling: touch;
}

/* Sections */
.modal-section {
  display: none;
}

.modal-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Overview Grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.overview-item {
  display: flex;
  gap: 1rem;
}

.overview-icon {
  font-size: 2rem;
  line-height: 1;
}

.overview-content h4 {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary, #6b7280);
}

.overview-content p {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary, #1f2937);
}

/* Details Content */
.detail-content h3 {
  margin: 2rem 0 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary, #1f2937);
}

.detail-content h3:first-child {
  margin-top: 0;
}

.event-description,
.event-notes {
  line-height: 1.6;
  color: var(--color-text-secondary, #4b5563);
}

/* Schedule */
.schedule-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border, #f3f4f6);
}

.schedule-item:last-child {
  border-bottom: none;
}

.schedule-time {
  min-width: 80px;
  font-weight: 600;
  color: var(--color-primary, #22c55e);
}

.schedule-content {
  flex: 1;
  color: var(--color-text-primary, #1f2937);
}

/* Participation */
.participation-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--color-surface-variant, #f9fafb);
  border-radius: 12px;
}

.stat-item {
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary, #22c55e);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
}

.participation-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.contact-info {
  padding: 1.5rem;
  background: var(--color-surface-variant, #f9fafb);
  border-radius: 8px;
  text-align: center;
}

.contact-info h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Footer */
.modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--color-border, #e5e7eb);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.footer-actions {
  margin-left: auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary, #22c55e);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-dark, #16a34a);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-secondary {
  background: var(--color-secondary, #64748b);
  color: white;
}

.btn-secondary:hover {
  background: var(--color-secondary-dark, #475569);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-border, #e5e7eb);
  color: var(--color-text-primary, #1f2937);
}

.btn-outline:hover {
  border-color: var(--color-primary, #22c55e);
  color: var(--color-primary, #22c55e);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 1.25em;
}

/* Toast Notification */
.modal-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-text-primary, #1f2937);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 10000;
}

.modal-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Dark Mode Support */
[data-theme="dark"] .modal-content {
  background: var(--color-surface-dark, #1f2937);
  color: var(--color-text-primary-dark, #f9fafb);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: var(--color-border-dark, #374151);
}

[data-theme="dark"] .event-status-badge {
  filter: brightness(0.8);
}

[data-theme="dark"] .modal-close {
  background: var(--color-surface-variant-dark, #374151);
  color: var(--color-text-primary-dark, #f9fafb);
}

[data-theme="dark"] .btn-outline {
  border-color: var(--color-border-dark, #4b5563);
  color: var(--color-text-primary-dark, #f9fafb);
}

/* Mobile Styles */
@media (max-width: 767px) {
  .modal-container {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .event-modal.is-open .modal-content {
    transform: translateY(0);
  }

  .event-modal.is-closing .modal-content {
    transform: translateY(100%);
  }

  /* Compact mode */
  .event-modal.compact-mode .modal-header {
    padding: 1.5rem 1.5rem 1rem;
  }

  .event-modal.compact-mode .modal-title {
    font-size: 1.5rem;
    padding-right: 2rem;
  }

  .event-modal.compact-mode .modal-body {
    padding: 0 1.5rem 1.5rem;
  }

  .event-modal.compact-mode .modal-footer {
    display: none;
  }

  .event-modal.compact-mode .modal-tabs {
    display: flex;
  }

  .event-modal.compact-mode .modal-section {
    display: none;
  }

  .event-modal.compact-mode .modal-section.active {
    display: block;
  }

  .overview-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .participation-stats {
    gap: 1rem;
    padding: 1rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .participation-actions {
    padding: 0 1rem;
  }

  /* Swipe indicator */
  .modal-content::before {
    content: "";
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--color-border, #e5e7eb);
    border-radius: 2px;
  }
}

/* Tablet Styles */
@media (min-width: 768px) and (max-width: 1023px) {
  .modal-content {
    max-width: 700px;
  }

  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop Styles */
@media (min-width: 1024px) {
  /* Show all sections on desktop */
  .modal-tabs {
    display: none !important;
  }

  .modal-section {
    display: block !important;
    margin-bottom: 3rem;
  }

  .modal-section:last-child {
    margin-bottom: 0;
  }

  .modal-body {
    padding: 2rem 3rem;
  }

  .modal-header {
    padding: 2.5rem 3rem 2rem;
  }

  .modal-footer {
    padding: 2rem 3rem;
  }

  .overview-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
  }

  .participation-actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid var(--color-primary, #22c55e);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-content,
  .modal-section,
  .tab-button::after,
  .btn {
    transition: none !important;
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .modal-overlay {
    background: rgba(0, 0, 0, 0.9);
  }

  .modal-content {
    border: 3px solid var(--color-text, #000);
    background: var(--color-background, #fff);
    color: var(--color-text, #000);
  }

  .tab-button {
    border: 2px solid var(--color-text, #000);
  }

  .tab-button:focus {
    outline: 3px solid var(--color-primary, #22c55e);
    outline-offset: 2px;
  }

  .btn {
    border: 2px solid var(--color-text, #000);
  }
}

/* Enhanced transition control */
.modal-timeout-indicator {
  position: absolute;
  top: 1rem;
  right: 4rem;
  width: 4px;
  height: 4px;
  background: var(--color-warning, #f59e0b);
  border-radius: 50%;
  animation: pulse 2s infinite;
  transition-duration: 0.3s;
  transition-timing-function: ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Timeout control for transitions */
.modal-content,
.modal-overlay,
.modal-section {
  transition-duration: var(--modal-transition-duration, 0.3s);
  transition-timing-function: var(--modal-transition-timing, cubic-bezier(0.4, 0, 0.2, 1));
}

.modal-content {
  --modal-timeout: 5000ms;
}

@supports (transition-behavior: allow-discrete) {
  .modal-content {
    transition-behavior: allow-discrete;
  }
}

/* Visited links support */
.event-contact a:visited {
  color: var(--color-primary-dark, #16a34a);
}

.modal-section a:visited {
  color: var(--color-primary-dark, #16a34a);
}
