@import url('https://fonts.googleapis.com/css?family=Google+Sans:400,500,700');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

body {
  background: white !important;
  margin: 0;
  font-family: 'Google Sans', sans-serif;
}

/* ========== WELCOME MODAL ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-overlay.hidden {
  animation: fadeOut 0.3s ease forwards;
  pointer-events: none;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.modal-card {
  background: white;
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 420px;
  width: 90%;
  animation: slideUp 0.4s ease;
  border: 4px solid transparent;
  background-clip: padding-box;
  position: relative;
}

.modal-card::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 26px;
  background: linear-gradient(135deg, #9C27B0, #FF9800, #4CAF50, #2196F3);
  z-index: -1;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 12px;
  border-radius: 16px;
}

.modal-card h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #1a1a2e;
}

.modal-subtitle {
  font-size: 16px;
  color: #666;
  margin: 0 0 20px;
}

.modal-input {
  width: 100%;
  padding: 14px 20px;
  font-size: 18px;
  font-family: 'Google Sans', sans-serif;
  border: 3px solid #e0e0e0;
  border-radius: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}

.modal-input:focus {
  border-color: #9C27B0;
  box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.15);
}

.start-btn {
  margin-top: 20px;
  padding: 14px 40px;
  font-size: 20px;
  font-weight: 700;
  font-family: 'Google Sans', sans-serif;
  color: white;
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.start-btn:active {
  transform: scale(0.98);
}

/* ========== USER GREETING ========== */
.user-greeting {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin: 0;
}

/* ========== APP CONTAINER ========== */
.app-container {
  --bg: white;
  --font-family: 'Google Sans';
}

.app-container {
  background-color: #f0f0f5;
  border-radius: 30px;
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ========== WORKSPACE PANEL ========== */
.workspace-panel {
  flex: 3;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 28px 0 28px 28px;
  border-radius: 20px;
  overflow: visible;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  flex: 0 0 auto;
}

@media screen and (max-width: 840px) {
  .app-container {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .workspace-panel {
    flex: none;
    height: 55vh;
    margin: 16px 16px 0;
  }

  #outputDiv {
    flex: 1;
    min-width: 0;
    max-width: none;
    margin: 16px;
  }
}

/* ========== BLOCKLY DIV ========== */
#blocklyDiv {
  background: var(--bg);
  flex: 1;
  min-height: 0;
  padding: 20px;
  position: relative;
}

/* ========== OUTPUT DIV ========== */
#outputDiv {
  background-color: var(--bg);
  flex: 2;
  min-width: 280px;
  max-width: 480px;
  margin: 28px 28px 28px 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.blocklyToolbox {
  background-color: var(--bg);
}

.blocklyToolboxCategory {
  height: 28px;
  line-height: 28px;
}

.blocklyToolboxCategoryContentContainer {
  border-left: 20px;
}

.blocklyToolboxCategoryIcon {
  width: 8px;
}

.blocklyToolboxCategoryLabel,
select,
option {
  font-family: var(--font-family) !important;
}

/* ========== DROPDOWNS ========== */
.dropdown-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 0 0 auto;
  align-self: flex-start;
}

#generateDropdown,
#languageDropdown {
  flex: 0 0 auto;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  color: #333;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 36px 10px 14px;
  border: 2px solid #667eea;
  border-radius: 12px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23667eea' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

#generateDropdown:hover,
#languageDropdown:hover {
  border-color: #764ba2;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#generateDropdown:active,
#languageDropdown:active {
  border-color: #667eea;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
}

#generateDropdown option,
#languageDropdown option {
  background: #fff;
  color: #333;
  padding: 8px 12px;
  font-weight: 500;
}

/* ========== TOOLBOX CATEGORY COLORS (VIBRANT) ========== */
.blocklyToolboxCategoryLogic {
  border-left: 15px solid #9C27B0 !important;
}

