/*
 * CTAO ELOG Theme v2
 * CSS-only, automatic light/dark mode
 * Compatible with legacy ELOG table-based layouts
 */

:root {
  color-scheme: light dark;

  /* CTAO accents */
  --ctao-galaxy: #00004A;
  --ctao-cherenkov: #00E4D8;
  --ctao-azure: #007AFF;
  --ctao-indigo: #00009C;

  /* Light mode */
  --bg: #F3F6FA;
  --bg-deep: #E9EEF5;
  --panel: #FFFFFF;
  --panel-alt: #F7F9FC;
  --panel-soft: #E9EEF5;
  --panel-strong: #DCE4EF;

  --border: #D2D9E5;
  --border-strong: #AEB9CB;

  --text: #162033;
  --text-soft: #3E4A61;
  --muted: #6A768C;

  --link: #0067C8;
  --link-hover: #00009C;

  --header-a: #00004A;
  --header-b: #13346B;

  --success: #177A59;
  --success-bg: #E5F6EF;
  --warning: #8A5A00;
  --warning-bg: #FFF3D6;
  --danger: #B42318;
  --danger-bg: #FDECEC;

  --quote-bg: #F7F9FC;
  --quote-head: #DDF9F6;
  --quote-text: #2E3A50;

  --radius-sm: 4px;
  --radius: 7px;
  --radius-lg: 10px;

  --shadow-soft: 0 2px 8px rgba(0, 0, 74, 0.08);
  --shadow: 0 10px 28px rgba(0, 0, 74, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08101F;
    --bg-deep: #050A14;
    --panel: #111A2E;
    --panel-alt: #18233B;
    --panel-soft: #202C46;
    --panel-strong: #283652;

    --border: #2C3957;
    --border-strong: #465775;

    --text: #E8EDF7;
    --text-soft: #C6CEE0;
    --muted: #9BA9C7;

    --link: #58C7FF;
    --link-hover: #00E4D8;

    --header-a: #00004A;
    --header-b: #102345;

    --success: #50D6A1;
    --success-bg: #12362F;
    --warning: #FFD166;
    --warning-bg: #3A2E13;
    --danger: #FF7B86;
    --danger-bg: #3A1820;

    --quote-bg: #111B2E;
    --quote-head: #10243D;
    --quote-text: #C6CEE0;

    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.22);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  }
}

/* Global */

html {
  background: var(--bg-deep);
}

body,
.calwindow,
.uploadwindow {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(0, 228, 216, 0.05), transparent 36rem),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  background-attachment: fixed;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

td {
  color: var(--text);
  font-size: 13px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
}

::selection {
  color: #050A14;
  background: var(--ctao-cherenkov);
}

a:link,
a:visited {
  color: var(--link);
  text-decoration: none;
}

a:hover,
a:active,
a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 228, 216, 0.45);
  outline-offset: 2px;
}

/* Main frames */

.frame,
.pframe,
.listframe {
  border-collapse: separate;
  border-spacing: 0;
}

.frame {
  width: 100%;
}

.pframe {
  width: min(100%, 1050px);
  margin: 0 auto;
}

/* Tabs */

.tabs {
  width: auto;
  padding: 0 6px;
  color: var(--text);
  background: var(--bg-deep) !important;
  border-bottom: 1px solid var(--border);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 13px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
}

.gtab,
.ltab,
.sgtab,
.sltab {
  width: auto;
  padding: 0;
  white-space: nowrap;
  vertical-align: middle;
  border: 0 !important;
  border-right: 1px solid var(--border) !important;
  border-radius: 6px 6px 0 0;
  box-shadow: none;
}

.gtab a,
.ltab a,
.sgtab a,
.sltab a {
  display: inline-block !important;
  padding: 7px 12px !important;
  line-height: 1.25 !important;
  border-radius: 6px 6px 0 0;
  font-weight: 650;
  text-decoration: none !important;
}

.gtab,
.ltab,
.gtab a,
.ltab a {
  color: var(--text-soft) !important;
  background: var(--panel-soft) !important;
}

.gtab:hover,
.ltab:hover,
.gtab:hover a,
.ltab:hover a {
  color: var(--link-hover) !important;
  background: var(--panel-alt) !important;
}

