/* =========================================================
   Termine Wochenkalender – Styles (namespaced: twk-*)
   ========================================================= */

/* ---- Shared base ---- */
.twk-card{ overflow:auto; -webkit-overflow-scrolling:touch; }
table.twk-table{ border-collapse:collapse; width:max-content; min-width:100%; }
table.twk-table th, table.twk-table td{ vertical-align:top; }
table.twk-table thead th{ position:sticky; top:0;  }

/* sticky time column */
.twk-time{ position:sticky; left:0;  }

/* ---- Main page ---- */
.twk-main .twk-wrap{ max-width:1200px; margin:14px auto; padding:0 12px; }

.twk-main .twk-toolbar{
  background:#fff;
  border:1px solid #dedede;
  border-radius:12px;
  box-shadow:0 2px 12px rgba(0,0,0,.06);
  padding:10px 12px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
}

.twk-main .twk-left,.twk-main .twk-right{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.twk-main .twk-toolbar label{ font-size:13px; color:#666; margin-right:6px; }

.twk-main .twk-toolbar select, .twk-main .twk-toolbar button{
  height:36px;
  line-height:36px;
  border:1px solid #dedede;
  border-radius:10px;
  background:#fff;
  padding:0 10px;
  font-size:14px;
  display:inline-flex;
  align-items:center;
}
.twk-main .twk-toolbar button{ cursor:pointer; background:#f4f5f7;  line-height:36px;}

.twk-main .twk-card{
  margin-top:12px;
  background:#fff;
  border:1px solid #dedede;
  border-radius:12px;
  box-shadow:0 2px 12px rgba(0,0,0,.06);
}

.twk-main table.twk-table th, .twk-main table.twk-table td{ border-bottom:1px solid #eee; }
.twk-main table.twk-table thead th{
  background:#f4f5f7;
  font-weight:800;
  font-size:13px;
  color:#333;
  padding:8px 10px;
}
.twk-main table.twk-table tbody td{ padding:6px 8px; }

.twk-main .twk-time{width:75px;min-width:75px;background:#fafafa;font-weight:700;color:#444;border-right:1px solid #eee;}
.twk-main .twk-day{width:165px;min-width:165px;}
.twk-main .twk-cell{ background:#fff; }

/* ---- Overlay calendar ---- */
.twk-cal .twk-card{margin:0;background:#f5f6f8;border:1px solid #d7dbe0;border-radius:12px;box-shadow:none;}

.twk-cal table.twk-table th, .twk-cal table.twk-table td{ border-bottom:1px solid #e3e6ea; }
.twk-cal table.twk-table th + th, .twk-cal table.twk-table td + td{ border-left:1px solid #e3e6ea; }

.twk-cal table.twk-table thead th{
  background:#eef0f3;
  font-weight:800;
  font-size:13px;
  color:#222;
  padding:8px 10px;
}
.twk-cal table.twk-table tbody td{ padding:6px 8px; }

.twk-cal .twk-time{width:75px;min-width:75px;background:#f0f1f4;font-weight:800;color:#333;border-right:1px solid #e3e6ea;}
.twk-cal .twk-day{width:165px;min-width:165px;background:rgba(255,255,255,.45);}
.twk-cal .twk-cell{ background:transparent; }

/* ---- Tiles ---- */
.twk-kalGrid{ display:flex; flex-direction:column; gap:6px; }
.twk-kalTile{width:165px;max-width:165px;background:#fbf1e5;border:1px solid rgba(0,0,0,.12);border-radius:10px;padding:8px 10px;box-sizing:border-box;cursor:pointer;}
.twk-cal .twk-kalTile{width:165px;max-width:165px;background:#fbf1e5;border:1px solid rgba(0,0,0,.12);border-radius:10px;padding:8px 10px;box-sizing:border-box;cursor:pointer;}

.twk-kalTileInner{ display:block; }
.twk-kalL1{ font-weight:800; color:#2a2a2a; font-size:13px; line-height:1.2; }
.twk-kalL2{ color:#444; font-size:13px; line-height:1.2; margin-top:2px; }
.twk-kalL3{ color:#555; font-size:12px; line-height:1.2; margin-top:2px; }
.twk-cal .twk-kalL1{ color:#111; }
.twk-cal .twk-kalL2{ color:#333; }

.twk-main .twk-left{align-items:flex-end;}

.twk-main table.twk-table th + th, .twk-main table.twk-table td + td{border-left:1px solid #eee;}

.twk-main .twk-toolbar select{ padding-top:0; padding-bottom:0; }

/* Align prev/next buttons with native selects (Firefox) */
.twk-main .twk-toolbar button#twk_prev,
.twk-main .twk-toolbar button#twk_next,
.twk-main .twk-toolbar button#wk_prev,
.twk-main .twk-toolbar button#wk_next{height:38px;line-height:38px;}

.twk-empty{padding: 5px;}


/* ---- v10 overrides ---- */
.twk-main .twk-time{width:75px;min-width:75px;}
.twk-main .twk-day{width:210px;min-width:210px;}
.twk-main .twk-kalTile{width:210px;max-width:210px;}

.twk-cal .twk-time{width:75px;min-width:75px;}
.twk-cal .twk-day{width:165px;min-width:165px;}
.twk-cal .twk-kalTile{width:165px;max-width:165px;}

/* Borders between day columns (both views) */
.twk-main table.twk-table th + th, .twk-main table.twk-table td + td{border-left:1px solid #eee;}
.twk-main .twk-time{border-right:1px solid #eee;}

.twk-cal .twk-card{background:#f5f6f8;}
.twk-cal table.twk-table th + th, .twk-cal table.twk-table td + td{border-left:1px solid #e3e6ea;}
.twk-cal .twk-time{border-right:1px solid #e3e6ea;}
.twk-cal .twk-cell{background:rgba(255,255,255,.55);}

/* Remove z-index that can overlap toolbar */
table.twk-table thead th{z-index:auto !important;}
.twk-time{z-index:auto !important;}

/* Toolbar alignment: labels above selects, buttons align to controls */
.twk-main .twk-left{align-items:flex-end;}
.twk-main .twk-toolbar select, .twk-main .twk-toolbar button{
  box-sizing:border-box;
  height:36px;
  line-height:36px;
  padding:0 10px;
  display:inline-flex;
  align-items:center;
}
.twk-main .twk-toolbar select{padding-top:0;padding-bottom:0;}


.twk-main .twk-wrap{max-width:none !important;}
/* v11 toolbar: like overlay */
.twk-main .twk-toolbar label{display:none !important;}
.twk-main .twk-toolbar{justify-content:space-between;}
.twk-main .twk-left{gap:8px;}

.twk-main .twk-toolbar select{padding-top:0;padding-bottom:0;margin: 0;}
/* v12 Ganztag Regie Badge */
.twk-allday-badge-regie{
  display:inline-flex;
  align-items:center;
  height:20px;
  line-height:20px;
  padding:0 8px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.18);
  background:#fff;
  font-size:12px;
  font-weight:800;
  color:#222;
  cursor:pointer;
  margin:2px 6px 2px 0;
  user-select:none;
}
.twk-allday-regie-list{display:none;margin-top:6px;}
.twk-allday-regie-list.is-open{display:block;}

.twk-cal .twk-scroll{background:#ffffff;}

.twk-toolbar-title{font-weight:800;}


/* Mehrfach-Termine Badge/Stack */
.twk-more-group{position:relative;}
.twk-more-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin-top:6px;
  padding:3px 8px;
  border:1px solid #d6d6d6;
  border-radius:12px;
  background:#fff;
  font-size:12px;
  cursor:pointer;
  width:fit-content;
}
.twk-more-arrow{font-size:11px;opacity:.75}
.twk-more-stack{margin-top:6px;}
/* Ganztag Badge */
.twk-allday-badge-regie{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border:1px solid #d6d6d6;
  border-radius:12px;
  background:#fff;
  font-size:12px;
  cursor:pointer;
  width:fit-content;
  margin-bottom:6px;
}

.twk-more-stack{display:none;margin-top:6px;}
.twk-more-stack .twk-kalTile{margin:6px 0 0 0 !important;}



/* Kalender-Overlay: kompakter, schmalere Tabelle */
#twk_cal_window .twk-body{background:#f7f7f7;}
#twk_cal_window .twk-card{padding:6px;}
#twk_cal_window .twk-scroll{padding:0;}
#twk_cal_window .twk-table{font-size:11px; table-layout:fixed; width:800px; max-width:800px;}
#twk_cal_window .twk-table thead th{padding:4px 4px;}
#twk_cal_window .twk-table td{padding:4px 4px;}
#twk_cal_window .twk-time{width:30px;}
#twk_cal_window .twk-day{width:145px; min-width:145px; max-width:145px;}
#twk_cal_window .twk-cell{border:1px solid #e0e0e0;}
#twk_cal_window .twk-kalGrid{gap:6px;}
#twk_cal_window .twk-kalTile{max-width:none;}
#twk_cal_window .twk-kalTileText{font-size:11px; line-height:1.2;}
#twk_cal_window .twk-kalL3{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
/* Overlay: Wartung-Details ausblenden */
#twk_cal_window .twk-kalTileWartFull{display:none !important;}




/* Overlay: Tiles kompakter */
#twk_cal_window .twk-kalTile{width:auto !important;}
#twk_cal_window .twk-time{width:30px !important;}
#twk_cal_window .twk-kalTileInner{font-size:11px;}
#twk_cal_window .twk-kalTileInner *{font-size:11px !important; line-height:1.2;}
#twk_cal_window .twk-kalL1{font-size:11px !important;}
#twk_cal_window .twk-kalL2{font-size:11px !important;}
#twk_cal_window .twk-kalL3{font-size:11px !important;}



/* ===== Overlay Styles (from termine_overlay_includes.php) ===== */
/* ---------- Shared overlay base (kein Abdunkeln, Seite bleibt bedienbar) ---------- */
  .twk-overlay{
    position:fixed; inset:0;
    background: transparent;
    display:none;
pointer-events:none; /* Klicks gehen durch – außer im Fenster */
  }

  .twk-window{box-sizing:border-box;
    position:fixed;
    z-index: 10000;
    left: 80px; top: 80px;
    background:#fff;
    border-radius: 4px;
    border:2px solid #0d0d0d;
    box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    overflow:hidden;
    display:flex;
    flex-direction:column;
    pointer-events:auto;
    resize: both;
    min-width: 520px;
    min-height: 240px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .twk-head{
    padding:6px 8px;
    background:#e9eaee;
    border-bottom:2px solid #bcbcbc;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    cursor: move;
    user-select: none;
  }
  .twk-title{font-weight:800}
  .twk-body{ padding:0; overflow:auto; background:#f7f7f7; flex:1; }
  .twk-foot{
    padding:8px 10px;
    background:#fff;
    border-top:1px solid #dedede;
    display:flex;
    gap:8px;
    justify-content:flex-end;
    flex-wrap:wrap;
  }

  .twk-btn{
    height:32px;
    border:1px solid #cfcfcf;
    border-radius:10px;
    background:#f4f5f7;
    padding:0 10px;
    font-size:13px;
    cursor:pointer;
    white-space:nowrap;
  }
  .twk-btn.primary{ background:#e60005; border-color:#cf0004; color:#fff; }
  .twk-btn.danger{ background:#ffecec; border-color:#f0b3b3; color:#8a0000; }

  .twk-empty{padding:12px;color:#666}

  /* ---------- Info Overlay (klein) ---------- */
  #twk_info_window{ width: 520px; height: 360px; }
  .twk-info-grid{
    display:flex;
    flex-direction:column;
    gap:10px;
  }
  .twk-card{
    background:#fff;
    border:1px solid #dedede;
    border-radius:12px;
    padding:10px 10px;
  }
  .twk-card h4{
    margin:0 0 6px 0;
    font-size:13px;
    color:#333;
  }
  .twk-line{font-size:13px;color:#222;line-height:1.35}
  .twk-muted{color:#666}
  .twk-pre{white-space:pre-wrap}

  /* ---------- Wochenkalender Overlay (groß) ---------- */
  #twk_cal_window{ width: 860px; height: 560px; min-width: 680px; min-height: 400px; }

  
  /* ---------- Kalender-Overlay Header Controls ---------- */
  .twk-cal-head-controls{
    display:flex;
    gap:8px;
    align-items:center;
    margin:0 auto; /* Mitte */
  }
  .twk-cal-head-controls select{
    height:32px;
    line-height:32px;
    border:1px solid #cfcfcf;
    border-radius:10px;
    background:#fff;
    padding:0 10px;
    font-size:13px;
    max-width: 320px;
  }

/* v16 safety */
.twk-overlay{background:transparent !important; opacity:1 !important;}
.twk-window{box-sizing:border-box;background:#fff !important; opacity:1 !important;}

  /* ---------- Overlay calendar visual (v17) ---------- */
  #twk_cal_window .twk-body{background:#f2f3f6;}
  #twk_cal_window #twk_cal_container{background:#ffffff; border:1px solid #dfe3e8; border-radius:10px; padding:6px;}
  #twk_cal_window table.twk-table{background:#ffffff;}
  #twk_cal_window table.twk-table th + th, #twk_cal_window table.twk-table td + td{border-left:1px solid #e3e6ea;}
  #twk_cal_window table.twk-table td{border-top:1px solid #eef1f4;}


/* Generic PDF overlay */
/*
#twk_generic_window{ width: 860px; height: 1160px; min-width: 520px; min-height: 420px; }
#twk_generic_window .twk-body{ background:#fff; }
*/

.twk-pdf-frame{ width:100%; height:100%; border:0; display:block; }



/* PDF-Viewer im Generic-Overlay */
#twk_generic_window .twk-body{ overflow:hidden; }
#twk_generic_container{ height:100%; }
#twk_generic_window .twk-pdf-host{ width:100%; height:100%; }


/* Overlay-only: kompaktere Termin-Kacheln */
#twk_cal_window .twk-kalTile{width:auto;}
#twk_cal_window .twk-kalTileInner{font-size:11px;}
#twk_cal_window .twk-kalL1{font-size:10px;}
#twk_cal_window .twk-kalL2{font-size:11px;}
#twk_cal_window .twk-kalL3{font-size:11px;}

/* allgemein */
#twk_generic_window.twk-minimized .twk-body{ display:none; }
#twk_generic_window.twk-minimized{ overflow:hidden; }


/* =========================
   Mobile final overrides
   (ans ENDE der Datei setzen)
   ========================= */
@media (max-width: 700px){

  /* Main table: wieder mobile Breiten setzen (v10 überschreibt sonst) */
  .twk-main .twk-time{ width:60px !important; min-width:60px !important; }
  .twk-main .twk-day{  width:140px !important; min-width:140px !important; }
  .twk-main .twk-kalTile{ width:140px !important; max-width:140px !important; }

  /* Toolbar: touchfreundlicher */
  .twk-main .twk-toolbar select,
  .twk-main .twk-toolbar button{
    height:42px !important;
    line-height:42px !important;
    font-size:15px;
    border-radius:12px;
  }


  /* Overlay Window: fullscreen-like */
  .twk-window{
    left:0 !important;
    top:40px !important;        
    width:100vw !important;
    height:calc(100vh - 40px) !important;
    max-width:100vw !important;
    max-height:calc(100vh - 80px) !important;
    border-radius:0 !important;
    resize:none !important;
    min-width: 200px;
    min-height: 200px;
  }
  #twk_generic_window.twk-minimized{
    height: auto !important;        /* killt calc(100vh-40px) */
    max-height: none !important;
    min-height: 0 !important;
    width: 100vw !important;        /* bleibt volle Breite */
    left: 0 !important;
    top: 40px !important;
  }

  /* Header: weniger "drag"-Feeling auf Touch */
  .twk-head{ cursor:default; }

  /* Generic PDF: lieber scrollen erlauben (hast du schon teils) */
  #twk_generic_window .twk-body{ overflow:auto !important; }

  /* Kalender-Overlay: Container voll breit, Tabelle darf scrollen */
  #twk_cal_window .twk-scroll{ overflow:auto; -webkit-overflow-scrolling:touch; }
  #twk_cal_window .twk-table{
    width:max-content !important;
    max-width:none !important;
    table-layout:auto !important;
  }
}
