#kuaby-calendar { max-width: 900px; margin: 20px auto; padding: 0 10px; box-sizing: border-box; }

/* Modal: needs a high z-index in wp-admin too */
#kac-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  z-index: 100000; /* above WP admin menus */
}

#kac-modal .kac-modal-content {
  background: #fff;
  margin: 5% auto;
  padding: 20px;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  z-index: 100001;
  border-radius: 6px;
}

/* Mobile: make the calendar readable and avoid distortion */
@media (max-width: 768px), (max-device-width: 768px){
  #kuaby-calendar{ max-width: 100%; margin: 10px auto; padding: 0 8px; }

  /* Toolbar: stack buttons and shrink typography */
  #kuaby-calendar .fc .fc-toolbar{
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    flex-wrap: wrap;
  }
  /* Title/date text (force override: some themes enlarge it on mobile) */
  #kuaby-calendar .fc .fc-toolbar-title,
  #kuaby-calendar .fc-toolbar-title{ font-size: 11px !important; line-height: 1.15 !important; }
  /* Compact buttons */
  #kuaby-calendar .fc .fc-button,
  #kuaby-calendar .fc-button{
    padding: 3px 5px !important;
    font-size: 10px !important;
    line-height: 1.1 !important;
    min-height: 28px !important;
  }
  /* Compact icons (prev/next arrows) */
  #kuaby-calendar .fc .fc-button .fc-icon{ font-size: 1em !important; }

  #kuaby-calendar .fc .fc-toolbar-chunk{ display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }

  /* View buttons (Lista/Mese) in a compact row with wrap (avoid full-width buttons) */
  #kuaby-calendar .fc .fc-toolbar-chunk:last-child{
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  #kuaby-calendar .fc .fc-toolbar-chunk:last-child .fc-button-group{
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
  }
  #kuaby-calendar .fc .fc-toolbar-chunk:last-child .fc-button-group .fc-button{
    width: auto;
  }

  /* Month grid events: truncate nicely when the grid is shown */
  #kuaby-calendar .fc-daygrid-event{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #kuaby-calendar .fc-daygrid-day-number{ font-size: 12px !important; }
  #kuaby-calendar .fc-col-header-cell-cushion{ font-size: 12px !important; }

  /* List view: more readable lines */
  #kuaby-calendar .fc-list-event-title,
  #kuaby-calendar .fc-list-event-time{
    font-size: 13px !important;
  }

  /* Modal: fit small screens */
  #kac-modal .kac-modal-content{ max-width: 92vw; margin: 12% auto; max-height: 88vh; }
}

/* Extra-small phones */
@media (max-width: 420px), (max-device-width: 420px){
  #kuaby-calendar .fc .fc-toolbar-title,
  #kuaby-calendar .fc-toolbar-title{ font-size: 10px !important; }
  #kuaby-calendar .fc .fc-button,
  #kuaby-calendar .fc-button{ padding: 2px 4px !important; font-size: 9px !important; min-height: 26px !important; }
}

/* ---- Time fields (modal): prevent iOS native time picker UI issues by using selects on mobile ---- */
.kac-time-selects{ display:none; align-items:center; gap:6px; }
.kac-time-hour, .kac-time-min{ padding: 4px 6px; }
.kac-time-sep{ opacity: 0.8; }

@media (max-width: 768px), (max-device-width: 768px){
  /* Hide native time input on mobile (it opens the iOS picker with buttons that may overflow) */
  .kac-time-native{ display:none !important; }
  .kac-time-selects{ display:inline-flex !important; }
}

/* Custom event content (frontend + admin)
   This avoids theme CSS that sometimes hides FullCalendar default title/time nodes.
*/
#kuaby-calendar .kac-evt{ display:block; }
#kuaby-calendar .kac-evt-user{ font-size: 11px; line-height: 1.1; opacity: 0.9; }
#kuaby-calendar .kac-evt-main{ display:flex; gap:6px; align-items: baseline; }
#kuaby-calendar .kac-evt-time{ font-weight: 600; white-space: nowrap; }
#kuaby-calendar .kac-evt-title{ overflow:hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Month grid: ensure the block has a readable height and padding (some themes shrink events to a thin line) */
#kuaby-calendar .fc-daygrid-event .kac-evt{
  padding: 2px 4px;
  font-size: 12px;
  line-height: 1.2;
}

