
:root{
  --bg:#f4f6fa;
  --ink:#172033;
  --muted:#758095;
  --line:#e4e8ef;
  --blue:#3478d4;
  --green:#26965a;
  --yellow:#f2c928;
  --card:#ffffff;
  --input-bg:#ffffff;
}

*{box-sizing:border-box}

body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:15px/1.45 Inter,system-ui,-apple-system,Segoe UI,sans-serif;
}

/* ÜLEMINE RIBA */

.topbar{
  min-height:68px;
  background:#111827;
  color:white;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 28px;
}

.topbar strong{letter-spacing:1.5px}

.topbar small{
  display:block;
  color:#9ca3af;
  font-size:11px;
}

.userbox{font-size:13px;color:#d1d5db}
.userbox a{color:#fff;margin-left:12px}

.user-actions{
  display:flex;
  align-items:center;
  gap:16px;
}

.theme-toggle{
  border:1px solid #465267;
  background:#263449;
  color:#fff;
  border-radius:9px;
  padding:8px 11px;
  font-weight:650;
  cursor:pointer;
}

/* PÕHILAYOUT */

.layout{
  max-width:1500px;
  margin:24px auto;
  padding:0 20px;
  display:grid;
  grid-template-columns:245px minmax(0,1fr);
  gap:22px;
}

.sidebar,.calendar-panel{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:16px;
  padding:20px;
}

.sidebar{height:max-content}

/* NUPUD */

.primary,.secondary,.danger,.filter{
  border:0;
  border-radius:9px;
  padding:11px 14px;
  font-weight:650;
  cursor:pointer;
  transition:background .15s,filter .15s;
}

.primary{
  background:#f2c928;
  color:#171717;
}

.primary:hover{background:#e8bd19}

.secondary{
  background:#eef1f6;
  color:#293449;
}

.secondary:hover{filter:brightness(.96)}

.danger{
  background:#fee2e2;
  color:#991b1b;
}

.wide{
  width:100%;
  margin-bottom:10px;
}

/* KALENDRITE FILTRID */

.filter-title{
  font-size:10px;
  font-weight:800;
  letter-spacing:1.4px;
  color:#98a1b1;
  margin:20px 0 8px;
}

.filters{display:grid;gap:5px}

.filter{
  text-align:left;
  background:transparent;
  color:#4b5563;
}

.filter.active{
  background:#edf3ff;
  color:#245ca8;
}

.groups{
  font-size:13px;
  min-width:0;
}

/* GRUPID */

.group-item{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:7px;
  padding:8px 4px;
  color:#465267;
  min-width:0;
}

.group-item>span{
  flex:1 1 100px;
  min-width:0;
  overflow-wrap:anywhere;
}

.group-item button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  white-space:nowrap;
  min-height:34px;
  padding:7px 10px;
  font-size:12px;
  border-radius:8px;
  cursor:pointer;
}

.group-item .members-button{
  display:inline-flex!important;
  visibility:visible!important;
  opacity:1!important;
  flex:0 0 auto!important;
}

.hint{
  font-size:11px;
  color:#8992a2;
  line-height:1.6;
  margin-top:22px;
  border-top:1px solid var(--line);
  padding-top:14px;
}

/* KALENDRI PÄIS */

.calendar-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:12px;
}

.calendar-head h1{font-size:23px;margin:0}

.calendar-head p{
  margin:2px 0;
  color:var(--muted);
  font-size:12px;
}

.legend{
  display:flex;
  gap:14px;
  font-size:12px;
  color:#657086;
}

.legend i{
  display:inline-block;
  width:8px;
  height:8px;
  border-radius:50%;
  margin-right:5px;
}

.blue{background:var(--blue)}
.green{background:var(--green)}

/* FULLCALENDAR */

#calendar{font-size:13px}
.fc .fc-toolbar-title{font-size:17px}

.fc .fc-button{
  background:#eef1f6!important;
  border:0!important;
  color:#334155!important;
  text-transform:none!important;
  box-shadow:none!important;
}

.fc .fc-button-primary:not(:disabled).fc-button-active{
  background:#1f2937!important;
  color:white!important;
}

.fc .fc-daygrid-event{
  white-space:normal;
  padding:2px 3px;
}

.fc-event-title{font-weight:600}
.fc .fc-day-today{background:#fffbea!important}

/* NÄDALAVAHETUSED JA RIIGIPÜHAD */

.fc .fc-daygrid-day{cursor:pointer}

.fc .fc-daygrid-day.estonian-saturday .fc-daygrid-day-frame{
  background:#f1f3f6;
}

.fc .fc-daygrid-day.estonian-sunday .fc-daygrid-day-frame{
  background:#fff0f0;
}

.fc .fc-daygrid-day.estonian-sunday .fc-daygrid-day-number{
  color:#dc2626;
  font-weight:800;
}

.fc .fc-daygrid-day.estonian-holiday .fc-daygrid-day-frame{
  background:#ffe3e3;
}

.fc .fc-daygrid-day.estonian-holiday .fc-daygrid-day-number{
  color:#c62828;
  font-weight:850;
}

.fc-holiday-label{
  display:block;
  padding:2px 5px 4px;
  color:#b42323;
  font-size:10px;
  line-height:1.2;
  font-weight:750;
  overflow-wrap:anywhere;
}

.fc .fc-daygrid-day.fc-day-today.estonian-holiday .fc-daygrid-day-frame{
  background:#ffdada!important;
  box-shadow:inset 0 0 0 2px #dc7777;
}

.fc .fc-daygrid-day.fc-day-today.estonian-sunday:not(.estonian-holiday) .fc-daygrid-day-frame{
  background:#ffe2e2!important;
  box-shadow:inset 0 0 0 2px #e6a0a0;
}

.fc .fc-daygrid-day.fc-day-today.estonian-saturday .fc-daygrid-day-frame{
  background:#e6eaf0!important;
  box-shadow:inset 0 0 0 2px #aab5c5;
}

.fc .fc-col-header-cell.fc-day-sun .fc-col-header-cell-cushion{
  color:#dc2626;
}

.fc .fc-col-header-cell.fc-day-sat .fc-col-header-cell-cushion{
  color:#64748b;
}

.fc .fc-daygrid-day:hover .fc-daygrid-day-frame{
  filter:brightness(.97);
}

/* DIALOOGID */

dialog{
  border:0;
  border-radius:16px;
  padding:0;
  width:min(540px,calc(100% - 24px));
  max-height:90vh;
  overflow:auto;
  box-shadow:0 24px 80px #11182740;
  background:#fff;
  color:var(--ink);
}

dialog::backdrop{
  background:#10182788;
  backdrop-filter:blur(3px);
}

.dialog-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.dialog-head h2{
  margin:0 0 16px;
  font-size:20px;
}

.dialog-head .x{
  border:0;
  background:none;
  font-size:26px;
  cursor:pointer;
  color:#64748b;
  flex-shrink:0;
}

#eventForm{
  padding:24px;
  display:grid;
  gap:13px;
}

label{
  display:grid;
  gap:5px;
  font-size:12px;
  font-weight:650;
  color:#536075;
}

input,textarea,select{
  width:100%;
  padding:10px 11px;
  border:1px solid #dce2eb;
  border-radius:8px;
  font:inherit;
  color:#172033;
  background:#fff;
}

textarea{resize:vertical}

input:focus,textarea:focus,select:focus{
  outline:2px solid rgba(52,120,212,.2);
  border-color:#3478d4;
}

.two{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.dialog-actions{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:8px;
}

.dialog-actions span{flex:1}

/* PÄEVA SÜNDMUSTE AKNAD */

#dayDialog{
  width:min(560px,calc(100% - 24px));
  max-height:85vh;
  padding:22px;
  overflow:hidden;
}

#dayDialog .dialog-head{
  border-bottom:1px solid var(--line);
  padding-bottom:12px;
  margin-bottom:14px;
}

