@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #21262d;
  --bg-tertiary: #161b22;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --border: #30363d;
  --success: #238636;
  --warning: #d29922;
  --error: #f85149;
}

* {
  box-sizing: border-box;
} 

body {
  margin: 0;
  padding: 20px;
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  user-select: none;
  line-height: 1.5;
}

navbar {
  background-color: #333;
  padding-left: 5px;
  padding-top: 1px;
}

navbar button {
  border-radius: 2px;
  background-color: #888;
  border: 3px outset #999;
}

navbar button:hover {
  background-color: #999;
  border-top: 3px outset #365;
}

.main-container {
  width: 100%;
  min-height: calc(100vh - 40px); /* allow growth beyond viewport */
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Title at top */
.title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 0;
  text-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
  letter-spacing: 0.05em;
  user-select: text;
  flex-shrink: 0;
}

/* Vertical divider between bottom-section and preview */
.divider-vertical {
  height: 6px;
  background: var(--border);
  cursor: row-resize;
  user-select: none;
  flex-shrink: 0;
  margin: 0;
  transition: background 0.3s ease;
  border-radius: 3px;
}

.divider-vertical:hover {
  background: var(--accent);
}

/* Bottom section: chat + horizontal divider + editor */
.bottom-section {
  display: flex;
  gap: 0;
  flex-grow: 1;
  height: 60vh; /* initial height, resizable by vertical divider */
  min-height: 200px;
}

/* Chat and editor containers take equal width initially */
.chat-container,
.editor-container {
  flex: 1 1 48.4%; /* CHANGE TO 50% */
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  background: var(--bg-secondary);
  color: var(--text-primary);
  overflow: hidden;
  margin: 0;
}

/* Horizontal divider between chat and editor */
.divider-horizontal {
  width: 6px;
  background: var(--border);
  cursor: col-resize;
  user-select: none;
  flex-shrink: 0;
  margin: 0;
  transition: background 0.3s ease;
  border-radius: 3px;
  margin-left: 15px;
  margin-right: 15px;
}

.divider-horizontal:hover {
  background: var(--accent);
}

/* Conversation container scrollable area inside chat */
#conversation-container {
  background: var(--bg-secondary);
  border-radius: 6px;
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  user-select: text;
}

/* Scrollbar styling for conversation */
#conversation-container::-webkit-scrollbar {
  width: 8px;
}
#conversation-container::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}
#conversation-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
#conversation-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Messages inside conversation */
#conversation p {
  margin: 0;
  padding: 12px 16px;
  border-radius: 6px;
  word-wrap: break-word;
  line-height: 1.6;
  user-select: text;
}

#conversation p.user-message {
  background: var(--success);
  color: #ffffff;
  margin-left: auto;
  font-weight: 500;
  border-left: 3px solid #2ea043;
  box-shadow: 0 2px 8px rgba(35, 134, 54, 0.3);
}

#conversation p.bot-message {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  margin-right: auto;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  font-weight: 400;
}

#conversation p.win-message {
  background: linear-gradient(135deg, var(--success), #2ea043);
  color: #ffffff;
  text-align: center;
  font-weight: 600;
  padding: 16px 24px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(35, 134, 54, 0.4);
  margin: 0 auto;
  border: 1px solid #2ea043;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Thinking animation styles */
.thinking-message {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 8px;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-pulse 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.thinking-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes thinking-pulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Input textarea below conversation */
#input {
  width: 100%;
  height: 100px;
  padding: 16px 20px;
  font-size: 14px;
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  margin-top: 10px;
}

#input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2), 0 4px 16px rgba(0, 0, 0, 0.1);
  background: var(--bg-tertiary);
}

#input::placeholder {
  color: var(--text-secondary);
  font-style: italic;
}

/* Codespace editor textarea (will be replaced by CodeMirror) */
#codespace {
  width: 100%;
  height: 100%;
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: none;
  border-radius: 0 0 6px 6px;
  padding: 16px;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
}

/* CodeMirror customizations */
.CodeMirror {
  height: 100% !important;
  border-radius: 6px;
  font-family: 'Fira Code', monospace;
  font-size: 14px;
  line-height: 1.5;
}

/* Preview container iframe */
.preview-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  height: calc(40vh - 8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  margin-top: 0px;
  margin-bottom: 10px;
  overflow: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.chat-container,
.editor-container {
  flex-grow: 0;
  flex-shrink: 0;
  transition: flex-basis 0.15s ease; /* smooth resizing */
}

.chat-button-right {
  float: right;
}

.chat-button-left {
  float: left;
}

.chat-button-right, .chat-button-left {
  cursor: pointer;
  margin: 2px;
  width: 50px;
  height: auto;
  border-radius: 5px;
  background-color: #666;
  border: none;
}

.chat-button-right:hover {
  background-color: #4ED96D;
}

.chat-button-left:hover {
  background-color: #40C2B9;
}

.chat-img {
  width: 60%;
}

.sidebar-img {
  width: 1em;
}

/* Toggle button */
#sidebarToggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1001;
  background-color: rgba(0, 0, 0, 0);
  color: #d33;
  border: none;
  /*padding: 6px 10px;*/
  font-size: 34px;
  cursor: pointer;
  text-shadow: 0 0 16px #0ff; /* glow */
  transition: transform 0.37s ease;
  transform-origin: center;
}

#sidebarToggle img {
  height: 40px;
  margin: 0;
  padding: 0;
}

