:root {
  --modern-bg: #eef3f8;
  --modern-surface: #ffffff;
  --modern-surface-2: #f8fafc;
  --modern-text: #172033;
  --modern-muted: #667085;
  --modern-border: #d9e2ec;
  --modern-primary: #1f6feb;
  --modern-primary-soft: #eaf2ff;
  --modern-run: #17a673;
  --modern-danger: #b42318;
  --classic-desktop: #008080;
  --classic-window: #c0c0c0;
  --classic-face: #d4d0c8;
  --classic-light: #ffffff;
  --classic-shadow: #808080;
  --classic-dark: #404040;
  --classic-title-start: #000080;
  --classic-title-end: #1084d0;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 980px;
  color: var(--modern-text);
  background:
    radial-gradient(circle at top left, rgba(31, 111, 235, 0.14), transparent 34%),
    linear-gradient(135deg, #f7fbff 0%, var(--modern-bg) 100%);
  font-family: "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
  font-size: 14px;
}

button {
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid var(--modern-border);
  border-radius: 7px;
  background: var(--modern-surface);
  color: var(--modern-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

button:hover {
  border-color: #b8c7d9;
  background: #f9fbfd;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

button:active,
button.active {
  border-color: var(--modern-primary);
  background: var(--modern-primary-soft);
  color: #0f3f91;
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.24);
  outline-offset: 2px;
}

.app-window {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  min-height: 680px;
  background: transparent;
}

.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--modern-border);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  backdrop-filter: blur(10px);
}

.title-text {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.title-text::before {
  content: "DFD";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1f6feb, #17a673);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  background: #172033;
  border-color: #172033;
  color: #ffffff;
}

.theme-toggle:hover {
  background: #24324a;
  border-color: #24324a;
}

.window-buttons {
  display: none;
}

.menu-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 14px 20px;
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid var(--modern-border);
}

.menu-bar button {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 292px;
  gap: 16px;
  min-height: 0;
  flex: 1;
  padding: 16px;
}

.toolbox {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--modern-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 34px rgba(16, 24, 40, 0.10);
}

.toolbox::before {
  content: "Herramientas";
  display: block;
  margin-bottom: 5px;
  color: var(--modern-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbox button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.run-button {
  margin-top: 8px;
  background: #e9fbf4;
  border-color: #9ee6c8;
  color: #067647;
}

.run-button:hover,
.run-button:active {
  background: #d9f7eb;
  border-color: var(--modern-run);
  color: #045f3a;
}

.fullscreen-button {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3447a8;
}

.center-button {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.center-button:hover,
.center-button:active {
  background: #ffedd5;
  border-color: #fb923c;
  color: #7c2d12;
}

.fullscreen-button:hover,
.fullscreen-button:active {
  background: #e0e7ff;
  border-color: #818cf8;
  color: #25318f;
}

.canvas-panel {
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--modern-border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(16, 24, 40, 0.10);
}

#diagramCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  cursor: crosshair;
}

.runtime-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
}

.runtime-box {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--modern-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 30px rgba(16, 24, 40, 0.08);
}

.runtime-box h2 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--modern-border);
  background: var(--modern-surface-2);
  color: var(--modern-text);
  font-size: 13px;
  font-weight: 800;
}

.runtime-box pre {
  flex: 1;
  min-height: 86px;
  margin: 0;
  padding: 13px 14px;
  overflow: auto;
  background: #ffffff;
  color: #1f2937;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

#errorsView {
  color: var(--modern-danger);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px 14px;
  color: var(--modern-muted);
  font-size: 13px;
}

.status-bar span {
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid rgba(217, 226, 236, 0.8);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
}

#statusText {
  min-width: 270px;
}

#hintText {
  flex: 1;
  text-align: right;
}

/* Classic visual mode keeps the previous retro shell. */
body.theme-classic {
  min-width: 0;
  padding: 12px;
  background: var(--classic-desktop);
  color: #111111;
  font-family: "MS Sans Serif", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
}

body.theme-classic button {
  min-height: 28px;
  padding: 4px 10px;
  border: 2px solid;
  border-radius: 0;
  border-color: var(--classic-light) var(--classic-dark) var(--classic-dark) var(--classic-light);
  background: var(--classic-face);
  color: #000000;
  font: inherit;
  font-weight: normal;
  cursor: pointer;
  box-shadow: none;
  transform: none;
  transition: none;
}

body.theme-classic button:hover {
  border-color: var(--classic-light) var(--classic-dark) var(--classic-dark) var(--classic-light);
  background: var(--classic-face);
  box-shadow: none;
}

body.theme-classic button:active,
body.theme-classic button.active {
  border-color: var(--classic-dark) var(--classic-light) var(--classic-light) var(--classic-dark);
  background: #b8b4ac;
  color: #000000;
}

body.theme-classic button:focus-visible {
  outline: 1px dotted #000000;
  outline-offset: -5px;
}