#dayDialog .dialog-head h2{
  margin:0;
  font-size:19px;
  text-transform:capitalize;
}

#dayEventsList{
  display:flex;
  flex-direction:column;
  gap:10px;
  max-height:55vh;
  overflow-y:auto;
  padding:3px 4px 8px 2px;
}

#dayEventsList .hint{
  margin:0;
  padding:18px;
  border:1px dashed var(--line);
  border-radius:10px;
  text-align:center;
  font-size:13px;
}

.day-event{
  display:flex;
  gap:14px;
  align-items:flex-start;
  padding:14px;
  border-radius:11px;
  cursor:pointer;
  border-left:4px solid var(--blue);
  background:rgba(59,130,246,.08);
  transition:transform .15s,background .15s;
}

.day-event:hover{
  transform:translateX(2px);
  background:rgba(59,130,246,.14);
}

.day-event-work{border-left-color:#3478d4}

.day-event-personal{
  border-left-color:#26965a;
  background:rgba(38,150,90,.08);
}

.day-event-personal:hover{
  background:rgba(38,150,90,.15);
}

.day-event-time{
  min-width:68px;
  padding-top:1px;
  font-weight:750;
  font-size:14px;
  color:var(--ink);
}

.day-event-content{
  display:flex;
  flex-direction:column;
  gap:5px;
  min-width:0;
  flex:1;
}

.day-event-content strong{
  font-size:14px;
  overflow-wrap:anywhere;
}

.day-event-description{
  font-size:13px;
  color:var(--muted);
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

.day-event-content small{
  opacity:.75;
  font-size:11px;
  font-weight:600;
}

#dayDialog .dialog-actions{
  border-top:1px solid var(--line);
  padding-top:14px;
  margin-top:12px;
}

/* PÄEVA AKNA LISA SÜNDMUS NUPP */
#dayDialog .dialog-actions .primary,
#dayDialog button.primary{
  background:#f2c928!important;
  color:#171717!important;
  border:0!important;
  font-weight:750!important;
  opacity:1!important;
}

