/* static/css/schedule.css */

:root {
  --start-hour: 7;
  --end-hour:   17;
  --total-q:    40; /* (17–7)*4 */
  --site-header-height: 0px;
  --header-wrapper-height: 0px;
  --mobile-header-offset: 0px;
  --hour-height: 60px;
  --quarter-h: calc(var(--hour-height)/4);
  --gap-x: 8px;
  --gap-y: 4px;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #333;
  --header-bg: hsl(210,60%,50%);
  --header-text: #fff;
  --header-glow: hsl(210,60%,40%);
  --event-bg: hsl(210,80%,50%);
  --event-text: #fff;
  --event-border: rgba(0,0,0,0.2);
  --event-glow: hsl(210,80%,40%);
  --event-hover: hsl(210,80%,45%);
  --now-line: red;
  --running-glow: #4CAF50;
}

/* Dark mode override */
body.dark {
  --bg: #121212;
  --card-bg: #1e1e1e;
  --text: #f0f0f0;
}

/* Global resets */
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.header-wrapper {
  position: sticky;
  top: var(--site-header-height, 0px);
  left: 0;
  right: 0;
  width: 100%;
  background: var(--bg);
  z-index: 1500;
  margin: 0;
  padding: 0;  /* No padding! */
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
@media (max-width: 700px) {
  .header-wrapper {
    left: 0;
    right: 0;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }
}

/* Prevent main container from covering sticky header with horizontal scroll */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1rem 1rem 1rem;
  animation: fadeIn .3s ease-out;
  position: relative;
}

/* Toolbar buttons: bigger tap targets */
.toolbar-flex {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin: 0;
  padding: 0.7rem 0 0.7rem 0;
}
.toolbar-flex button:disabled {
  background: #c5c7cd !important;
  color: #ffffffcc !important;
  cursor: not-allowed !important;
  opacity: 0.68;
  box-shadow: none;
  border: none;
}
.toolbar-flex > #customBtn { margin-right: .7rem; }
.toolbar-flex > #searchBtn { margin-left: .7rem; }
.toolbar-flex button {
  background: var(--header-bg);
  color: var(--header-text);
  border: none;
  border-radius: 9px;
  font-size: 1.4rem;
  font-weight: 600;
  min-width: 2.8rem;
  min-height: 2.8rem;
  padding: .7rem 1rem;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .13s;
  box-shadow: 0 1.5px 7px rgba(0,0,0,0.09);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.toolbar-flex button:focus,
.toolbar-flex button:hover {
  background: var(--event-hover);
  color: var(--header-bg);
}
.toolbar-flex button i {
  font-size: 1.15em;
  pointer-events: none;
}

@media (max-width: 700px) {
  .header-wrapper {
    width: 100%;
    min-width: unset;
    padding: 0;
  }
  .toolbar-flex {
    gap: 0.42rem;
    padding: 0.4rem 0 0.7rem 0;
  }
  .toolbar-flex button {
    font-size: 1.4rem;
    min-width: 2.6rem;
    min-height: 2.6rem;
    padding: .75rem 1.15rem;
    border-radius: 10px;
  }
}

/* SEARCH PANEL - with animation */
.search-panel {
  display: none;
  background: var(--card-bg);
  border: 1px solid var(--event-border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .2s, transform .2s;
}
.search-panel.active {
  display: block;
}
.search-panel .form-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
  align-items: center;
}
.search-panel input[type="text"],
.search-panel select,
.search-panel input[type="date"] {
  flex: 1;
  padding: .5rem;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 4px;
}
/* date-filters labels inline & centered */
.date-filters label {
  white-space: nowrap;
}
/* SEARCH & CLEAR buttons */
.btn-search, .btn-clear {
  background: var(--event-bg);
  color: var(--event-text);
  border: none;
  border-radius: 4px;
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  transition: background .2s;
}
.btn-clear {
  background: #aaa;
}
.btn-clear i {
  transform: rotate(45deg);
}
.btn-clear:hover { opacity:.9; }

/* SORT ORDER select */
.search-panel #sortOrder {
  width: 100%;
}

/* MOBILE: stack inputs vertically */
@media (max-width: 768px) {
  .search-panel .form-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* SEARCH RESULTS */
.search-result {
  background: var(--bg);
  border-left: 3px solid var(--header-bg);
  padding: .85rem 1rem;
  margin-bottom: .7rem;
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 1.01rem;
}
.search-result > div {
  margin-bottom: .23rem;   /* Add space between each field */
  line-height: 1.25;
}
.search-result hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: .62rem 0 .15rem 0;
}

