@charset "UTF-8";

.drag-box { /* must be global, document.body is used to generate this box */
  position: fixed;
  top: calc(100vh + 100px);
  padding: 0 12px 12px 0; /* for shadow */
  z-index: 20;
  & > div {
    box-shadow: 6px 6px 8px rgb(47,72,88,.8); /* rhino */
    border: 2px solid var(--pl-rhino);
    background: white;
    border-radius: 6px;
    padding: 12px;
  }
}

main.plan-page {
  --control-height: 3em;
  display: grid;

  max-height: calc(100vh - var(--nav-height)); height: calc(100vh - var(--nav-height)); min-height: calc(100vh - var(--nav-height));
  box-sizing: border-box;
  grid-template-areas:
    "filt filt"
    "shipments shipments" /* shipments table */
    "slicer slicer"
    "heapctrl selpanel"
    "heap map";
  grid-template-columns: 480px 1fr; /* minmax(1fr, 200px) 1fr; /*2em 2fr 1fr; */
  grid-template-rows:
    var(--control-height)  /* filt */
    1fr                    /* shipments */
    4px                    /* slicer */
    var(--control-height)  /* heap-control & selpanel */
    var(--map-height, 50%);/* map & laps; map-height is set and modified by javascript */
  /* transition: grid-template-rows .3s ease-out; */

  .slicer { grid-area: slicer; border-top: 1px solid white; border-bottom: 1px solid white; height: 2px; background-color: var(--pl-eggshell); cursor: row-resize; }
  .slicer:hover, .slicer.act { background-color: var(--pl-beetle-green); transition: background-color .4s .2s; }

  .table-header {
    grid-area: filt;
    background-color: #f4f5f7;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-sizing: border-box;
    flex-wrap: wrap;
    position: relative;
    z-index: 6;

    .date-range-section {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .filter-section {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;

      label {
        display: flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap;
        cursor: pointer;

        input[type=checkbox] {
          cursor: pointer;
        }

        .checkbox-wrapper {
          margin: 0;
        }
      }

      select {
        outline: none;
        padding: 4px 6px;
        border-radius: 4px;
        border-color: var(--pl-platinum);
        width: 140px;
      }

      .user-select {
        min-width: 140px;
      }
    }

    .terms {
      display: flex;
      align-items: center;
      gap: 2px;
      position: relative;
      z-index: 1001;
      transition: all 0.1s ease;
    }
    
    .terms > * {
      transition: all 0.1s ease;
    }

    .search-section {
      margin-left: auto;
      
      input {
        outline: none;
      }
    }
  }

  search {
    grid-area: filt;
    .icon { margin: 0 14px 0 0; transform: scale(1.4); width: 14px; /* ilma with-ita hüppab palju kuni font on laetud */ }
    input { margin-left: 12px; }
    .disabled { opacity: .7; }
    vertical-align: center;
    box-sizing: border-box;
    padding-left: 20px;
    display: flex;
    align-items: center;
    background-color: #f4f5f7;
    /* background-color: #F7A6002A; /* --pl with opacity */
    /* background-color: var(--pl-champagne); */
    select { outline: none; padding: 4px 6px; border-radius: 4px; border-color: var(--pl-platinum); margin-left: 12px; width: 140px; }
  }
  div.shp { 
    grid-area: shipments; 
    grid-column: 1 / 3; 
    position: relative; 
    width: 100%; 
    overflow: hidden;
    display: flex;
    flex-direction: column;

    .table-container {
      flex: 1;
      overflow: auto;
      position: relative;
    }

    .table-wrapper {
      overflow: auto;
      height: 100%;
    }

    .table-component {
      width: 100%;

      tr.sel td { 
        background-color: var(--sel-color); 
        cursor: grab; 
      }

      td.splitter {
        cursor: pointer;
      }

      .icon.colorlegend {
        font-size: 16px;

        &.a { color: var(--a-color); }
        &.b { color: var(--b-color); }
      }

      .address-info {
        display: inline;
      }

      .address-info .company {
        color: var(--pl-rhino);
        opacity: 0.5;
      }

      .shipment-id {
        cursor: pointer;
        color: #E78F00DE;
      }

      .date-day {
        color: #8D92A5;
      }

      .date-month {
        color: #000000DE;
      }

      .date-fallback {
        color: var(--pl-gray-olive);
      }

      .client-cell {
        max-width: 6em;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      .tags-cell {
        max-height: 1em;
        overflow-y: auto;
        max-width: 500px;
      }
    }
  }
  div.map { grid-area: map; }
  #plan-map {
    width: 100%;
    height: 100%;
  }
  div.selpanel {
    grid-area: selpanel;
    display: flex;
    margin: 5px 12px 5px 0;
    justify-content: space-between;
    padding: 6px 12px 6px 12px;
/*
    border: 1px solid var(--pl-dark-mustard);
    background-color: var(--pl-early-dawn);
*/
    border-radius: 4px;
  }

  address, div.adr {
    display: flex; 
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    font-style: normal;
    .city { font-weight: bold; }
    .twin {
      font-size: 82%;
      border: 1px solid #B5A60035;
      background-color: #B5A60005;
      color: var(--pl-sahara);
      border-radius: 4px;
      padding: 0px 3px;
      line-height: 1.3;
      margin-left: 9px;
      margin-top: 0px;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      vertical-align: middle;
      height: auto;
      max-height: 16px;
    }
    .comp {
      font-size: 96%;
      color: #aaa; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; width: 0px;
      border-radius: 5px;
    }
  }

  th { white-space: nowrap; }
  th.tags { width: 6em; max-width: 6em; }
/*
  td.rm { text-align: right }
  td.rm button {
    border-radius: 50%;
    border: 1px solid var(--pl-platinum);
  }
*/

  .map-term { font-size: 30px; border-radius: 50%; background-color: var(--pl); opacity: .7; }

  .term { 
    /* border: 1px solid #bbb; */
    border: 1px solid transparent;
    background: #E1E4EA;
    color: #212121;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: -0.36px;
    padding: 2px 6px;
    line-height: 1.4;
    border-radius: 4px;
    margin: 0;
    margin-right: 2px;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 18px;
    box-sizing: border-box;
    text-align: center;
    cursor: pointer;
    position: relative;
  }
  
  .term:last-child {
    margin-right: 0;
  }
  /* .term.jv, .term.kv { cursor: pointer; } */
  .term.act {
    background: var(--pl-pale-orange);
  }
  /* TODO: peaks olema fix laiusega, aga nende joinimised lähevad katki */
  /* margin: 0; text-align: center; box-sizing: border-box; width: 32px; padding-left: 0; padding-right: 0; margin-right; */
  .term.plan { background-color: #ffa600; color: white; }
  .term.done { background-color: #1e9f22; color: white; }
  th.due, td.due { width: 12em; }
  td.due .term {
    margin: 0 2px;
  }
  
  td.due {
    .alink, .blink, .link-left, .link-right { background-color: #fff8dd;  color: #212121; }
  }

  td.due .term.alink { border: 1px solid #ffa600; border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; border-right: 0 none; }
  td.due .term.blink { border: 1px solid #ffa600; border-top-left-radius : 0; border-bottom-left-radius:  0; margin-left:  0; border-left:  0 none; }

  td.due .term.link-left  { border: 1px solid #ffa600; margin-left:  0; border-top-left-radius:  0; border-bottom-left-radius:  0; border-left:  0 none; padding-left:  12px; }
  td.due .term.link-right { border: 1px solid #ffa600; margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0 none; padding-right: 12px; }

  /* Terminal pair styles */
  span.term-pair {
    display: inline-flex;
    gap: 0;
    position: relative;
    margin-right: 4px;
  }

  span.term-pair:last-child {
    margin-right: 0;
  }
  
  /* Highlighted pair styling - applied only when pair has active class */
  span.term-pair.active .term.pair-left {
    border: 1px solid #ffa600;
    border-right: none;
    background-color: #fff8dd;
    color: #212121;
  }
  
  span.term-pair.active .term.pair-right {
    border: 1px solid #ffa600;
    border-left: 1px solid #ffa600;
    background-color: #fff8dd;
    color: #212121;
  }

  span.term {
    &.pair-left {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
      margin-right: 0;
    }

    &.pair-right {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
      border-left: 1px solid #ffffff;
      margin-left: 0;
    }
  }

  td img.warnsign {
    height: 24px;
    margin: 0 4px;
  }

  .plandone { color: var(--pl-gray-olive); }

  .twarn {
    display: inline flow-root;
    height: 26px;
    width: 26px;
    padding-top: 3px;
    min-width: 26px;
    background-image: url(warning.svg);
    background-size: cover;
    text-align: center;
    line-height: 30px;
    box-sizing: border-box;
  }

  .loc-marker {
    border-radius: 4px;
    opacity: .76;
    /* border: 1px solid var(--pl-early-dawn); */
    min-width: 26px;
    min-height: 18px; height: 18px; line-height: 18px;
    box-sizing: border-box;
    text-align: center;
    color: white; /* var(--pl-champagne); */
    font-size: 12px;
    outline: none;
    filter: grayscale(40%);
    border: 2px solid transparent; /* hilight lisab borderi */
    display: flex; justify-content: center; align-items: center;
    transform: translate(0, 50%); /* marker pole mitte asukoha üleval vaid peal */
    transition: height .4s, border-radius .4s, opacity .4s;
    /* position: relative; */
    & *:focus { outline: none }
    &.a  { background-color: var(--a-color); } /* .loc-marker.a::after { display:none; border-top: 8px solid var(--a-color); } */
    &.b  { background-color: var(--b-color); } /* .loc-marker.b::after { display:none; border-top: 8px solid var(--b-color); } */
    &.a.b { background: linear-gradient(90deg, var(--a-color) 0%, var(--b-color) 100%); }
    &.sel { /* TODO: töötas vanasti, enam mitte */
      color: var(--pl-light-sky);
      /* height: 100px; width: 200px; */
/*
      background: linear-gradient(90deg, blue 50%, transparent 50%), linear-gradient(90deg, blue 50%, transparent 50%), linear-gradient(0deg, blue 50%, transparent 50%), linear-gradient(0deg, blue 50%, transparent 50%);
      background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
      background-size: 15px 4px, 15px 4px, 4px 15px, 4px 15px;
      background-position: 0px 0px, 200px 100px, 0px 100px, 200px 0px;
      padding: 10px;
      animation: border-dance 4s infinite linear;
*/
    }
  }

  .filt-date input { background-color: transparent; border: 1px solid var(--pl-sahara); padding: 1px 6px; color: var(--pl-rhino); border-radius: 4px; }
  .filt-date ul {
    list-style-type: none;
    margin: 0; padding: 0;
    li { line-height: 1.4em; }
    /* li:hover { color: var(--pl-topaz); } */
  }

/*
  .stop-pin {
    background-color: var(--pl-champagne);
    border: 1px solid var(--pl-cocoa);
  }
*/

  .total {
    display: flex; width: 100%;
    text-align: right;
    padding: 4px 8px 4px 0;
    box-sizing: border-box;

    .price, .dist, .dur { margin-left: 10px }
    .creator { text-align: left; padding-left: 8px; font-size: 90%; font-style: italic; color: var(--pl-aluminium); }
    .date  { flex-grow: 1; text-align: left; padding-left: 8px; font-size: 90%; font-style: italic; }
    .price { color: var(--pl-gray-olive); }
    .icon { margin: -2px 0px 0 0px; padding: 0 0 0 9px; font-size: 18px; color: inherit; vertical-align: middle; }
    .icon:hover { color: var(--pl-deep-sea); }
  }

  ul.shp { max-height: 50%; list-style-type: none; }

  div.heap {
    grid-area: heap;
    display: flex;
    position: absolute;
    flex-direction: column;
    max-height: 100%;
    width: 100%;

    ul { padding: 0; overflow: auto; flex-grow: 1; margin: 0; list-style-type: none }
    li { width: 100%; }

    .hi  .heap-head { background-color: #FFA952AA; }
    .new .heap-head { background-color: #FFA952AA; }

    .heap-head {
      width: 100%;
      background-color: var(--pl-early-dawn);
      /* background: linear-gradient(180deg, var(--pl-salmon-pink) 0%, var(--pl-early-dawn) 25%, var(--pl-early-dawn) 60%, white 95%); */
      color: var(--pl-deep-brown); /* without it also pretty */
      letter-spacing: .8px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: nowrap;
      height: 2.8em;
      border-top: 1px solid var(--pl-gray-olive);
      border-top-left-radius: 9px; border-top-right-radius: 9px;
      user-select: none;
      box-sizing: border-box;
      position: relative; /* to attach "Uus ring" div here */
      scroll-behavior: smooth;
      transition: background-color 1.2s .1s;

      &:hover .more { visibility: visible }

      .drv { max-width: 180px; }
      select.drv:focus { color: var(--pl-rhino); text-align: left; } /* TODO: pole hea, päis hüppab */

      .drag-over {
        position: absolute;
        width: 100%; /* TODO: scrollbar width javascriptiga kinni püüda ja css muutujaks teha (8px is random) */
        display: flex;
        justify-content: space-around;
        animation: fadeInOpacity ease .4s;
        background-color: rgba(255, 255,255,.65);
        border-top-left-radius: 6px; border-top-right-radius: 6px;
        box-sizing: border-box;
        height: 2.8em;
        text-align: center;
        line-height: 2.8em;
        padding: 0 20px;
        color: var(--pl-teal-green);
        font-size: 16px;
        user-select: none;
        pointer-events: none;
      }
      .drag { display: block; padding: 6px 8px; visibility: hidden; }

      .regnr { flex-grow: 1; padding: 4px 0 0 4px; vertical-align: bottom; }
      .more { width: 1.2em; text-align: right; padding-right: 4px; visibility: hidden; }

      &.combo .car { margin-left: 28px; }
      .car { width: 6em; max-width: 6em; }
      .trailer { width: 6.5em;}
      .space { flex-grow: 1; }
      /* .more menu li:first-child { border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; } */

      &.has-lap:hover .drag { display: inline flow-root; cursor: grab; visibility: visible; }
      /* &.has-lap */ .more:hover menu { display: block; position: relative; }
      /* span.emoji { font-size: 18px; padding-top: -16px; margin-top: -7px; } endine laadimismanifest */
      select {
        background-color: transparent;
        border: 0 none;
        color: inherit;
        /* border-bottom: 1px solid var(--pl-platinum); */
        padding: 6px 4px;
        text-align: right; /* TODO: option text-align: right */
      }
      select:focus { outline: none }
      select option { direction: rtl; }
      .act { width: 15px; }
    }

    .lap-content {
      display: grid;
    }

    table.small-lap {
      margin-left: 4px;

      .up-here, .down-here { background-color: #f5f5f5; }

      td { padding: 5px 0px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
/*
      td.track-dots { background: url(track-dots.png); background-repeat: repeat-y; background-position: 2.5px -1px; background-size: 77%; padding-left: 4px;  }
      td.track-dots span { display: block; border: 2px solid var(--pl-aluminium); width: 10px; height: 10px; border-radius:50%; background-color:white; box-sizing: border-box; transform: translate(1px, 1px); }
      td.track-dots span.up-here { background-color: var(--a-color); }
      td.track-dots span.down-here { background-color: var(--b-color); }
*/
      td.drag-indicator {  width: 20px; min-width: 20px; font-size: 20px; line-height: 20px; vertical-align: top; color: var(--pl-aluminium); cursor: grab; padding-left: 2px; overflow: visible; }
      td.drag-indicator * { display: none; position: relative; max-height: 6px; overflow: visible; }

      td:first-child { width: 1em; max-width: 1em; min-width: 1em; text-align: left; }
      td.ldm { font-family: Tahoma; width: 2.3em; min-width: 2.3em; white-space: nowrap; text-align: right; }
      td.ldm.pos { color: var(--pl-redwood); }
      td.ldm.neg { color: var(--pl-teal-green); }
      td.km  { width: 2em; min-width: 2em; white-space: nowrap; text-align: right; }
      td.adr { width: 100%; max-width: 100%; padding-left: 12px; }
      td.act {
        padding-right: 4px;
        white-space: nowrap;
        margin-left: 0;
        font-size: 14px;
        vertical-align: baseline;
        text-align: right;
        width: 28px;
        min-width: 28px;
        padding-left: 4px;
        .warn {
          transform: scale(1.2);
          color: var(--pl-neon-pink);
        }
      }

      tr.dragoverup  td { border-top: 1px solid transparent; padding-top: 4px; }
      tr.dragoverup  td:nth-child(3),
      tr.dragoverup  td:nth-child(4)
      { border-top   : 1px dashed var(--pl-deep-sea); padding-top: 4px; } /* TODO: it jumps becuse of border */

      tr.dragoverdown td { border-bottom: 1px solid transparent; padding-bottom: 4px; }
      tr.dragoverdown td:nth-child(3),
      tr.dragoverdown td:nth-child(4)
      { border-bottom: 1px dashed var(--pl-deep-sea); padding-bottom: 4px; }

      tr.dragoverup.invalid td:nth-child(3),
      tr.dragoverup.invalid td:nth-child(4) { border-top: 1px dashed red; padding-top: 4px; }
      tr.dragoverdown.invalid td:nth-child(3),
      tr.dragoverdown.invalid td:nth-child(4) { border-bottom: 1px dashed red; padding-bottom: 4px; }

      span.dur { width: 5em; display: inline flow-root; }
      span.km { margin-right: 12px; }
      span.company { display: inline flow-root; margin-left: 6px; color: var(--pl-rhino); opacity: .5; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; width: 0px; }

      td.time { width: 3.6em; min-width: 3.6em; text-align: right; opacity: .5 }
      span.time-label {
        animation: fadeInOpacity ease 1s;
        display: block;
        text-align: right;
        padding: 3px 3px 1px 3px;
        width: 3.2em;
        box-sizing: border-box;
        border-radius: 4px;
        font-size: 12px;
        color: white;
        border: 0px none;
        margin: -1px 0;
      }
      span.done  { background-color: var(--pl-forest); }
      span.issue { background-color: var(--pl-neon-pink); }
      span.canceled { background-color: var(--pl-platinum); text-align: center; }
      span.half-done  { background-color: var(--pl); }

      tr:hover {
        td.drag-indicator * {  display: block; }
      }

      .fold {
        cursor: pointer;
        color: var(--pl-muddy-brown);
        display: none;
      }
      tr:hover .fold { display: inline flow-root }

      tr.sub {
        height: 1.2em;
        td { padding-top: 0; padding-bottom: 0; font-size: 92%; }
        .adr { color: var(--pl-rhino); opacity: .6; }
/*
        .ldm {  }
        .track-dots span { border: 0 none; background-color: transparent; width: 6px; height: 6px; transform: translate(3px, 0); }
        .track-dots span.up-here { background-color: var(--a-color); }
        .track-dots span.down-here { background-color: var(--b-color); }
*/
      }

      /* multi-stop count */
      .count::before { content: " "; }
    }
  }

  menu.popbox.car-lap {
    white-space: nowrap;
    overflow: hidden;
    list-style-type: none;
    margin: 8px 0 0 8px;
    padding: 0;
    background-color: var(--pl-early-dawn);
    animation: fadeInOpacity ease .4s;
    border-radius: 6px;
    border: 1px solid var(--pl-gray-olive);
    box-shadow: 3px 3px 4px 0px var(--pl-gray-olive);

    li { width: 100%; border-bottom: 1px solid var(--pl-platinum); }
    li:last-child { border-bottom: 0px none; }
    li.term {
      font-size: 13px;
      width: 100%;
      padding: 8px 16px;
    }
    li.term span:hover { color: var(--pl-teal-green); }
    li.term span {
      display: inline flow-root;
      width: 5em;
      cursor: pointer
    }
    li.simple {
      padding: 8px 16px;
      cursor: pointer;
    }
    li.simple:hover { background-color: var(--pl-eggshell); color: var(--pl-teal-green); }
    li.simple.disabled { 
      color: gray;
      cursor: default;
      font-style: italic;
    }
    li.simple .icon {
      margin: auto 4px auto 0;
      text-align: bottom;
    }
/*
      border-top-right-radius: 4px;
      border-bottom-right-radius: 4px;
      border-bottom-left-radius: 4px;
*/
/*
    li.simple:last-child { border-bottom: 1px solid var(--pl-platinum); border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; }
    li.simple.disabled { color: var(--pl-fuzzy-brown); }
*/
  }

  div.selagg {
    font-size: 13px;
    display: flex;
    text-align: middle;
    align-items: center;
    cursor: default;
    .sum { /* background-color: #f7f7f7; padding: 3px 5px; */  border-radius: 6px; letter-spacing: .4px; padding-left: 8px; padding-right: 8px; padding-top: 1px; /* border: 1px solid var(--pl-eggshell); */ }

    .selected-count {
      padding-right: 8px;
      padding-left: 8px;
      padding-top: 1px;
      display: inline-flex;
      align-items: center;
      font-weight: 400;
      color: var(--pl-rhino);
      white-space: pre;
      line-height: 1;
    }

    .icon { 
      color: var(--pl-aluminium); 
      display: inline-flex; 
      align-items: center; 
      justify-content: center;
      margin-left: 4px;
      line-height: 1;
      cursor: pointer;
    }
    .icon:hover { color: var(--pl-rhino); }
    .opted { background-color: #FFA600; border-radius: 8px; color: white; }
  }


  .heap-control {
    display: flex; align-items: center;
    padding-left: 12px;
    input { padding: 2px 6px; outline: none; border-radius: 5px; border: 1px solid var(--pl-aluminium); }
    img { height: 20px; width: 20px; margin-left: 8px; cursor: pointer; }
  }

  .gps-marker {
    font-size: 16px;
    padding: 0px 4px;
    background-color: #FFFFFF;
    color: #504639;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    border: 1px solid #504639;
    text-align: center;
    border-radius: 4px;
  }
  .gps-marker.hi {
    background-color: var(--pl-pale-rose);
    color: var(--pl-dark-gray);
  }

  .out-of-bounds-info {
    background-color: #F5AD31;
    color: white;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 4px;
    transform: translateY(50%);
  }

  /* Infinity button styles */
  .infinity-button {
    width: auto;
    min-width: 24px;
    height: 24px;
    border-radius: 8px;
    padding: 6.5px 4px 6.5px 6.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    gap: 4px;
    border: 0.85px solid #ddd;
    background-color: transparent;

    &.active {
      border-color: #FFA600;
      background-color: #FFF8DD;
    }

    .msymbol {
      color: #263E50;
      font-size: 12px;
    }

    .badge {
      background-color: #FFA600;
      color: white;
      font-size: 10px;
      font-weight: 700;
      padding: 4px 6px;
      border-radius: 4px;
      line-height: 1;
      min-width: 14px;
      text-align: center;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
  }
}