#dayDialog .dialog-actions .primary:hover,
#dayDialog button.primary:hover{
  background:#e8bd19!important;
  color:#171717!important;
}

/* TEATED */

#toast{
  position:fixed;
  bottom:24px;
  left:50%;
  transform:translate(-50%,20px);
  background:#172033;
  color:white;
  padding:11px 18px;
  border-radius:10px;
  opacity:0;
  pointer-events:none;
  transition:.2s;
  z-index:9999;
  max-width:calc(100% - 30px);
  text-align:center;
}

#toast.show{
  opacity:1;
  transform:translate(-50%,0);
}

/* SISSELOGIMINE */

.login-bg{
  min-height:100vh;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,#111827,#26364d);
}

.login-card{
  background:white;
  border-radius:18px;
  padding:30px;
  width:min(420px,calc(100% - 30px));
  box-shadow:0 20px 70px #0004;
}

.login-card h1{margin:0}

.login-card p{
  color:#788397;
  margin-top:4px;
}

.login-card form{
  display:grid;
  gap:14px;
  margin-top:24px;
}

.error{
  background:#fee2e2;
  color:#991b1b;
  padding:10px;
  border-radius:8px;
  font-size:13px;
}

/* TUME KUJUNDUS */

:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#101722;
  --ink:#e7edf5;
  --muted:#9aa8bb;
  --line:#293547;
  --card:#182333;
  --input-bg:#101a28;
}

:root[data-theme="dark"] body{
  background:var(--bg);
  color:var(--ink);
}

:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .calendar-panel,
:root[data-theme="dark"] dialog,
:root[data-theme="dark"] .login-card{
  background:var(--card);
  color:var(--ink);
  border-color:var(--line);
}

:root[data-theme="dark"] .secondary,
:root[data-theme="dark"] .filter.active{
  background:#29384d;
  color:#e5edf8;
}