/* Customizer modal */
.customizer {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center; justify-content: center;
  z-index: 2000;
}
.customizer.active {
  display: flex;
}
.customizer-content {
  background: var(--card-bg);
  color: var(--text);
  padding: 1rem;
  border-radius: 8px;
  max-width: 90vw;
  width: 430px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: slideDown .3s ease-out;
}
.customizer-content h3 {
  margin: 0 0 .75rem;
  font-size: 1.25rem;
  text-align: center;
}
.custom-close {
  position: absolute; top: .5rem; right: .75rem;
  font-size: 1.2rem; cursor: pointer; color: var(--text);
}

/* Color Preset Row */
.preset-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .7rem .7rem;
  margin-bottom: 1.4rem;
  justify-items: center;
  align-items: stretch;
}
.preset-btn {
  background: var(--header-bg);
  color: var(--header-text);
  border: none;
  border-radius: 8px;
  font-size: 1.12rem;
  font-weight: 500;
  height: 70px;
  min-width: 110px;
  width: 100%;
  max-width: 180px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  transition: background .18s, color .18s, border .18s, box-shadow .18s;
  border: 2px solid transparent;
  outline: none;
  padding: 0;
}
.preset-btn span {
  font-size: 1.6em;
  line-height: 1.2;
  display: block;
}
.preset-btn.preset-custom {
  background: #e0e0e0;
  color: #2e2e2e;
}
.preset-btn.active {
  border: 2.5px solid var(--event-hover);
  background: var(--event-hover);
  color: var(--header-bg);
}
.preset-btn:focus-visible {
  border: 2.5px solid var(--event-hover);
  box-shadow: 0 0 0 2px var(--header-bg);
}

@media (max-width: 600px) {
  .preset-row {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: .4rem .4rem;
  }
  .preset-btn {
    min-width: 70px;
    font-size: .98rem;
    height: 52px;
  }
  .preset-btn span {
    font-size: 1.18em;
  }
}

/* Settings grid */
.settings-grid { display: flex; flex-direction: column; gap: 1.2rem; }
.setting-group h4 { margin:0 0 .5rem; font-size:1rem; font-weight:600; }
.group-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:.75rem; }
.settings-grid label {
  background: var(--bg);
  padding:.5rem;
  border-radius:6px;
  display:flex; flex-direction:column;
  font-size:.93rem;
  transition: background .2s;
}
.settings-grid label:hover { background: var(--card-bg); }
.settings-grid input { margin-top:.25rem; }

/* Reset button */
.reset-container { text-align:center; margin-top:1rem; }
.btn-reset {
  background: var(--event-hover);
  color: var(--event-text);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.btn-reset:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Calendar grid */
.calendar-grid {
  display: grid;
  grid-template-columns: 50px repeat(5,1fr);
  grid-template-rows: 40px repeat(var(--total-q),1fr) 1fr;
  column-gap: var(--gap-x);
  row-gap: var(--gap-y);
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  height: calc(100vh - var(--site-header-height) - var(--header-wrapper-height) - 2rem);
  overflow: hidden;
}

/* Day headers */
.header-day {
  grid-row: 1;
  position: relative;
  z-index: 10;
  background: var(--header-bg);
  color: var(--header-text);
  text-align: center;
  border-radius: 4px;
  font-weight: 600;
  /* box-shadow removed! */
  border: 2px solid var(--header-glow);
  box-shadow: none;
  display:flex; flex-direction:column; justify-content:center; padding:0;
}
.header-day .day-name { padding-top:.25rem; }
.header-day .day-date { padding-bottom:.25rem; opacity:.9; }

/* Time labels & lines */
.time-label {
  grid-column: 1;
  padding-right: 8px;
  font-size: .75rem;
  display:flex; align-items:center; justify-content:flex-end;
}
.hour-line { border-top:1px solid rgba(0,0,0,0.1); }

/* Events */
.event {
  background: var(--event-bg);
  color: var(--event-text);
  border:2px solid var(--event-border);
  border-radius:4px;
  padding:.5rem;
  position:relative; z-index:1;
  box-shadow: none; /* No glow by default! */
  cursor:pointer;
  transition: background .2s, box-shadow .2s, border-color .2s, transform .2s;
  display:flex; flex-direction:column; overflow:hidden;
}
.event:hover { transform: translateY(-2px); border-color: var(--event-hover);}
.pill {
  position:absolute; top:.25rem; right:.25rem;
  background:rgba(0,0,0,0.2);
  padding:.2rem .4rem;
  border-radius:4px;
  font-size:.75rem;
}
.event.running,
.mobile-event.running {
  border: 2.5px solid var(--running-glow);
  box-shadow: 0 0 10px var(--running-glow);
}

.time { font-size:.9rem; font-weight:500; margin-bottom:.25rem; white-space:nowrap; }
.info { font-size:.85rem; margin:.5rem 0; }

/* Free slots */
.event.free {
  background:#FFF9C4;
  border:2px dashed var(--header-glow);
  color:var(--header-glow);
  box-shadow: none;
}
.event.free .time {
  display:flex; align-items:center; justify-content:center;
  font-size:1.1rem; font-weight:700; text-align:center; width:100%;
}
.event.free .pill, .event.free .info { display:none; }

/* Selbststudium style */
.event[data-type="Selbststudium"] {
  background: repeating-linear-gradient(45deg,
    #fff3cd,#fff3cd 10px,#ffe8a1 10px,#ffe8a1 20px);
  border:2px dashed #ff9800;
  color:#333;
}
.event[data-type="Selbststudium"] .pill {
  background: rgba(255,152,0,0.2);
}

/* Now-line */
.now-line { border-top:2px solid var(--now-line); z-index:2; }

/* Detail modal */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.44);
  align-items: center; justify-content: center;
  z-index: 2500;
}
.modal.active { display: flex; }

