@charset "UTF-8";
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

/* ==============================================
   ROOT VARIABLES
   ============================================== */
:root {
  --font-family: 'Poppins', sans-serif;
  --primary-bg: #ffffff;
  --secondary-bg: #e5e7eb;
  --bg-code: #f1f3f4;
  --white: #fff;
  --border-color: #d9d9d9;
  --border-color-light: #dfdfdf;
  --hover-bg: #e5e7eb;
  --flyout-bg: rgba(250, 250, 250, 0.6);
  --text-color: #000;
  --bg-button: #f3f4f6;
  --text-toast: #364153;
  --hover-green: #bef8c8;
  --hover-export-bg: #f0fdf4;
  --scroll-color: #ccc;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 20px;

  /* Toolbox */
  --toolbox-width: 10em;
  --toolbox-width-mobile: 7em;

  /* Category */
  --category-height: 40px;
  --category-height-mobile: 32px;

  /* Radii */
  --border-radius: 0.5rem;
  --border-radius-lg: 24px;

  /* Sidebar panel widths */
  --sidebar-width-config: 383px;
  --sidebar-width-exemplos: 319px;

  /* Header & sidebar rail — fluid via clamp */
  --header-height: clamp(48px, 7vh, 72px);
  --sidebar-rail: clamp(44px, 5.5vw, 72px);

  /* Transitions */
  --transition-speed: 500ms;
  --transition-fast: 200ms;
}

/* ==============================================
   DARK THEME OVERRIDES
   ============================================== */
[data-theme='dark'] {
  --primary-bg: #18181b;
  --secondary-bg: #292929;
  --bg-code: #09090b;
  --white: #1f2937;
  --border-color: #3c3c3e;
  --border-color-light: #4b5563;
  --hover-bg: #3f3f46;
  --flyout-bg: rgba(31, 41, 55, 0.6);
  --text-color: #f9fafb;
  --bg-button: #27272a;
  --text-toast: #d1d1d1;
  --hover-green: #234d2a;
  --hover-export-bg: #002d0d;
  --scroll-color: #383838;
}

/* ==============================================
   BASE STYLES
   ============================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast);
  user-select: none;
}

body {
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  background-color: var(--secondary-bg);
  overflow: hidden;
  /* Prevent any accidental horizontal scroll */
  overflow-x: hidden;
}

body.voucher-modal-open {
  overflow: hidden;
}

/* ==============================================
   VOUCHER AUTH MODAL
   ============================================== */
.voucher-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    background-color 180ms ease;
}

.voucher-modal-overlay.voucher-modal-visible {
  background: rgba(0, 0, 0, 0.52);
  opacity: 1;
  pointer-events: auto;
}

.voucher-modal {
  position: relative;
  width: min(100%, 420px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--primary-bg);
  color: var(--text-color);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.28);
  padding: 1.5rem;
  transform: translateY(14px) scale(0.98);
  transition: transform 180ms ease;
}

.voucher-modal-visible .voucher-modal {
  transform: translateY(0) scale(1);
}

.voucher-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-color);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.voucher-modal-close:hover,
.voucher-modal-close:focus {
  background: var(--hover-bg);
  outline: none;
}

.voucher-modal-title {
  margin: 0 2.5rem 0.5rem 0;
  font-size: 1.25rem;
  line-height: 1.25;
  font-weight: 600;
}

.voucher-modal-description {
  margin: 0 0 1.25rem 0;
  color: #6b7280;
  font-size: 0.92rem;
  line-height: 1.5;
}

[data-theme='dark'] .voucher-modal-description {
  color: #a1a1aa;
}

.voucher-modal-form {
  display: grid;
  gap: 0.75rem;
}

.voucher-modal-label {
  color: var(--text-color);
  font-size: 0.85rem;
  font-weight: 500;
}

.voucher-modal-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border-color);
  border-radius: 0.65rem;
  background: var(--secondary-bg);
  color: var(--text-color);
  padding: 0.75rem 0.9rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  outline: none;
}

.voucher-modal-input:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}

.voucher-modal-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.voucher-modal-error {
  margin: -0.25rem 0 0 0;
  color: #ef4444;
  font-size: 0.82rem;
  line-height: 1.35;
}

.voucher-modal-submit {
  min-height: 44px;
  border: 0;
  border-radius: 0.65rem;
  background: #16a34a;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    opacity 160ms ease;
}

.voucher-modal-submit:hover,
.voucher-modal-submit:focus {
  background: #15803d;
  outline: none;
}

.voucher-modal-submit:disabled,
.voucher-modal-input:disabled {
  opacity: 0.68;
  cursor: wait;
}

@media (max-width: 480px) {
  .voucher-modal {
    padding: 1.25rem;
  }

  .voucher-modal-title {
    font-size: 1.12rem;
  }

  .voucher-modal-input {
    font-size: 1.15rem;
  }
}

/* ==============================================
   SIDEBAR RAIL (sideBarFuncoes)
   ============================================== */
[name='sideBarFuncoes'] {
  width: var(--sidebar-rail) !important;
}