body.theme-classic .app-window {
  display: flex;
  flex-direction: column;
  width: min(1440px, calc(100vw - 24px));
  height: calc(100vh - 24px);
  min-height: 620px;
  margin: 0 auto;
  border: 2px solid;
  border-color: var(--classic-light) var(--classic-dark) var(--classic-dark) var(--classic-light);
  background: var(--classic-window);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

body.theme-classic .title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  height: 28px;
  padding: 3px 5px 3px 8px;
  border: 0;
  background: linear-gradient(90deg, var(--classic-title-start), var(--classic-title-end));
  color: #ffffff;
  font-weight: bold;
  box-shadow: none;
  backdrop-filter: none;
}

body.theme-classic .title-text {
  gap: 0;
  font-size: 13px;
  font-weight: bold;
}

body.theme-classic .title-text::before {
  content: none;
}

body.theme-classic .title-actions {
  gap: 6px;
}

body.theme-classic .theme-toggle {
  min-height: 22px;
  padding: 1px 8px;
  background: var(--classic-face);
  color: #000000;
  font-size: 12px;
}

body.theme-classic .window-buttons {
  display: flex;
  gap: 3px;
}

body.theme-classic .window-buttons span {
  width: 17px;
  height: 17px;
  border: 2px solid;
  border-color: var(--classic-light) var(--classic-dark) var(--classic-dark) var(--classic-light);
  background: var(--classic-face);
}

body.theme-classic .menu-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px;
  background: var(--classic-window);
  border-bottom: 2px solid var(--classic-shadow);
}

body.theme-classic .menu-bar button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 13px;
}

body.theme-classic .workspace {
  display: flex;
  min-height: 0;
  flex: 1;
  gap: 0;
  padding: 0;
}

body.theme-classic .toolbox {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 182px;
  padding: 9px;
  border: 0;
  border-right: 2px solid var(--classic-shadow);
  border-radius: 0;
  background: var(--classic-window);
  box-shadow: none;
}

body.theme-classic .toolbox::before {
  content: "Herramientas";
  display: block;
  margin-bottom: 2px;
  padding: 3px 4px;
  border: 1px solid var(--classic-shadow);
  background: #eeeeee;
  color: #000000;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0;
  text-transform: none;
}

body.theme-classic .toolbox button {
  width: 100%;
  text-align: left;
}

body.theme-classic .run-button {
  margin-top: 6px;
  background: #d8e7d0;
  color: #000000;
  font-weight: bold;
}

body.theme-classic .fullscreen-button {
  background: var(--classic-face);
  color: #000000;
}

body.theme-classic .center-button {
  background: var(--classic-face);
  color: #000000;
}

body.theme-classic .canvas-panel {
  flex: 1;
  min-width: 0;
  padding: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

body.theme-classic #diagramCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  cursor: crosshair;
}

body.theme-classic .runtime-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 270px;
  min-width: 240px;
  padding: 9px;
  border-left: 2px solid var(--classic-light);
  background: var(--classic-window);
}

body.theme-classic .runtime-box {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border: 2px solid;
  border-radius: 0;
  border-color: var(--classic-shadow) var(--classic-light) var(--classic-light) var(--classic-shadow);
  background: #eeeeee;
  box-shadow: none;
}

body.theme-classic .runtime-box h2 {
  margin: 0;
  padding: 4px 6px;
  border-bottom: 1px solid var(--classic-shadow);
  background: var(--classic-face);
  color: #000000;
  font-size: 13px;
  font-weight: bold;
}

body.theme-classic .runtime-box pre {
  flex: 1;
  min-height: 72px;
  margin: 0;
  padding: 7px;
  overflow: auto;
  background: #ffffff;
  color: #000000;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

body.theme-classic #errorsView {
  color: #7a0000;
}

body.theme-classic .status-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px;
  border-top: 2px solid var(--classic-light);
  color: #000000;
  font-size: 13px;
}

body.theme-classic .status-bar span {
  min-height: 22px;
  padding: 3px 6px;
  border: 1px solid;
  border-radius: 0;
  border-color: var(--classic-shadow) var(--classic-light) var(--classic-light) var(--classic-shadow);
  background: var(--classic-window);
}

body.theme-classic #statusText {
  min-width: 250px;
}

body.theme-classic #hintText {
  flex: 1;
  text-align: right;
}

@media (max-width: 1080px) {
  body {
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 190px minmax(720px, 1fr);
    grid-template-rows: minmax(0, 1fr) 220px;
  }

  .runtime-panel {
    grid-column: 1 / -1;
    flex-direction: row;
  }
}

@media (max-width: 980px) {
  body.theme-classic {
    padding: 6px;
  }

  body.theme-classic .app-window {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
  }

  body.theme-classic .workspace {
    flex-direction: column;
  }

  body.theme-classic .toolbox {
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
    border-right: 0;
    border-bottom: 2px solid var(--classic-shadow);
  }

  body.theme-classic .toolbox::before {
    width: 100%;
  }

  body.theme-classic .toolbox button {
    width: auto;
  }

  body.theme-classic .runtime-panel {
    width: auto;
    max-height: 230px;
    flex-direction: row;
    border-left: 0;
    border-top: 2px solid var(--classic-light);
  }

  body.theme-classic .status-bar {
    flex-direction: column;
  }

  body.theme-classic #hintText {
    text-align: left;
  }
}