:root[data-theme="dark"] .filter{color:#c1cada}

:root[data-theme="dark"] .group-item,
:root[data-theme="dark"] label{
  color:#c1cada;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] select{
  background:#101a28;
  color:#e7edf5;
  border-color:#3a4960;
  color-scheme:dark;
}

:root[data-theme="dark"] .fc{
  --fc-page-bg-color:#182333;
  --fc-neutral-bg-color:#202d40;
  --fc-border-color:#344257;
  --fc-neutral-text-color:#aab7c8;
  --fc-list-event-hover-bg-color:#26364b;
  --fc-today-bg-color:#34301d;
}

:root[data-theme="dark"] .fc .fc-col-header-cell-cushion,
:root[data-theme="dark"] .fc .fc-daygrid-day-number,
:root[data-theme="dark"] .fc .fc-timegrid-slot-label-cushion{
  color:#dce5f0;
}

:root[data-theme="dark"] .fc .fc-button{
  background:#29384d!important;
  color:#e5edf8!important;
}

:root[data-theme="dark"] .fc .fc-button-primary:not(:disabled).fc-button-active{
  background:#526782!important;
  color:white!important;
}

:root[data-theme="dark"] .fc .fc-day-today{
  background:#34301d!important;
}

:root[data-theme="dark"] .calendar-head p,
:root[data-theme="dark"] .legend{
  color:#aab7c8;
}

:root[data-theme="dark"] .hint{
  color:#aab7c8;
  border-color:var(--line);
}

:root[data-theme="dark"] .dialog-head .x{color:#c1cada}
:root[data-theme="dark"] .login-card p{color:#aab7c8}

:root[data-theme="dark"] .theme-toggle{
  background:#29384d;
  color:#f5d76e;
  border-color:#40516a;
}

/* TUME KUJUNDUS – NÄDALAVAHETUSED JA PÜHAD */

:root[data-theme="dark"] .fc .fc-daygrid-day.estonian-saturday .fc-daygrid-day-frame{
  background:#263244;
}

:root[data-theme="dark"] .fc .fc-daygrid-day.estonian-sunday .fc-daygrid-day-frame{
  background:#44272d;
}

:root[data-theme="dark"] .fc .fc-daygrid-day.estonian-sunday .fc-daygrid-day-number{
  color:#ff8585;
  font-weight:800;
}

:root[data-theme="dark"] .fc .fc-daygrid-day.estonian-holiday .fc-daygrid-day-frame{
  background:#512b32;
}

:root[data-theme="dark"] .fc .fc-daygrid-day.estonian-holiday .fc-daygrid-day-number{
  color:#ff9292;
  font-weight:850;
}

:root[data-theme="dark"] .fc-holiday-label{color:#ff9999}

:root[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today.estonian-holiday .fc-daygrid-day-frame{
  background:#63333b!important;
  box-shadow:inset 0 0 0 2px #d77979;
}

:root[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today.estonian-sunday:not(.estonian-holiday) .fc-daygrid-day-frame{
  background:#512d34!important;
  box-shadow:inset 0 0 0 2px #c87979;
}

:root[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today.estonian-saturday .fc-daygrid-day-frame{
  background:#303e52!important;
  box-shadow:inset 0 0 0 2px #71839d;
}

:root[data-theme="dark"] .fc .fc-col-header-cell.fc-day-sun .fc-col-header-cell-cushion{
  color:#ff8585;
}

/* TUME PÄEVADE AKEN */

:root[data-theme="dark"] #dayDialog .dialog-head{
  border-color:var(--line);
}

:root[data-theme="dark"] .day-event-work{
  background:rgba(52,120,212,.17);
  border-left-color:#60a5fa;
}

:root[data-theme="dark"] .day-event-work:hover{
  background:rgba(52,120,212,.26);
}

:root[data-theme="dark"] .day-event-personal{
  background:rgba(38,150,90,.17);
  border-left-color:#4ade80;
}

:root[data-theme="dark"] .day-event-personal:hover{
  background:rgba(38,150,90,.25);
}

:root[data-theme="dark"] .day-event-time,
:root[data-theme="dark"] .day-event-content strong{
  color:#e7edf5;
}

:root[data-theme="dark"] .day-event-description{color:#b6c2d2}

:root[data-theme="dark"] #dayDialog .dialog-actions{
  border-color:var(--line);
}

/* TAHVELARVUTI JA MOBIIL */

@media(max-width:800px){

  .layout{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-areas:
      "calendar"
      "sidebar"!important;
    margin:10px auto;
    padding:0 10px;
    gap:12px!important;
  }

  .calendar-panel{
    grid-area:calendar!important;
    order:unset!important;
    width:100%;
    min-width:0;
    padding:12px;
  }

  .sidebar{
    grid-area:sidebar!important;
    order:unset!important;
    width:100%;
    height:auto;
    padding:13px;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:5px;
  }

  /* Lisa sündmus alati nähtav */
  .sidebar #newEvent{
    display:block!important;
    visibility:visible!important;
    opacity:1!important;
    grid-column:1/-1!important;
    width:100%!important;
    min-height:46px!important;
    background:#f2c928!important;
    color:#171717!important;
    border:0!important;
    font-weight:750!important;
    position:relative;
    z-index:2;
  }

  .sidebar .primary,
  .sidebar .filter-title,
  .sidebar .filters,
  .sidebar .groups,
  .sidebar .hint{
    grid-column:1/-1;
  }

  .sidebar .filter-title{margin:8px 0 0}
  .sidebar .wide{margin:0}

  .calendar-head h1{font-size:19px}

  .topbar{padding:0 14px}

  .fc .fc-toolbar{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
  }

  .fc .fc-toolbar-chunk{
    display:flex;
    gap:4px;
  }

  .fc .fc-button{
    padding:.35em .5em!important;
    font-size:12px!important;
  }

  .two{grid-template-columns:1fr}
  .legend{display:none}

  .sidebar .groups,
  #groups{
    display:block!important;
    width:100%;
    min-width:0;
    overflow:visible!important;
  }

  .group-item{
    display:flex!important;
    flex-wrap:wrap!important;
    align-items:center!important;
    width:100%;
    overflow:visible!important;
  }

  .group-item .members-button{
    display:inline-flex!important;
    visibility:visible!important;
    opacity:1!important;
  }
}

/* TELEFON */

@media(max-width:600px){

  .topbar{min-height:58px}
  .topbar strong{font-size:14px}
  .user-actions{gap:7px}
  .userbox{font-size:11px}

  .theme-toggle{
    font-size:11px;
    padding:7px 8px;
  }

  .layout{
    margin:8px auto;
    padding:0 7px;
    gap:10px!important;
  }

  .calendar-panel{
    padding:9px;
    border-radius:12px;
  }

  .calendar-head{margin-bottom:8px}
  .calendar-head h1{font-size:17px}
  #calendar{font-size:11px}
  .fc .fc-toolbar-title{font-size:15px}

  .fc .fc-button{
    padding:.35em .45em!important;
    font-size:11px!important;
  }

  .fc .fc-daygrid-event{
    padding:1px 2px;
    font-size:10px;
  }

  .fc-holiday-label{
    font-size:9px;
    padding:2px 3px 4px;
  }

  .sidebar{
    padding:12px;
    border-radius:12px;
  }

  .sidebar #newEvent{
    display:block!important;
    width:100%!important;
    min-height:46px!important;
    background:#f2c928!important;
    color:#171717!important;
  }

  .group-item{
    gap:7px!important;
    padding:9px 2px!important;
  }

  .group-item>span{
    flex:1 1 100%!important;
    font-weight:650;
  }

  .group-item button,
  .group-item .members-button{
    display:inline-flex!important;
    min-height:38px!important;
    padding:8px 12px!important;
    font-size:12px!important;
  }

  #dayDialog{
    width:calc(100% - 20px);
    max-height:88vh;
    padding:16px;
    border-radius:14px;
  }

  #dayDialog .dialog-head h2{font-size:17px}

  #dayEventsList{
    max-height:58vh;
    gap:8px;
  }

  .day-event{
    padding:12px 10px;
    gap:10px;
  }

  .day-event-time{
    min-width:58px;
    font-size:13px;
  }

  .day-event-content strong{font-size:13px}
  .day-event-description{font-size:12px}

  #dayDialog .dialog-actions{flex-wrap:wrap}

  #dayDialog .dialog-actions .primary,
  #dayDialog .dialog-actions .secondary{
    padding:10px 12px;
  }

  #dayDialog .dialog-actions .primary{
    background:#f2c928!important;
    color:#171717!important;
  }

  #eventForm{padding:18px}
  .two{grid-template-columns:1fr}
}

/* VÄGA KITSAS EKRAAN */

@media(max-width:380px){

  .topbar strong{font-size:12px}
  .userbox{font-size:10px}
  .day-event{gap:7px}
  .day-event-time{min-width:52px}

  .fc-holiday-label{
    font-size:8px;
    line-height:1.1;
  }
}

/* LÕPLIK NUPPUDE VÄRVIKINDLUSTUS */

.sidebar #newEvent,
#dayDialog .primary{
  background:#f2c928!important;
  color:#171717!important;
  border:0!important;
  font-weight:750!important;
}

.sidebar #newEvent:hover,
#dayDialog .primary:hover{
  background:#e8bd19!important;
  color:#171717!important;
}
