/* === CSS VARIABLES === */
:root {
  --primary-color: #3498db;
  --secondary-color: #2c3e50;
  --light-bg: #f2f4f8;
  --dark-bg: #23272e;
  --retro-bg: #c0c0c0;
  --cyber-bg: #0d0d0d;
  --container-bg: #fff;
  --container-border: #dfe4ea;
  --font-family-sans: Helvetica, Arial, sans-serif;
  --font-family-mono: 'Cutive Mono', 'Courier New', monospace;
  --tip-bg: #f8f8f8;
  --tip-border: #d0d0d0;
  --tip-color: #444;
}

/* === BASE LAYOUT === */
body {
  background: var(--light-bg);
  color: var(--secondary-color);
  font-family: var(--font-family-sans);
  margin: 0;
  padding: 0;
}

.container {
  min-height: 100vh;
  max-width: 1200px; /* Increased from 900px to 1200px */
  margin: 0 auto;
  background: var(--container-bg);
  border: 1px solid var(--container-border);
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  padding: 2rem 1rem 1rem 1rem;
}

main {
  flex: 0 1 auto; /* Allow main to shrink to fit its content */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === TYPOGRAPHY === */
h1, h2 {
  text-align: center;
  margin: 0.5em 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.2rem;
  color: var(--secondary-color);
}

h3.tip {
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  color: var(--tip-color);
  max-width: 420px;
  margin: 1em auto;
  padding: 0.75em 1.2em;
  border-radius: 7px;
  font-size: 0.95em;
  font-style: italic;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* === INPUTS & BUTTONS === */
.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%; /* You can set this to 1000px or 1200px */
  margin: 0 auto;
  width: 100%;
  padding: 1rem 0;
  box-sizing: border-box;
}

.input-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5em;
  justify-content: center;
  padding: 0;
}
.input-inline label {
  margin-bottom: 0;
  margin-right: 0.5em;
}

#user-question {
  width: 500px;
  max-width: 100%;
  min-width: 200px;
  min-height: 5em;
  max-height: 18em;
  font-size: 1.1em;
  padding: 0.75rem;
  resize: none;
  overflow-y: auto;
  margin-bottom: 0;
  box-sizing: border-box;
  font-family: var(--font-family-sans);
  border-radius: 5px;
  border: 1px solid #ccc;
  background: #fafbfc;
}

#char-counter {
  width: 100%;
  text-align: right;
  margin-top: 0.2em;
  font-size: 0.85em;
  color: #888;
}

#ask-button {
  width: 50%;
  padding: 0.75rem;
  cursor: pointer;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1.1em;
  font-family: var(--font-family-sans);
  transition: background 0.3s, color 0.3s;
}

#ask-button:hover {
  background: #2980b9;
}

/* === RESPONSE AREA === */
#response {
  width: 800px;
  max-width: 100%;
  min-width: 200px;
  max-height: 18em;
  font-size: 1.1em;
  padding: 0.75rem;
  margin-top: 1.5rem;
  white-space: pre-wrap;
  font-family: var(--font-family-sans);
  font-size: 1.2em;
  padding: 1rem;
  resize: none;
  overflow-y: auto;
  margin-bottom: 0;
  box-sizing: border-box;
  font-family: var(--font-family-sans);
  text-align: center;
  overflow-wrap: break-word;
  background: var(--container-bg);
  border-radius: 8px;
  max-height: 60vh;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* === THEME TOGGLE & FOOTER === */
.theme-toggle {
  margin: 2rem 0 1rem 0;
  text-align: center;
  font-size: 0.9em;
}

.theme-toggle p {
  margin: 0 0 0.5rem 0;
}

.theme-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.theme-toggle input[type="radio"] {
  display: none;
}

.theme-toggle label {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  background: #f6f6f6;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.theme-toggle input[type="radio"]:checked + label {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.theme-toggle label:hover {
  background: #e0e0e0;
}

footer {
  text-align: center;
  font-size: 0.9em;
  color: #666;
  margin-top: 0.5rem; /* Reduce from 1rem to 0.5rem or 0 */
  padding: 0.5rem 0 0 0;
  flex-shrink: 0;
}

/* === TYPED OUTPUT === */
.typed-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 3rem;
  width: 100%;
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1.3em;
  padding: 0.5rem;
  font-family: var(--font-family-mono);
}

#typed-output {
  display: inline-block;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
}