/* Sidebar shell */
#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(30vw, 300px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: -2px 0 8px rgba(0,0,0,.4);
  transform: translateX(100%);
  transition: transform .29s ease;
  z-index: 1000; 
  display: flex;
  flex-direction: column;
}

#sidebar.open { transform: translateX(0); }

/* Header inside sidebar */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  line-height: 3em;
}

.sidebar-header button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
}

/* Scrollable content */
.sidebar-content {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
}

.sidebar-content button {
  margin: 2px;
  font-size: 1.4em;
  border-radius: 6px;
  width: 100%;
  font-family: "Andale Mono", "Monaco", "Menlo", "Consolas", "Ubuntu Mono", "DejaVu Sans Mono", "Courier New", monospace;
  cursor: pointer;
  background-color: #858AA1;
}

.sidebar-content button:hover {
  background-color: #999FBA;
  color: #293332;
}

.sidebar-content button span {
  float: right;
}

.sidebar-content button img {
  float: left;
}

.copyright {
  position: relative;
  color: #444; 
  font-family: 'Times'; 
  font-size: 0.3em; 
  padding: 0px; 
  margin-top: -10px; 
  margin-bottom: -10px; 
  height: 0px;
  transition: 0.3s ease;
  width: fit-content;
}

.tab {
  font-family: 'Times';
  padding: 5px;
  margin-bottom: -20px;
  margin-right: 10px;
  margin-left: 10px;
  margin-top: -20px;
  font-size: 20px;
  line-height: 30px;
  text-align: bottom;
  border-bottom: 22px solid #555; /* Color and height of the trapezoid */
  border-left: 12px solid transparent; /* Left slope */
  border-right: 12px solid transparent; /* Right slope */
  height: 0; /* Important for the border trick */
  width: fit-content; /* Top width of the trapezoid */
}

.tab {
  color: black;
}

.tab button img {
  width: auto;
  height: 14px;
  float: bottom;
  margin-bottom: -1.2px;
  margin-right: -5px;
}

.tab span img {
  margin-right: 6px;
  margin-bottom: -2px;
  height: 0.9em;
  width: auto;
  margin-top: 6px;
}

.tab button img:hover {
  transform: scale(1.1);
  transform: rotate(360deg);
  transition: 0.3s ease;
}

.tab button {
  font-size: 20px;
  background: none;
  border: none;
  cursor: pointer;
}

.actions {
  padding: 0px;
}

.actions button img {
  height: 1em;
  margin-bottom: -1.5px;
}

.actions button {
  border-radius: 1em;
  border: 2px inset pink;
  background-color: pink;
  margin-left: 1px;
  height: fit-content;
  width: fit-content;
  cursor: context-menu;
}

.code-count {
  float: right;
  font-family: monospace;
  font-size: 0.9em;
  transform: scaleX(0.9);
  transform-origin: center;
  margin: 2px;
  color: #E5E3AA;
  cursor: default;
}

.code-count:hover {
  color: #f6f4bb;
}

.popup-overlay {
  font-family: "Arial", sans-serif;
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Dim background */
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup-content {
  background-color: white;
  padding: 20px;
  border-radius: 5px;
  text-align: center;
}

.goodButton {
  background-color: #47f;
  border-radius: 5px;
  border: none;
}

.fineButton {
  background-color: grey;
  border-radius: 5px;
  border: none;
}

/*********** menubar **********/

nav.options-menubar {
  padding: 1px;
  padding-left: 2px;
  background: #888;
  position: absolute;
  width: 100vw;
  margin: 0;
  left: 0;
  right: 0;
  top: 0;
}

nav.options-menubar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

nav.options-menubar li {
  position: relative;
  display: inline-block;
}

nav.options-menubar button {
  background: #888;
  border-radius: 5px;
  border: none;
  font-family: sans-serif;
  padding: 5px 10px;
  cursor: pointer;
}

nav.options-menubar button:hover {
  background: #aaa;
}

nav.options-menubar button img {
  height: 1em;
  scale: 1.6;
  vertical-align: middle;
}

nav.options-menubar button span {
  display: none;
  padding-right: 2px;
}

nav.options-menubar button:hover span {
  display: inline;
}

/* ------------------------- */
/* Settings icon rotation */
/* ------------------------- */
nav.options-menubar img.settings-icon {
  transition: transform 0.2s ease;
  transform-origin: center;
}

nav.options-menubar button:hover > img.settings-icon {
  transform: rotate(90deg);
}

/********* Submenus ************/

/* Hide all submenus by default */
nav.options-menubar li ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #999;
  border: 1px solid #777;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  min-width: 140px;
  z-index: 10;
}

/* Show only hovered item's direct submenu */
nav.options-menubar li:hover > ul {
  display: block;
}

nav.options-menubar li ul li {
  display: block;
  position: relative;
}

nav.options-menubar li ul a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  text-decoration: none;
  color: #000;
  background: rgba(119, 119, 119, 0.2);
  font-family: sans-serif;
  font-size: 10px;
  white-space: nowrap;
  transition: background 0.2s;
  border-radius: 5px;
}

nav.options-menubar li ul a:hover {
  background: #aaa;
}

/* ------------------------- */
/* Arrows only if submenu */
/* ------------------------- */
nav.options-menubar li ul a::after {
  content: "";
}

nav.options-menubar li ul li:has(ul) > a::after {
  content: "→";
  margin-left: 10px;
}

/* ------------------------- */
/* Nested submenus */
/* ------------------------- */
nav.options-menubar li ul ul {
  display: none;
  top: 0;
  left: 100%;
}

nav.options-menubar li ul li:hover > ul {
  display: block;
}