.sgtab,
.sltab,
.sgtab a,
.sltab a,
.sgtab a:visited,
.sltab a:visited {
  color: #050A14 !important;
  background: var(--ctao-cherenkov) !important;
  font-weight: 750 !important;
}

.sgtab,
.sltab {
  box-shadow: inset 0 -3px 0 var(--ctao-galaxy) !important;
}

td.gtab,
td.ltab,
td.sgtab,
td.sltab {
  display: table-cell;
}

/* Header */

.title1,
.title2,
.title3 {
  color: #FFFFFF;
  background: linear-gradient(90deg, var(--header-a), var(--header-b));
  border: 0;
  border-bottom: 3px solid var(--ctao-cherenkov);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.title1 {
  padding: 14px 18px;
  font-size: 19px;
  font-weight: 750;
  text-align: left;
  letter-spacing: 0.01em;
}

.title2 {
  padding: 10px;
  font-size: 15px;
  font-weight: 650;
  text-align: center;
}

.title3 {
  width: 140px;
  padding: 10px 14px;
  text-align: right;
}

.title1 a,
.title2 a,
.title3 a,
.dlgtitle a {
  color: var(--ctao-cherenkov) !important;
}

/* Menus and toolbars */

.menuframe,
.menucenter,
.toolframe {
  min-height: 35px;
  padding: 7px 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
}

.menuframe {
  border-top: 0;
  box-shadow: var(--shadow-soft);
}

.toolframe {
  background: var(--panel-alt);
}

.menu1,
.menu1a,
.menu2a,
.menu2b,
.menu3,
.menu4 {
  color: var(--text-soft);
}

.menu1a,
.menu3 {
  font-weight: 700;
}

/* Form controls */

input,
select,
textarea,
button {
  box-sizing: border-box;
  color: var(--text);
  background: var(--panel-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 13px;
}

input:not([type="image"]),
select,
textarea {
  padding: 7px 9px;
}

/* ELOG navigation arrows */

input[type="image"] {
  box-sizing: content-box;
  width: auto;
  height: auto;
  padding: 2px 3px;
  margin: 0 2px;
  background: transparent;
  border: 0;
  border-radius: 0;
  vertical-align: middle;
  cursor: pointer;
}

input[type="image"]:hover,
input[type="image"]:focus {
  background: transparent;
  border: 0;
  box-shadow: none;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ctao-cherenkov);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ctao-cherenkov);
  box-shadow: 0 0 0 2px rgba(0, 228, 216, 0.14);
}

input[type="submit"],
input[type="button"],
button,
.login_submit {
  padding: 7px 14px;
  color: #050A14;
  background: var(--ctao-cherenkov);
  border-color: var(--ctao-cherenkov);
  font-weight: 750;
  cursor: pointer;
}

input[type="submit"]:hover,
input[type="button"]:hover,
button:hover,
.login_submit:hover {
  background: #62F1E8;
  border-color: #62F1E8;
}

input[type="reset"] {
  color: var(--text);
  background: var(--panel-soft);
}

option {
  color: var(--text);
  background: var(--panel-alt);
}

/* Logbook selection */

.selframe {
  width: min(94%, 1040px);
  margin: 22px auto;
  overflow: hidden;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  font-size: 15px;
}

.seltitle,
.selexp,
.selentries,
.selgroup,
.sellogbook,
.selspace {
  border: 0;
  border-bottom: 1px solid var(--border);
}

.seltitle {
  padding: 11px;
  color: #FFFFFF;
  background: linear-gradient(90deg, var(--header-a), var(--header-b));
  border-bottom: 3px solid var(--ctao-cherenkov);
  font-weight: 750;
  text-align: center;
}

.selexp {
  padding: 8px 11px;
  color: var(--muted);
  background: var(--panel-alt);
}

.selgroup {
  padding: 9px 12px;
  color: var(--link-hover);
  background: var(--panel-soft);
  font-size: 15px;
  font-weight: 750;
}

.sellogbook {
  padding: 9px 12px;
  color: var(--text);
  background: var(--panel);
  font-weight: 650;
}

.sellogbook:hover {
  background: var(--panel-alt);
}

.selspace {
  background: var(--bg-deep);
}

.selentries {
  color: var(--muted);
  background: var(--panel-alt);
  text-align: center;
}