.typed-cursor {
  display: inline;
  vertical-align: baseline;
  animation: blink 0.7s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* === THEME OVERRIDES === */

/* --- DARK THEME --- */
body.dark {
  --container-bg: #2e2e2e;
  --container-border: #444a57;
  --tip-bg: #23272e;
  --tip-border: #444a57;
  --tip-color: #e0e0e0;
  background: #23272e;
  color: #e0e0e0;
}

body.dark h1 { color: #ffcc00; }
body.dark h2 { color: #ff9900; }
body.dark #ask-button { background: #ff9900; color: #2e2e2e; }
body.dark #ask-button:hover { background: #cc7a00; color: #fff; }
body.dark .theme-toggle label { background: #4a4a4a; color: #ffcc00; border: 1px solid #ff9900; }
body.dark .theme-toggle input[type="radio"]:checked + label { background: #ff9900; color: #2e2e2e; border-color: #ffcc00; }
body.dark #user-question, body.dark input { background: #2e2e2e; color: #e0e0e0; border: 1px solid #444a57; }
body.dark #user-question:focus, body.dark input:focus { border: 1px solid #ffcc00; box-shadow: 0 0 10px #ffcc00; }
body.dark #response { background: #2e2e2e; color: #e0e0e0; }

/* --- CYBER THEME --- */
body.cyber {
  --container-bg: #1a1a1a;
  --container-border: #ff00ff;
  --tip-bg: #1a1a1a;
  --tip-border: #00ffff;
  --tip-color: #00ffff;
  background: #0d0d0d;
  color: #00ffff;
  font-family: "Orbitron", sans-serif;
}
body.cyber h1 { color: #ff00ff; text-shadow: 0 0 10px #ff00ff, 0 0 20px #00ffff; }
body.cyber #ask-button { background: #ff00ff; color: #0d0d0d; border: 2px solid #00ffff; box-shadow: 0 0 10px #ff00ff, 0 0 20px #00ffff; }
body.cyber #ask-button:hover { background: #00ffff; color: #0d0d0d; box-shadow: 0 0 15px #00ffff, 0 0 30px #ff00ff; }
body.cyber .theme-toggle label { background: #1a1a1a; color: #00ffff; border: 2px solid #ff00ff; }
body.cyber .theme-toggle input[type="radio"]:checked + label { background: #ff00ff; color: #0d0d0d; border-color: #00ffff; }
body.cyber #user-question, body.cyber input { background: #0d0d0d; color: #00ffff; border: 2px solid #ff00ff; }
body.cyber #user-question:focus, body.cyber input:focus { border: 2px solid #00ffff; box-shadow: 0 0 15px #00ffff, 0 0 30px #ff00ff; }
body.cyber #response { background: #1a1a1a; color: #00ffff; border: 2px solid #ff00ff; box-shadow: 0 0 20px #ff00ff; }
body.cyber footer { background: #1a1a1a; color: #00ffff; border-top: 2px solid #ff00ff; box-shadow: 0 0 10px #ff00ff, 0 0 20px #00ffff; }

/* --- RETRO THEME --- */
body.retro {
  --container-bg: #fff;
  --container-border: #808080;
  --tip-bg: #fff;
  --tip-border: #808080;
  --tip-color: #000080;
  background: #c0c0c0;
  color: #000080;
  font-family: var(--font-family-mono);
}
body.retro h1 { font-size: 1.8rem; color: #000080; border-bottom: 2px solid #808080; padding-bottom: 0.5rem; margin-bottom: 1rem; }
body.retro #ask-button { background: #c0c0c0; color: #000080; border: 2px solid #808080; border-radius: 0; box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #404040; text-transform: uppercase; }
body.retro #ask-button:hover { background: #808080; color: #fff; }
body.retro .theme-toggle label { font-family: var(--font-family-mono); background: #c0c0c0; color: #000080; border: 2px solid #808080; border-radius: 0; text-transform: uppercase; box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #404040; }
body.retro .theme-toggle input[type="radio"]:checked + label { background: #000080; color: #fff; border-color: #000080; }
body.retro #user-question, body.retro input { background: #fff; color: #000080; border: 2px solid #808080; box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #404040; }
body.retro #user-question:focus, body.retro input:focus { border: 2px solid #000080; }
body.retro #response { background: #fff; color: #000080; border: 2px solid #808080; box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #404040; }
body.retro footer { background: #fff; color: #000080; border-top: 2px solid #808080; }

/* === RESPONSIVE DESIGN === */
@media (max-width: 900px) {
  .container { max-width: 100vw; padding: 1rem 0.5rem; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1rem; }
  h3.tip { font-size: 0.9em; padding: 0.5em 0.7em; margin: 0.5em auto; }
  .typed-container { font-size: 1em; min-height: 2rem; padding: 0.5rem; }
  .input-group { max-width: 100%; }
  #response { font-size: 1em; margin-top: 1em; padding: 0.5em; }
}

@media (max-width: 600px) {
  .container { padding: 0.5rem 0.2rem; }
  h1, h2 { font-size: 1em; margin: 0.25em 0; }
  h3.tip { font-size: 0.85em; padding: 0.4em 0.5em; margin: 0.3em auto; }
  .theme-toggle { margin: 1rem 0 0.5rem 0; }
  #ask-button { width: 100%; }
  #user-question {
    width: 100%;
  }
}