*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Arial', sans-serif;
  background: #007f82;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 50px;
}

h1 {
  color: #fce300;
  font-size: 24px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;

  img {
    width: 32px;
    height: auto;
  }
}

canvas {
  display: block;
  border: 2.5px solid #222;
  border-radius: 2px;
  box-shadow: 2px 2px #808080;
  background: #fff;
  max-width: 100%;
  max-height: 100%;
}

#canvas-container {
  position: relative;
}

#gridOverlay {
  position: absolute;
  top: 0;
  left: 0;
  background-size: 20px 20px;
  background-image:
    linear-gradient(to right, #e0e0e0 1px, transparent 1px),
    linear-gradient(to bottom, #e0e0e0 1px, transparent 1px);
  pointer-events: none;
  z-index: 2;
  display: none;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

header {
  grid-area: header;
  background: silver;
  padding: 2px;
  display: flex;
  align-items: center;

  button {
    border: 0;
    background: transparent;
    font-size: clamp(10px, 1.5vw, 12px);
    padding: 2px clamp(4px, 2vw, 8px);
    border-radius: 2px;
    cursor: pointer;
    height: clamp(18px, 2vw, 24px);
    min-width: clamp(18px, 8vw, 24px);

    &:hover,
    &:focus {
      box-shadow: 1px 1px black, inset -1px -1px gray, inset 1px 1px white;
    }
  }
}

main {
  grid-area: main;
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  height: 100%;
  min-height: 0;
}

#footer-color {
  grid-area: footer;
  background: #e0e0e0;
  padding: 8px;
  border-top: 2px solid #808080;
  display: flex;
  align-items: center;
  gap: 8px;
}

#container {
  border: 2.5px solid #808080;
  background: #c0c0c0;
  border-radius: 4px;
  box-shadow: 4px 4px 0 #222;
  display: grid;
  grid-template-areas:
    'header header header'
    'aside main main'
    'footer footer footer';
  grid-template-columns: 90px 1fr 1fr;
  /* aside fijo */
  grid-template-rows: auto 1fr auto;
  margin: 24px auto 0 auto;
  width: 50vw;
  max-width: 1200px;
  height: 50vh;
  min-height: 400px;
}

aside {
  grid-area: aside;
  background: #bdbdbd;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  padding-top: 8px;
  border-right: 2px solid #808080;
  display: flex;
  flex-direction: column;
  align-items: center;

  nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    justify-content: center;
    align-items: center;
  }

  button {
    background: #bdbdbd url('./icons/draw.png') no-repeat center;
    border: 1.5px solid #eee;
    border-right-color: #000;
    border-bottom-color: #000;
    image-rendering: pixelated;
    cursor: pointer;
    transition: border .1s, background .1s;

    width: 32px;
    height: 32px;
    background-size: 22px;

    &.active,
    &:focus {
      border: 2px inset #222;
      background-color: #b0b0b0;
      outline: none;
    }

    &:active {
      border: 2px inset #222;
      background-color: #a0a0a0;
    }

    &[disabled] {
      pointer-events: none;
      opacity: 0.5;
      filter: grayscale(.7);
    }
  }
}

#drawBtn {
  background-image: url('./icons/draw.png');
}

#eraseBtn {
  background-image: url('./icons/erase.png');
}

#rectangleBtn {
  background-image: url('./icons/rectangle.png');
}

#ellipseBtn {
  background-image: url('./icons/ellipse.png');
}

#pickerBtn {
  background-image: url('./icons/picker.png');
}

#clearBtn {
  background-image: url('./icons/trash.png');
}

#color-picker {
  border: 2px inset #808080;
  width: 8%;
  height: 38px;
  background: #fff;
  cursor: pointer;
  margin-left: 8px;
}

/* Responsive */
@media (max-width: 900px) {
  #container {
    width: 99vw;
    min-height: 400px;
    grid-template-columns: 60px 1fr 1fr;
  }

  aside {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
  }

  aside button {
    width: 22px;
    height: 22px;
    background-size: 14px 14px;
  }

  h1 img {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 600px) {
  #container {
    grid-template-areas:
      'header'
      'main'
      'footer';
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    width: 100vw;
    min-height: 100vh;
    margin: 0;
  }

  aside {
    display: none;
  }

  main {
    padding: 0;
  }

  canvas {
    border-width: 1.5px;
  }

  footer {
    padding: 8px 4px;
    gap: 8px;
  }
}

.menu-container {
  position: relative;
  display: inline-block;
  z-index: 3;
}

.dropdown {
  display: none;
  position: absolute;
  background-color: #f1f1f1;
  min-width: 120px;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border: 1px solid #ccc;
}

.dropdown button {
  width: 100%;
  padding: 6px;
  text-align: left;
  background: #e0e0e0;
  border: none;
  cursor: pointer;
}

.dropdown button:hover {
  background-color: #c9c9c9;
}

#optionsMenu label {
  display: block;
  padding: 6px;
  font-size: 12px;
}

#optionsMenu input[type="range"],
#optionsMenu select {
  width: 100%;
}

.modal {
  display: none;
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(50, 50, 50, 0.35);
  /* Gris oscuro translúcido */
}

.modal-content {
  background: #d4d4d4;
  /* Gris base */
  border: 2px solid #808080;
  border-top-color: #f5f5f5;
  /* borde superior más claro */
  border-left-color: #f5f5f5;
  box-shadow: 4px 4px 0 #3a3a3a;
  margin: 8% auto;
  width: 62%;
  padding: 0;
  font-family: 'Tahoma', sans-serif;
  font-size: 13px;
  color: #111;
}

.modal-header {
  background: linear-gradient(to bottom, #d0e4ff, #a9c9f7);
  /* degradado gris */
  color: #000;
  padding: 4px 6px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #808080;
  height: 22px;
  text-shadow: 1px 1px #e0e0e0;
}

.modal-header .close {
  background: #c0c0c0;
  border: 2px outset #fff;
  color: #000;
  font-size: 12px;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 15px;
  cursor: pointer;
  margin-left: 6px;
  box-shadow: inset 1px 1px #fff, inset -1px -1px #808080;
}

.modal-header .close:hover {
  background: #e57373;
}

.modal-body {
  padding: 12px;
  background: #e5e5e5;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  border-right: 2px solid #808080;
  border-bottom: 2px solid #808080;
}

.modal-body p {
  margin: 5px 0;
  line-height: 1.4em;
  color: #222;
}

#app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background: #c0c0c0;
  border-top: 2px solid #808080;
  border-left: 2px solid #fff;
  padding: 0 16px;
  font-family: 'Tahoma', sans-serif;
  font-size: 13px;
  color: #222;
  line-height: 40px;
  box-shadow: inset 1px 1px #fff, inset -1px -1px #808080;
  z-index: 1000;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  text-align: center;
}

.footer-text {
  color: #111;
}

.footer-link {
  color: #000080;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-links {
  list-style: none;
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 0;
}