.modal-content {
  background: var(--card-bg);
  color: var(--text);
  padding: 1.2rem 1.7rem 1.25rem 1.7rem;
  border-radius: 14px;
  max-width: 94vw; max-height: 94vh;
  box-shadow: 0 6px 30px rgba(0,0,0,0.28);
  border-top: 8px solid var(--header-bg);
  border-bottom: 3px solid var(--event-hover);
  animation: slideDown .28s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
}

.modal-content h2 {
  margin: 0 0 .5rem 0;
  color: var(--header-bg);
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: .5px;
}

.modal-content p {
  margin: .32rem 0 .32rem 0;
  padding-bottom: .09rem;
  border-bottom: 1px solid #eee3;
  width: 100%;
  font-size: 1.02rem;
  line-height: 1.34;
}

.modal-close {
  position: absolute; top: .7rem; right: 1.1rem;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--header-bg);
  font-weight: 900;
  transition: color .16s;
}
.modal-close:hover { color: var(--event-hover); }

/* Mobile fallback */
.mobile-list { display:none; }
@media (max-width:768px) {
  .calendar-grid { display:none !important; }
  .mobile-list    { display:block !important; }

  .mobile-day { margin-bottom:2rem; }
  .mobile-day-header {
    position: sticky;
    top: calc(var(--site-header-height, 0px) + var(--header-wrapper-height, 0px));
    z-index: 10;
    width: calc(100% + 2rem);
    margin: 0 -1rem;
    background: var(--header-bg);
    color: var(--header-text);
    padding: .5rem;
    font-weight:600;
    border: 2px solid var(--header-glow);
    box-shadow: none;
    text-align:center;
  }
  .mobile-event {
    background: var(--event-bg);
    color: var(--event-text);
    border:2px solid var(--event-border);
    box-shadow:none;
    border-radius:4px;
    margin:1rem 0;
    padding:.75rem;
    position:relative;
    display:flex; flex-direction:column;
    transition: transform .2s, border-color .2s;
  }
  .mobile-event:hover { transform: translateY(-2px); border-color: var(--event-hover);}
  .mobile-event.free {
    background:#FFF9C4;
    border:2px dashed var(--header-glow);
    box-shadow:none;
    cursor:default;
  }
  .mobile-event.free .time {
    font-size:1rem; font-weight:700; text-align:center;
  }
  .mobile-event.free .pill, .mobile-event.free .info { display:none; }
}
/* Floating Export Button (as before) */
/* Floating Export Button (as before, with new icon) */
.fab-export {
  position: fixed;
  right: 2.5rem;
  bottom: 2.5rem;
  z-index: 2500;
  width: 58px;
  height: 58px;
  background: var(--header-bg);
  color: var(--header-text);
  border: none;
  border-radius: 50%;
  font-size: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .16s, transform .13s;
}
.fab-export:hover, .fab-export:focus {
  background: var(--event-hover);
  color: var(--header-bg);
  transform: translateY(-4px) scale(1.08);
}
@media (max-width: 800px) {
  .fab-export {
    right: 1.2rem;
    bottom: 1.2rem;
    width: 46px;
    height: 46px;
    font-size: 1.4rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity:0; transform: translateY(-10px); }
  to   { opacity:1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity:0; transform: translateY(-20px); }
  to   { opacity:1; transform: translateY(0); }
}