.blocklyToolboxCategoryLoops {
  border-left: 15px solid #4CAF50 !important;
}

.blocklyToolboxCategoryMath {
  border-left: 15px solid #2196F3 !important;
}

.blocklyToolboxCategoryText {
  border-left: 15px solid #FF9800 !important;
}

.blocklyToolboxCategoryLists {
  border-left: 15px solid #00BCD4 !important;
}

.blocklyToolboxCategoryVariables {
  border-left: 15px solid #E91E63 !important;
}

.blocklyToolboxCategoryProcedures {
  border-left: 15px solid #795548 !important;
}

.blocklyToolboxSeparator {
  border-bottom: unset;
}

.blocklyMainBackground,
.blocklyPath {
  stroke: var(--bg);
}

.blocklyText {
  fill: white !important;
  font: 700 16px var(--font-family) !important;
}

hr {
  border: 0;
  clear: both;
  height: 1px;
}

.next-line {
  display: none;
}

/* ========== RUN BUTTON ========== */
.play-button {
  background: white;
  color: #667eea;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 16px/1 var(--font-family);
  padding: 10px 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.play-button .material-icons {
  cursor: default;
  font-size: 22px;
  height: 22px;
  pointer-events: none;
  position: relative;
  vertical-align: middle;
  width: 22px;
}

.play-button:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.3);
}

.play-button:active {
  transform: scale(0.96);
}

.play-button.running {
  background: #FF9800;
  color: white;
}

/* ========== CLEAR BUTTONS ========== */
.button-group {
  display: flex;
  gap: 8px;
}

.clear-button {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-sizing: border-box;
  color: #666;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 500 13px/1 var(--font-family);
  padding: 8px 14px;
  transition: background 0.2s, border-color 0.2s;
}

.clear-button:hover {
  background: #f5f5f5;
  border-color: #bbb;
}

.clear-button .material-icons {
  cursor: default;
  font-size: 18px;
  pointer-events: none;
  vertical-align: middle;
}

.clear-all-button {
  border: 2px solid #FFCDD2;
  border-radius: 8px;
  box-sizing: border-box;
  color: #E53935;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 500 13px/1 var(--font-family);
  padding: 8px 14px;
  transition: background 0.2s, border-color 0.2s;
}

.clear-all-button:hover {
  background: #FFEBEE;
  border-color: #E53935;
}

.clear-all-button .material-icons {
  cursor: default;
  font-size: 18px;
  pointer-events: none;
  vertical-align: middle;
}

/* ========== FLEX CONTAINER ========== */
.flex-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

/* ========== CODE HOLDER ========== */
#codeHolder {
  white-space: pre-wrap;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  padding: 12px 20px;
  line-height: 22px;
  background-color: #E3F2FD;
  border: solid 3px #42A5F5;
  font-size: 16px;
  border-radius: 12px;
  box-sizing: border-box;
}

/* ========== TEXT OUTPUT ========== */
#textOutput {
  white-space: pre-wrap;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  padding: 12px;
  background-color: #E8F5E9;
  font-family: 'Google Sans', monospace;
  border: solid 3px #66BB6A;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.6;
  box-sizing: border-box;
}

/* ========== ERROR MESSAGE ========== */
.error-msg {
  background: #FFEBEE;
  color: #C62828;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid #EF9A9A;
  font-weight: 500;
  font-size: 15px;
  line-height: 1.5;
}

/* ========== TOOLBOX ========== */
.blocklyToolboxCategoryContainer:hover {
  background: rgba(0, 0, 0, 0.06);
}

.blocklyMainWorkspaceScrollbar {
  display: none !important;
}

/* ========== PRINT STYLES ========== */
@media print {
  .no-print {
    display: none !important;
    visibility: hidden !important;
  }

  .blocklyToolbox {
    display: none !important;
    visibility: hidden !important;
  }

  #playButton {
    display: none !important;
    visibility: hidden !important;
  }
}
