html {
  /** For normal scaling of rem and em in PDF */
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: #2c2c2c;
  font-family: sans-serif;
}

#browserAdvice {
  display: none;
  color: goldenrod;
  font-weight: bold;
  font-size: 14px;
}

#document-status {
  color: white;
  font-size: 14px;
  display: flex;
  gap: 0.5em;
  align-items: center;
}

#editor-container {
  flex: 0 0 auto;
  width: 50%;
  min-width: 200px;
  flex-direction: column;
  background: #1e1e1e;
  border-right: 2px solid #000;
  overflow: hidden;
  display: flex;
  overflow-anchor: none;

  .toolbar {
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    border-bottom: 2px solid #000;
    position: sticky;
    top: 0;
    z-index: 100;

    .spacer {
      width: 2px;
    }

    .toolbar-row {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      padding: 4px 8px;
      border-bottom: 1px solid #333;

      button,
      input[type="file"]::file-selector-button {
        background: #3c3c3c;
        color: #eee;
        border: 1px solid #555;
        padding: 4px 10px;

        font-family: sans-serif;
        line-height: 1.2;
        cursor: pointer;
        transition: color 0.2s;

        border-radius: 2px;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }

      .active {
        background: green;
        border-color: darkgreen;
      }

      button:hover,
      input[type="file"]::file-selector-button:hover {
        background: #555;
        border-color: #888;
      }

      select {
        background: #3c3c3c;
        color: #eee;
        padding: 4px 10px;
        border: 1px solid #555;
        width: 120px;
        max-width: 120px;
        min-width: 120px;
        overflow: hidden;

        &:hover {
          background: #555;
          border-color: #888;
        }
        option {
          min-width: 140px;
          width: auto;
        }
      }
    }

    .row-elements {
      background: #252525;
    }

    .row-project {
      background: #111;
      padding: 6px 12px;
      border-bottom: 1px solid #000;
      align-items: baseline;

      button {
        background: transparent !important;
        border: none !important;
        color: #aaa !important;
        font-size: 12px;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 2px 8px;
        transition: color 0.2s;
        border-radius: 0;
      }

      button:hover {
        color: #fff !important;
        text-decoration: none;
        background: transparent !important;
      }

      .spacer {
        padding-left: 5px;
        padding-right: 5px;
      }

      button[onclick*="clearEditor"]:hover {
        background: #f44 !important;
        color: black !important;
      }
    }
  }

  .btn-pdf {
    background: #611 !important;
  }

  .tool-dropdown {
    position: relative;
    display: inline-block;

    .dropbtn {
      background: #2e4a3e;
      color: white;
      padding: 6px 12px;
      border: none;
      cursor: pointer;
      border-radius: 4px;
    }

    /* Das versteckte Panel */
    .dropdown-content {
      position-area: bottom;
      inset: auto;
      background: #f9f9f9;
      min-width: 300px;
      box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
      padding: 12px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }

    .list-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px;
      border-bottom: 1px solid #eee;
      font-size: 10px;

      &:hover {
        background: #ddd;
        cursor: pointer;
      }
    }

    button.delete-small-btn {
      background: #a22;
      color: white;
      border: none;
      padding: 2px 8px;
      cursor: pointer;
      border-radius: 3px;
      font-size: 0.8em;
    }
    table {
      border-collapse: collapse;
      width: 100%;
    }
    tr:hover {
      background: #ddd;
      cursor: pointer;
    }
    td {
      padding: 0.4em;
      border: 1px solid #ccc;
    }
  }

  #localimages-dialog {
    /* Styling für die Liste im Manager */
    #localimages-list {
      list-style: none;
      padding: 0;
      max-height: 200px;
      overflow-y: auto; /* Scrollbar falls viele Bilder */

      li {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 0;
        border-bottom: 1px solid #eee;
        font-size: 11px;
      }
    }

    .img-name-link {
      cursor: pointer;
      color: #2c3e50;
      font-weight: bold;
      text-decoration: underline dotted;
      flex-grow: 1; /* Nimmt den Platz links vom X ein */
      padding: 2px 5px;

      &:hover {
        background: #e0e0e0;
        color: #000;
      }
    }

    .delete-btn {
      background: #ff4444;
      color: white;
      border: none;
      border-radius: 3px;
      padding: 2px 6px;
      cursor: pointer;
    }
  }

  #sizetable-dialog {
    table {
      border-collapse: collapse;
      border: 1px solid black;
      width: 100%;
    }

    tr:nth-child(odd) {
      background: gainsboro;
    }

    td,
    th {
      border: 1px solid black;
      padding: 2px;
    }

    th {
      background: silver;
    }

    th:nth-child(2),
    th:nth-child(3),
    td:nth-child(2),
    td:nth-child(3) {
      text-align: right;
    }
  }
}

#resizer {
  width: 16px;
  cursor: col-resize;
  background: #909090;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-inline 0.2s;
  border-inline: 1px solid #1a1a1a;
  z-index: 10;

  &::after {
    content: "";
    width: 4px;
    height: 30px;
    background-image: radial-gradient(circle, #2c2c2c 1.5px, transparent 1.5px);
    background-size: 100% 8px;
    background-position: center;
  }

  &:hover {
    background: #2c2c2c;
    border-inline: 1px solid #555;
  }

  &:hover::after {
    background-image: radial-gradient(circle, #ffffff 1.5px, transparent 1.5px);
  }
}

#editor {
  flex: 1;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 12px;
  font-family: monospace;
  font-size: 18px;
  border: none;
  outline: none;
  resize: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}

#preview-container {
  flex: 1 1 0;
  min-width: 0;
  background: #444;
  overflow-y: auto;
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

.show {
  display: block;
}