/* Icon buttons inside rail */
.sidebar-btn {
  display: flex;
  width: 100%;
  justify-content: center;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
}

.sidebar-btn:hover {
  background: var(--hover-bg);
  cursor: pointer;
}

/* Rail icon sizes — fluid */
.sidebar-icon {
  width: clamp(28px, 3.5vw, 46px);
  height: clamp(28px, 3.5vw, 46px);
  transition: filter 0.3s ease;
}

[data-theme='dark'] .sidebar-icon {
  filter: brightness(1.7);
}

.sidebar-icon.open {
  filter: none;
}

#theme-icon {
  width: clamp(22px, 2.8vw, 30px);
  height: clamp(22px, 2.8vw, 30px);
  filter: brightness(1.3);
}

[data-theme='dark'] #theme-icon {
  filter: brightness(2.5);
}

/* ==============================================
   LAYOUT SHIFT HELPERS (JS-driven)
   Only push the workspace on larger screens
   ============================================== */
@media (min-width: 1024px) {
  .moveConfig {
    width: calc(
      100vw - var(--sidebar-rail) - var(--sidebar-width-config)
    ) !important;
  }

  .moveExemplos {
    width: calc(
      100vw - var(--sidebar-rail) - var(--sidebar-width-exemplos)
    ) !important;
  }
}

/* Agnostic open class for sidebar panels */
.sidebar-panel-open {
  transform: translateX(var(--sidebar-rail)) !important;
}

/* Component bars base and open states */
.component-bar-open {
  transform: translateX(var(--sidebar-rail)) !important;
}

/* Desktop push effect for component bars */
@media (min-width: 1024px) {
  #sideBarConfig.sidebar-panel-open ~ #divNegraComponentes.component-bar-open,
  #sideBarConfig.sidebar-panel-open ~ * .component-bar-open {
    transform: translateX(
      calc(var(--sidebar-rail) + var(--sidebar-width-config))
    ) !important;
  }

  #sideBarExemplos.sidebar-panel-open ~ #divNegraComponentes.component-bar-open,
  #sideBarExemplos.sidebar-panel-open ~ * .component-bar-open {
    transform: translateX(
      calc(var(--sidebar-rail) + var(--sidebar-width-exemplos))
    ) !important;
  }
}

/* ==============================================
   BLOCKLY CONTAINER
   ============================================== */
#blockly-container {
  position: fixed;
  bottom: 0;
  right: 0;
  width: calc(100vw - var(--sidebar-rail));
  height: calc(100vh - var(--header-height));
  background-color: var(--bg-code);
}

#bg-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#blocklyDiv {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: transparent !important;
}

.blocklySvg {
  background: transparent !important;
}

/* ==============================================
   TOOLBOX
   ============================================== */
.blocklyToolboxDiv {
  background-color: var(--primary-bg);
  border-right: 0.5px solid var(--border-color);
  padding: var(--spacing-xs);
  overflow-y: auto;
  overflow-x: hidden;
  color: var(--text-color);
}

.blocklyToolboxContents {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  padding: var(--spacing-sm);
  padding-top: var(--spacing-md);
  /* Fluid width: collapses gracefully on very small screens */
  width: clamp(5rem, 12vw, 12rem);
  min-width: clamp(5rem, 12vw, 12rem);
}

.blocklyToolboxCategory {
  height: clamp(28px, 4.5vh, 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--spacing-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast) ease;
}

.blocklyTreeSeparator {
  display: none;
}

.blocklyTreeRow {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: var(--border-radius);
  transition: background-color var(--transition-fast) ease;
}

.blocklyTreeRow:not(.blocklyTreeSelected):hover {
  background-color: var(--hover-bg);
}

.blocklyTreeLabel {
  fill: var(--text-color);
  font-family: var(--font-family);
  /* Fluid label: readable even at 200px wide */
  font-size: clamp(8pt, 1.4vw, 13pt);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}

.blocklyTreeIcon {
  width: 0 !important;
  height: 0 !important;
  display: none;
}

/* ==============================================
   FLYOUT
   ============================================== */
.blocklyFlyout {
  border-top-right-radius: var(--border-radius-lg);
  background-color: var(--flyout-bg);
  z-index: 20;
  color: var(--text-color);
  backdrop-filter: blur(8px);
  border-right: 0.5px solid var(--border-color-light);
  transform: translate(20px, 50px);
}

.blocklyFlyoutBackground {
  fill: transparent;
}

.blocklyFlyoutLabelText {
  fill: var(--text-color);
}

/* ==============================================
   SCROLLBARS
   ============================================== */
.blocklyScrollbarVertical {
  width: 0 !important;
  display: none;
}

#sideBarExemplos,
#sideBarExtensoes,
#body,
#tutoriais {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#sideBarExemplos::-webkit-scrollbar,
#sideBarExtensoes::-webkit-scrollbar,
#body::-webkit-scrollbar,
#tutoriais::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* ==============================================
   TRASH CAN
   ============================================== */
