/**
 * Responsive styles for mobile devices - Enhanced minimalist design 2025
 */

@media screen and (max-width: 768px) {
  /* Main container */
  .jsm-event-calendar-wrapper {
    border-radius: var(--border-radius-md);
    margin-bottom: 1.5rem;
  }

  /* Calendar navigation */
  .jsm-event-calendar-nav {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem 0.75rem;
  }

  .jsm-event-calendar-title {
    font-size: 1.25rem;
    text-align: center;
  }

  .jsm-event-calendar-nav-buttons {
    width: 100%;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  
  .jsm-event-calendar-nav-buttons::-webkit-scrollbar {
    display: none;
  }
  
  .jsm-event-calendar-view-switcher,
  .jsm-event-calendar-nav-main-buttons {
    width: 100%;
    justify-content: center;
  }

  .jsm-event-calendar-nav-button {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--button-radius);
    flex-shrink: 0;
    min-width: 70px;
  }

  /* Alternative display for mobile - list view instead of table */
  .jsm-mobile-view .jsm-event-calendar-table {
    display: none;
  }

  .jsm-event-calendar-list-view {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day {
    padding: 1rem;
    border-radius: var(--border-radius-md);
    min-height: auto;
    height: auto;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.5rem;
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day.empty {
    display: none;
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day-number {
    margin: 0;
    width: auto;
    height: auto;
    text-align: left;
    font-size: 1rem;
    background: none;
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day.today .jsm-event-calendar-day-number {
    background: none;
    color: var(--primary-color);
    font-weight: 700;
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-day-name {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
  }

  .jsm-event-calendar-list-view .jsm-event-calendar-event {
    margin-bottom: 0.5rem;
    white-space: normal;
    text-overflow: ellipsis;
    line-height: 1.4;
    border-radius: var(--border-radius-sm);
  }

  /* Table calendar on small screens - hide most elements */
  .jsm-event-calendar-table-wrapper {
    padding: 0.75rem;
  }

  .jsm-event-calendar-table {
    border-spacing: 0.375rem;
  }

  .jsm-event-calendar-table th {
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
  }

  .jsm-event-calendar-table td {
    height: auto;
  }

  .jsm-event-calendar-day {
    min-height: 5rem;
    height: auto;
    padding: 0.375rem;
  }

  .jsm-event-calendar-day.empty {
    min-height: auto;
  }

  .jsm-event-calendar-day-number {
    font-size: 0.75rem;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1.5rem;
  }

  .jsm-event-calendar-event {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
  }

  .jsm-event-calendar-event:hover {
    white-space: normal;
    z-index: 10;
  }

  /* Event list */
  .jsm-event-list {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0 0.75rem 0.75rem;
  }

  .jsm-event-list-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .jsm-event-list-item-header {
    padding: 1rem 1rem 0.5rem;
  }

  .jsm-event-list-item-title {
    font-size: 1.125rem;
  }

  .jsm-event-list-item-date {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--button-radius);
  }

  .jsm-event-list-item-content {
    padding: 0 1rem;
    font-size: 0.875rem;
  }

  .jsm-event-list-item-footer {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .jsm-event-button {
    width: 100%;
    justify-content: center;
    border-radius: var(--button-radius);
  }

  /* Modal window for event detail - FIXED for proper mobile display */
  .jsm-event-modal {
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
  }

  .jsm-event-modal-content {
    width: 92%;
    max-width: 100%;
    max-height: 85vh;
    margin: 0 auto;
    padding: 1.25rem;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    background-color: var(--surface-color);
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-x: hidden;
  }

  .jsm-event-detail-title {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    width: 90%;
  }

  .jsm-event-detail-meta {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .jsm-event-detail-date,
  .jsm-event-detail-time {
    width: 100%;
    border-radius: var(--button-radius);
  }

  .jsm-event-loading {
    padding: 2rem 1rem;
  }

  .jsm-event-loading-spinner {
    width: 2rem;
    height: 2rem;
  }

  /* Grid layout for event list */
  .jsm-event-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 0.75rem 0.75rem;
  }

  .jsm-event-grid-item-thumbnail {
    height: 8rem;
  }
}

/* Touch devices optimizations */
@media (hover: none) {
  .jsm-event-calendar-event,
  .jsm-event-button,
  .jsm-event-calendar-nav-button {
    cursor: default;
  }

  .jsm-event-calendar-event {
    white-space: normal;
    line-height: 1.4;
  }

  .jsm-event-calendar-nav-button,
  .jsm-event-button {
    -webkit-tap-highlight-color: transparent;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }

  .jsm-event-list-item:active,
  .jsm-event-grid-item:active,
  .jsm-event-calendar-event:active,
  .jsm-event-button:active {
    transform: scale(0.98);
  }
}

/* Extra small screens (small phones) */
@media screen and (max-width: 360px) {
  .jsm-event-calendar-nav-button {
    min-width: 60px;
    padding: 0.3125rem 0.5rem;
    font-size: 0.75rem;
  }
  
  .jsm-event-calendar-view-button {
    min-width: 50px;
    font-size: 0.6875rem;
  }
  
  .jsm-nav-buttons-vertical {
    gap: 0.25rem;
  }
}

/* Medium screens (tablets) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .jsm-event-list {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 1rem 1rem;
  }

  .jsm-event-calendar-day {
    min-height: 6.5rem;
    padding: 0.625rem;
  }

  .jsm-event-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 1rem 1rem;
  }

  /* Improvements for event readability on tablets */
  .jsm-event-calendar-event:hover {
    position: absolute;
    width: auto;
    max-width: 250px;
    z-index: 50;
    border-radius: var(--border-radius-sm);
  }

  /* Modal for tablets */
  .jsm-event-modal {
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
  }

  .jsm-event-modal-content {
    max-width: 80%;
    padding: 2rem;
    max-height: 80vh;
    margin: 0 auto;
    background-color: var(--surface-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);

  }
}

/* Enhancements for better event readability in calendar */
@media screen and (min-width: 1025px) {
  /* If there are more events in one day, increase cell height */
  .jsm-event-calendar-day:has(.jsm-event-calendar-event:nth-child(3)) {
    min-height: 9.5rem;
  }

  .jsm-event-calendar-day:has(.jsm-event-calendar-event:nth-child(4)) {
    min-height: 11rem;
  }

  /* Improvement for event readability on hover */
  .jsm-event-calendar-event:hover {
    position: absolute;
    width: auto;
    min-width: 200px;
    max-width: 300px;
    z-index: 50;
    border-radius: var(--border-radius-sm);
  }

  /* Airier design for desktop */
  .jsm-event-calendar-table-wrapper {
    padding: 1.5rem;
  }

  .jsm-event-calendar-table {
    border-spacing: 0.5rem;
  }

  /* Modal for desktop */
  .jsm-event-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 0;
  }

  .jsm-event-modal-content {
    width: 600px;
    max-width: 90%;
    max-height: 85vh;
    background-color: var(--surface-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    margin: 0 auto;
    position: relative;
    overflow-y: auto;
    box-sizing: border-box;
    word-wrap: break-word
    overflow-x: hidden;
  }
}