.selcomment {
  color: var(--muted);
  font-size: 12px;
}

/* Listings */

.listframe {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.listtitle,
.listtitle2,
.listtitle3 {
  padding: 8px 9px;
  color: #FFFFFF;
  background: linear-gradient(180deg, #18355C, #10264A);
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 3px solid var(--ctao-cherenkov);
  font-weight: 750;
  text-align: center;
}

.list1,
.list2,
.list1h,
.list2h,
.listdraft,
.listatt,
.thread,
.threadreply,
.threadh,
.threadreplyh,
.threaddraft {
  padding: 7px 9px;
  color: var(--text);
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  line-height: 1.35;
}

.list1,
.list1h,
.thread,
.threadh {
  background: var(--panel);
}

.list2,
.list2h,
.threadreply,
.threadreplyh {
  background: var(--panel-alt);
}

.list1:hover,
.list2:hover,
.list1h:hover,
.list2h:hover,
.thread:hover,
.threadreply:hover {
  background: var(--panel-soft);
}

.list1h,
.list2h,
.threadh,
.threadreplyh {
  font-weight: 750;
}

.listdraft,
.threaddraft {
  color: var(--warning);
  background: var(--warning-bg);
  font-weight: 750;
}

.listatt {
  color: var(--success);
  background: var(--success-bg);
}

.draftsel {
  padding: 8px;
  color: var(--warning);
  background: var(--warning-bg);
  border-bottom: 1px solid var(--border);
}

/* Metadata and forms */

.attribhead {
  padding: 8px 10px;
  color: #FFFFFF;
  background: linear-gradient(180deg, #18355C, #10264A);
  border: 0;
  border-bottom: 3px solid var(--ctao-cherenkov);
  font-size: 13px;
  font-weight: 750;
}

.attribname,
.attribvalue,
.attribvalue2,
.form1,
.form2,
.uploadtext,
.uploadvalue {
  padding: 8px 10px;
  color: var(--text);
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.attribname,
.uploadtext {
  width: 175px;
  color: var(--text-soft);
  background: var(--panel-soft);
  font-weight: 750;
}

.attribvalue,
.form1,
.uploadvalue {
  background: var(--panel);
}

.attribvalue2,
.form2 {
  background: var(--panel-alt);
}

/* Messages */

.messagelist,
.messageframe,
.attachmentframe,
.summary {
  color: var(--text);
  background: var(--panel);
  border-color: var(--border);
}

.messagelist {
  padding: 13px;
  border: 1px solid var(--border);
  border-top: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.messageframe {
  padding: 15px;
  border: 1px solid var(--border);
  border-top: 0;
}

.messagepre,
.bytes,
.summary {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.messagepre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.summary {
  padding: 8px;
  border: 1px solid var(--border);
}

/* Quotes, including ELOG inline yellow background */

.quotetable {
  width: 98%;
  margin: 10px 1%;
  background: transparent !important;
  border: 1px solid var(--border) !important;
  border-left: 4px solid var(--ctao-cherenkov) !important;
  border-radius: var(--radius-sm);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.quotetable td,
.quotetable td[style],
td[style*="#FFFFB0"],
td[style*="#ffffb0"],
td[style*="FFFFB0"],
td[style*="ffffb0"] {
  color: var(--quote-text) !important;
  background: var(--quote-bg) !important;
}

.quotetitle,
.quotetable .quotetitle {
  padding: 6px 9px !important;
  color: var(--link-hover) !important;
  background: var(--quote-head) !important;
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 12px;
  font-weight: 750;
}

.quote,
.quotetable .quote {
  padding: 10px !important;
  color: var(--quote-text) !important;
  background: var(--quote-bg) !important;
  border: 0 !important;
}

blockquote {
  margin: 0.8em 0;
  padding: 0.7em 1em;
  color: var(--quote-text);
  background: var(--quote-bg);
  border-left: 4px solid var(--ctao-cherenkov);
}

/* Attachments */

.attachment {
  padding: 7px 10px;
  color: var(--text-soft);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-top: 0;
}

.attachmentframe {
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.attachmentframe img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Alerts */

.errormsg,
.dlgerror {
  padding: 10px 12px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  font-weight: 750;
  text-align: center;
}

.notifymsg,
.notifyleft {
  padding: 10px 12px;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
}

/* Dialogs and login */

.dlgframe,
.login_frame {
  width: min(92%, 500px);
  margin: 8vh auto 0;
  overflow: hidden;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.dlgtitle,
.login_title {
  padding: 13px 16px;
  color: #FFFFFF;
  background: linear-gradient(90deg, var(--header-a), var(--header-b));
  border-bottom: 3px solid var(--ctao-cherenkov);
  font-size: 18px;
  font-weight: 750;
  text-align: center;
}

.dlgform,
.login_form,
.login_form_bottom {
  padding: 17px 22px;
  color: var(--text);
  background: var(--panel);
  text-align: center;
}

.login_input {
  width: 100%;
  max-width: 290px;
  padding: 8px 10px;
  font-size: 15px;
}

.overlabel {
  color: var(--muted);
}

/* Calendar */

.caltitle {
  padding: 7px;
  color: #FFFFFF;
  background: linear-gradient(90deg, var(--header-a), var(--header-b));
  border-bottom: 2px solid var(--ctao-cherenkov);
  font-weight: 750;
}

.calhead {
  padding: 5px;
  color: var(--text-soft);
  background: var(--panel-soft);
  font-weight: 750;
}

.calday,
.calsat,
.calsun,
.calcurday,
.calsel {
  padding: 5px;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 750;
}

.calday {
  background: var(--panel);
}

.calsat,
.calsun {
  background: var(--panel-alt);
}

.calsun {
  color: var(--danger);
}

.calcurday {
  color: #050A14;
  background: var(--link);
}

.calsel {
  color: #050A14;
  background: var(--ctao-cherenkov);
}

/* Upload */

.holder {
  height: 66px;
  margin: 8px;
  color: var(--muted);
  background: var(--panel-alt);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 66px;
  text-align: center;
}

.holder:hover {
  color: var(--link-hover);
  background: var(--panel-soft);
  border-color: var(--ctao-cherenkov);
}

.bottomlink {
  padding: 10px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* Scrollbars */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--bg-deep);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid var(--bg-deep);
  border-radius: 8px;
}

/* Accessibility */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* Responsive */

@media (max-width: 760px) {
  body {
    font-size: 13px;
  }

  .selframe,
  .dlgframe,
  .login_frame {
    width: 96%;
  }

  .title1 {
    font-size: 16px;
  }

  .gtab a,
  .ltab a,
  .sgtab a,
  .sltab a {
    padding: 6px 8px !important;
  }

  .attribname {
    width: 120px;
  }
}

/* Print */

@media print {
  :root {
    color-scheme: light;
    --bg: #FFFFFF;
    --bg-deep: #FFFFFF;
    --panel: #FFFFFF;
    --panel-alt: #FFFFFF;
    --panel-soft: #F2F2F2;
    --border: #888888;
    --border-strong: #666666;
    --text: #111111;
    --text-soft: #222222;
    --muted: #444444;
    --link: #000000;
    --link-hover: #000000;
    --quote-bg: #FFFFFF;
    --quote-head: #F2F2F2;
    --quote-text: #111111;
  }

  html,
  body {
    background: #FFFFFF;
  }

  .menuframe,
  .menucenter,
  .toolframe,
  .tabs {
    display: none;
  }

  .title1,
  .title2,
  .title3,
  .attribhead,
  .listtitle,
  .listtitle2,
  .listtitle3 {
    color: #111111;
    background: #FFFFFF;
    border-color: #777777;
  }

  .messageframe,
  .messagelist,
  .attachmentframe,
  .listframe,
  .selframe,
  .dlgframe,
  .login_frame {
    color: #111111;
    background: #FFFFFF;
    border-color: #777777;
    box-shadow: none;
  }

  a:link,
  a:visited {
    color: #000000;
    text-decoration: underline;
  }
}

/* =========================================================
   CKEditor 4 — outer interface
   ========================================================= */

.cke_chrome,
.cke_inner {
  color: var(--text) !important;
  background: var(--panel) !important;
  border-color: var(--border-strong) !important;
}

.cke_chrome {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-soft) !important;
  overflow: hidden;
}

.cke_top,
.cke_bottom {
  color: var(--text-soft) !important;
  background: var(--panel-alt) !important;
  border-color: var(--border) !important;
}

.cke_toolgroup,
.cke_combo_button {
  background: var(--panel-soft) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}

.cke_button:hover,
.cke_button:focus,
.cke_combo_button:hover,
.cke_combo_button:focus {
  background: var(--panel-strong) !important;
}

.cke_button_on {
  background: var(--ctao-cherenkov) !important;
}

.cke_button_label,
.cke_combo_text,
.cke_combo_label,
.cke_path_item,
.cke_resizer {
  color: var(--text-soft) !important;
}

.cke_toolbar_separator {
  background-color: var(--border-strong) !important;
}

.cke_contents {
  background: var(--panel) !important;
  border-color: var(--border) !important;
}

.cke_path_item:hover {
  color: var(--link-hover) !important;
  background: var(--panel-soft) !important;
}

/* =========================================================
   ELOG navigation arrows
   ========================================================= */

/*
 * ELOG uses <input type="image"> elements for the
 * First / Previous / Next / Last navigation controls.
 *
 * They live in a td.menu1a cell. Keep this cell compact
 * and prevent the four icons from wrapping onto two lines.
 */
td.menu1a:has(> input[type="image"]) {
  white-space: nowrap;
}

/*
 * Remove the generic form-control styling inherited by
 * ELOG's image buttons and keep the native arrow icons small.
 */
td.menu1a > input[type="image"] {
  width: auto !important;
  height: 18px !important;

  padding: 0 !important;
  margin: 0 3px !important;

  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;

  box-sizing: content-box !important;
  vertical-align: middle !important;
}


/* =========================================================
   Legacy ELOG menu-frame layout
   ========================================================= */

/*
 * Do not add padding directly to .menuframe.
 *
 * ELOG uses this class as part of its table-based layout,
 * including the entry-list/search page. Adding padding here
 * changes the legacy table geometry and reduces the natural
 * separation between the view controls and search filters.
 */
.menuframe {
  padding: 0;
}

@media (prefers-color-scheme: dark) {

  div[style*="background:#eee"],
  div[style*="background: #eee"],
  pre {
    background: var(--panel-alt) !important;
    color: var(--text) !important;
    border-color: var(--border-strong) !important;
  }
}

/* ---------------------------------------------------------
   Listing column headers
   --------------------------------------------------------- */

.listtitle,
.listtitle2,
.listtitle3,
.listtitle a,
.listtitle2 a,
.listtitle3 a,
.listtitle a:visited,
.listtitle2 a:visited,
.listtitle3 a:visited {
  color: #FFFFFF !important;
}

.listtitle a:hover,
.listtitle2 a:hover,
.listtitle3 a:hover {
  color: var(--ctao-cherenkov) !important;
}

/* Make links inside ELOG coloured status cells inherit the cell colour */
td[style*="background-color"] a,
td[style*="background-color"] a:visited {
  color: inherit !important;
}

/* ---------------------------------------------------------
   Logbook column sizing
   --------------------------------------------------------- */

.listframe th:nth-child(1),
.listframe td:nth-child(1) {
  width: 55px;
}

.listframe th:nth-child(2),
.listframe td:nth-child(2) {
  width: 160px;
}

.listframe th:nth-child(3),
.listframe td:nth-child(3) {
  width: 100px;
}

.listframe th:nth-child(4),
.listframe td:nth-child(4),
.listframe th:nth-child(5),
.listframe td:nth-child(5) {
  width: 90px;
}

.listframe th:nth-child(6),
.listframe td:nth-child(6),
.listframe th:nth-child(7),
.listframe td:nth-child(7),
.listframe th:nth-child(8),
.listframe td:nth-child(8) {
  width: 90px;
}

/* Subject */
.listframe th:nth-child(9),
.listframe td:nth-child(9) {
  width: 210px;
  min-width: 210px;
  max-width: 210px;
}

/* Show at most two lines of Subject */
.listframe td:nth-child(9) a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Status */
.listframe th:nth-child(10),
.listframe td:nth-child(10) {
  width: 75px;
}

/* Attachment */
.listframe th:nth-child(12),
.listframe td:nth-child(12) {
  width: 32px;
}