.blocklyTrash {
  position: fixed !important;
  bottom: clamp(6px, 1.5vw, 10px);
  right: clamp(6px, 1.5vw, 10px);
  z-index: 1000;
}

/* ==============================================
   TOAST
   ============================================== */
.toastify {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

/* ==============================================
   NAVBAR HEADER
   ============================================== */
nav {
  height: var(--header-height);
}

/* Logo fluid */
#logo_navbar {
  width: clamp(90px, 14vw, 180px);
  height: auto;
}

/* ==============================================
   SIDEBAR PANELS (Config, Exemplos, Extensoes)
   ============================================== */

/* All lateral panels: width caps so they never overflow tiny screens */
#sideBarConfig {
  width: min(
    var(--sidebar-width-config),
    calc(100vw - var(--sidebar-rail))
  ) !important;
}

#sideBarExemplos {
  width: min(
    var(--sidebar-width-exemplos),
    calc(100vw - var(--sidebar-rail))
  ) !important;
}

/* Component bars: ensure they also respect viewport bounds */
#divNegraComponentes,
#barControles,
#barLeds,
#barMotores,
#barDisplay,
#barSons,
#barSensores {
  width: min(320px, calc(100vw - var(--sidebar-rail))) !important;
  max-width: calc(100vw - var(--sidebar-rail)) !important;
}

/* Padding inside panels scales with viewport */
#sideBarConfig,
#sideBarExemplos,
#sideBarExtensoes {
  padding: clamp(12px, 2vw, 20px);
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

/* ==============================================
   TOOLTIP
   ============================================== */
.blocklyTooltipDiv {
  background: #ffffff;
  color: #1e293b;
  border-radius: 14px;
  padding: 8px 12px;
  font-family: 'Poppins', sans-serif;
  font-size: clamp(12px, 1.4vw, 16px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
  max-width: clamp(140px, 20vw, 220px);
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.blocklyTooltipDiv::first-letter {
  text-transform: uppercase;
}

.blocklyTooltipDiv.show,
.blocklyTooltipDiv.hide {
  opacity: 1;
  transform: none;
}

.blocklyTooltipDiv span {
  display: block;
  overflow-wrap: break-word;
}

.blocklyTooltipDiv::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

/* ==============================================
   COMPACT SCREENS  ≤ 480px  (phones portrait)
   ============================================== */
@media (max-width: 480px) {
  :root {
    --sidebar-rail: 44px;
    --header-height: 48px;
    --sidebar-width-config: calc(100vw - 44px);
    --sidebar-width-exemplos: calc(100vw - 44px);
  }

  .blocklyToolboxContents {
    width: clamp(4.5rem, 18vw, 7rem);
    min-width: clamp(4.5rem, 18vw, 7rem);
    gap: var(--spacing-md);
    padding: var(--spacing-xs);
  }

  .blocklyToolboxCategory {
    height: 28px;
    padding: 0 4px;
  }

  .blocklyTreeLabel {
    font-size: clamp(7pt, 2.5vw, 9pt);
  }

  /* Navbar buttons: icon-only */
  #compile span.hidden,
  #upload span.hidden {
    display: none !important;
  }
}

/* ==============================================
   VERY NARROW / EMBEDDED  ≤ 320px
   ============================================== */
@media (max-width: 320px) {
  :root {
    --sidebar-rail: 36px;
    --header-height: 44px;
  }

  .blocklyToolboxContents {
    width: 4rem;
    min-width: 4rem;
    gap: var(--spacing-sm);
    padding: 2px;
  }

  .blocklyTreeLabel {
    font-size: 7pt;
  }

  .sidebar-icon {
    width: 24px;
    height: 24px;
  }
}

/* ==============================================
   TOUCH DEVICES
   ============================================== */
@media (hover: none) and (pointer: coarse) {
  .blocklyToolboxCategory {
    min-height: 44px;
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .blocklyTreeRow {
    min-height: 44px;
  }

  .blocklyToolboxDiv {
    -webkit-overflow-scrolling: touch;
  }
}

/* ==============================================
   LANDSCAPE / SHORT VIEWPORT
   ============================================== */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --header-height: clamp(40px, 8vh, 48px);
    --sidebar-rail: clamp(40px, 5vw, 52px);
  }

  .blocklyToolboxContents {
    gap: var(--spacing-sm);
    padding: var(--spacing-xs);
  }

  .blocklyToolboxCategory {
    height: 28px;
  }
}

/* ==============================================
   LARGE SCREENS  ≥ 1280px
   ============================================== */
@media (min-width: 1280px) {
  .blocklyToolboxContents {
    width: 12em;
    min-width: 12em;
  }
}

/* ==============================================
   HIGH-DPI
   ============================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .blocklyToolboxDiv {
    border-left-width: 0.5px;
  }
}

/* ==============================================
   PRINT
   ============================================== */
@media print {
  #blocklyDiv {
    position: static;
    width: 100%;
    height: auto;
  }

  .blocklyToolboxDiv,
  .blocklyTrash {
    display: none;
  }
}
