/* BRUTALIST GRAFFITI NOTEPAD */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: monospace;
  background: #000;
  color: #fff;
  margin: 0;
  padding: 0;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  touch-action: none;
}

/* CONFIDENCE BAR */
#confidence {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 6px;
  background: #fff;
  border-top: 2px solid #000;
  transition: width 0.2s linear;
  z-index: 300;
}

/* OUTPUT PANEL */
#output {
  height: 30vh;
  border-bottom: 3px solid #fff;
  padding: 1rem;
  padding-top: calc(1rem + 8px);
  overflow-y: auto;
  background: #000;
  position: relative;
}

#output-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  z-index: 10;
}

#output-controls button {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: bold;
  background: #fff;
  color: #000;
  border: 2px solid #fff;
  cursor: pointer;
  text-transform: uppercase;
}

#output-controls button:hover {
  background: #00CED1;
  border-color: #00CED1;
}

#output-controls button:active {
  background: #fff;
}

#text {
  font-size: 1.5rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
  font-weight: bold;
  padding-right: 10rem;
}

#text::after {
  content: '█';
  color: #00CED1;
  font-weight: bold;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* CANVAS */
#stage {
  height: 70vh;
  width: 100%;
  background: #fff;
  cursor: crosshair;
  display: block;
  position: relative;
  z-index: 1;
}

/* TEXT CONTROLS (LEFT SIDE) */
#text-controls {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

#text-controls button {
  padding: 0.75rem;
  width: 60px;
  height: 60px;
  border: 3px solid #000;
  background: #fff;
  color: #000;
  font-family: monospace;
  font-weight: bold;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#text-controls button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

#text-controls button:hover {
  background: #00CED1;
  color: #000;
}

/* CONTROLS (RIGHT SIDE) */
#controls {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

#controls button {
  padding: 0.75rem 1rem;
  border: 3px solid #000;
  background: #fff;
  color: #000;
  font-family: monospace;
  font-weight: bold;
  font-size: 0.9rem;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
  transition: all 0.1s;
}

#controls button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

#mode-btn[data-mode="training"] {
  background: #000;
  color: #fff;
  border-color: #fff;
  box-shadow: 4px 4px 0 #fff;
}

#mode-btn[data-mode="training"]:active {
  box-shadow: 2px 2px 0 #fff;
}

/* TRAINING OVERLAY */
#training {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 35vh;
  background: #000;
  border-bottom: 3px solid #fff;
  padding: 1rem;
  z-index: 100;
  overflow-y: auto;
}

#training.hidden {
  display: none;
}

.training-inner {
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  position: relative;
}

.factory-reset-btn {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  font-family: monospace;
  font-weight: bold;
  background: #ff0000;
  color: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 #000;
  transition: all 0.1s;
}

.factory-reset-btn:hover {
  background: #cc0000;
}

.factory-reset-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}

.training-inner h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  letter-spacing: 2px;
}

#char-input {
  width: 80px;
  padding: 0.5rem;
  font-size: 1.5rem;
  font-family: monospace;
  font-weight: bold;
  text-align: center;
  background: #fff;
  color: #000;
  border: 3px solid #fff;
  text-transform: uppercase;
}

#char-input:focus {
  outline: none;
  background: #000;
  color: #fff;
}

#samples {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sample-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.sample-canvas {
  border: 2px solid #fff;
  background: #fff;
  display: block;
  width: 60px !important;
  height: 60px !important;
}

.sample-box span {
  font-weight: bold;
  font-size: 0.8rem;
}

#training-status {
  text-align: center;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  font-weight: bold;
  letter-spacing: 1px;
}

#preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0.5rem;
}

#preview-container.hidden {
  display: none;
}

#preview-canvas {
  border: 3px solid #00CED1;
  background: #fff;
}

.training-buttons {
  display: flex;
  gap: 0.5rem;
}

.training-buttons button {
  flex: 1;
  padding: 0.5rem;
  border: 2px solid #fff;
  background: #fff;
  color: #000;
  font-family: monospace;
  font-weight: bold;
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 #fff;
  transition: all 0.1s;
}

.training-buttons button:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #fff;
}

.training-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.training-buttons button.hidden {
  display: none;
}

#save-training {
  background: #000;
  color: #fff;
}

#retry-training {
  background: #FF4444;
  color: #fff;
  border-color: #FF4444;
}

/* EXPORT MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  padding: 2rem;
  border: 3px solid #fff;
  background: #000;
}

.modal-content h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
  letter-spacing: 2px;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.export-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1rem;
  border: 3px solid #fff;
  background: #000;
  color: #fff;
  font-family: monospace;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.export-option:hover {
  background: #fff;
  color: #000;
  transform: translateX(4px);
}

.export-option:active {
  transform: translateX(2px);
}

.export-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.export-label {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.export-desc {
  font-size: 0.8rem;
  opacity: 0.8;
}

.modal-buttons {
  display: flex;
  justify-content: center;
}

.modal-buttons button {
  padding: 0.75rem 2rem;
  border: 2px solid #fff;
  background: #fff;
  color: #000;
  font-family: monospace;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 #fff;
  transition: all 0.1s;
}

.modal-buttons button:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #fff;
}

/* PREVIEW MODAL */
.preview-modal-content {
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

#preview-svg-container {
  margin-bottom: 1.5rem;
  border: 3px solid #fff;
  background: #000;
  overflow: auto;
  max-height: 70vh;
}

#preview-svg-container svg {
  display: block;
  width: 100%;
  height: auto;
}

/* MOBILE OPTIMIZATIONS */
@media (max-width: 600px) {
  #controls button {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  
  .training-inner {
    padding: 1rem;
  }
  
  .sample-canvas {
    width: 80px !important;
    height: 80px !important;
  }
  
  .modal-content {
    padding: 1rem;
  }
  
  .export-icon {
    font-size: 1.5rem;
  }
  
  .export-label {
    font-size: 1rem;
  }
}