/* List view: keep the line compact and readable */
#kuaby-calendar .fc-list-event .kac-evt-main{ display:block; }
#kuaby-calendar .fc-list-event .kac-evt-time{ display:inline-block; margin-right: 6px; }
#kuaby-calendar .fc-list-event .kac-evt-title{ display:inline; white-space: normal; }

.kac-close { position:absolute; top:10px; right:10px; cursor:pointer; }

#kac-register-form, #kac-login-form, #kac-event-form { display: flex; flex-direction: column; }
#kac-event-form p { margin-bottom:10px; }

#kac-modal-msg { margin-top: 8px; }

/* Admin responsiveness (Users table) */
.kac-table-wrap{
  max-width: 100%;
  overflow-x: auto;
}
.kac-users-table{
  width: 100%;
  table-layout: fixed;
}
.kac-users-table th,
.kac-users-table td{
  word-break: break-word;
}
.kac-users-table input.regular-text{
  width: 100%;
  max-width: 100%;
  min-width: 120px;
  box-sizing: border-box;
}

/* FullCalendar (admin scope=all): show owner name above title */
.kac-fc-user{
  font-size: 11px;
  line-height: 1.1;
  opacity: 0.9;
}
.kac-fc-title{
  line-height: 1.2;
}

/* Color presets (modal) */
.kac-color-row { margin-bottom: 10px; }
.kac-color-row > label { display:block; margin-bottom:6px; }
.kac-color-controls { display: flex; flex-direction: column; gap: 10px; }
.kac-color-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.kac-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.25);
  padding: 0;
  cursor: pointer;
  background: #000;
}
.kac-color-swatch.is-active {
  outline: 2px solid rgba(0,0,0,0.9);
  outline-offset: 2px;
}
.kac-color-custom { display:flex; align-items: center; gap: 8px; }
.kac-color-custom input[type="color"] { width: 46px; height: 30px; padding: 0; border: none; background: transparent; }




/* Password field with show/hide button */
.kac-pass-wrap{ display:flex; gap:8px; align-items:center; }
.kac-pass-wrap input{ flex:1; min-width: 0; }
.kac-toggle-pass{ padding: 6px 10px; border: 1px solid rgba(0,0,0,0.25); background: #f7f7f7; border-radius: 4px; cursor: pointer; }
.kac-toggle-pass:focus{ outline: 2px solid rgba(0,0,0,0.6); outline-offset: 2px; }

/* Small helpers for account forms */
#kac-forgot-toggle,
#kac-toggle-change-password{
  text-decoration: underline;
}

#kac-forgot-form,
#kac-change-password-wrap{
  border: 1px solid rgba(0,0,0,0.12);
  padding: 12px;
  border-radius: 6px;
  background: rgba(0,0,0,0.02);
}


/* Event visibility (Master) */
.kac-share-wrap{
  border: 1px solid rgba(0,0,0,0.12);
  padding: 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.02);
  margin-bottom: 10px;
}
.kac-users-checklist{
  max-height: 170px;
  overflow: auto;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}
.kac-user-check{
  display:flex;
  gap: 8px;
  align-items: center;
}
.kac-user-check span{
  font-size: 13px;
  line-height: 1.2;
}
@media (max-width: 480px){
  .kac-user-check span{ font-size: 12px; }
}

/* ---- Search bar (eventi) ---- */
.kac-calendar-toolbar{
  max-width: 900px;
  margin: 12px auto 0;
  padding: 0 10px;
  box-sizing: border-box;
}
.kac-searchbar{
  display: flex;
  gap: 8px;
  align-items: center;
}
.kac-searchbar input[type="search"]{
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.2;
}
#kac-event-search-clear{
  padding: 6px 10px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 8px;
  background: rgba(0,0,0,0.02);
  cursor: pointer;
}
.kac-search-count{
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
}

/* Highlight matches lightly */
#kuaby-calendar .kac-search-hit{
  box-shadow: 0 0 0 2px rgba(0,0,0,0.10) inset;
}

/* WP-like screen reader text (frontend safe) */
.screen-reader-text{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

@media (max-width: 768px), (max-device-width: 768px){
  .kac-calendar-toolbar{ padding: 0 8px; }
  .kac-searchbar input[type="search"]{ font-size: 12px; padding: 6px 8px; }
  #kac-event-search-clear{ padding: 5px 9px; }
  .kac-search-count{ font-size: 11px; }
}
