/* --- Global Variables & Defaults --- */
:root {
  --bg: #ffffff;
  --panel: #f3f4f6;
  --text: #333333;
  --muted: #777777;
  --accent: #3498db;
  --card: #ffffff;
  --line: #e0e0e0;
  --ok: #2ecc71;
  --warn: #f39c12;

  /* Calendar in Light Theme */
  --cal-cell-bg-light: #f7fafc;
  --cal-cell-border-light: #e0e0e0;
  --cal-has-entry-outline-light: #3498db;
  --cal-today-border-light: #94a3b8;
  --cal-selected-outline-light: #2563eb;

  /* Input/Form in Light Theme */
  --input-bg-light: #f7fafc;
  --input-border-light: #e0e0e0;
  --input-text-light: #2c3e50;

  /* Table in Light Theme */
  --table-border-light: #dee2e6;
}

/* Dark theme variables */
body.dark-theme {
  --bg: #0b1020;
  --panel: #111834;
  --text: #e5e7eb;
  --muted: #9aa3b2;
  --accent: #4f46e5;
  --card: #0f172a;
  --line: #223058;
  --ok: #16a34a;
  --warn: #f59e0b;
}

/* Import Google Fonts for Icons */
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Lucida Bright", Georgia, serif;
  background: linear-gradient(180deg, #0b1020, #0d1734);
  color: var(--text);
  transition: background-color 0.3s ease;
}

/* ------------------- Theme Specific Backgrounds ------------------- */
body.light-theme {
  background: linear-gradient(to bottom, #d6eaff, #f4e8ff, #fff5e6);
}

body.dark-theme {
    background: linear-gradient(135deg, #111834, #0b1020, #0d1734);
}

/* ------------------- Navbar & Header ------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid #1f2a44;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text);
  font-size: 18px;
}

.topbar .nav {
  display: flex;
  gap: 32px;
  justify-content: center;
  flex-grow: 1;
}

.topbar .nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  font-size: 15px;
}

.topbar .nav a:hover {
  color: var(--text);
}

.theme-container {
    margin-left: auto;
}

#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

#theme-icon {
    font-size: 30px;
    width: 30px;
    height: 30px;
    line-height: 30px;
    color: var(--text);
}

/* ------------------- Main Layout & Components ------------------- */
main#app {
  max-width: 1180px;
  margin: 24px auto;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid #263055;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(12,18,40,.35) inset;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

h2 {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--muted);
}

p {
  color: var(--muted);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: 2fr 1fr;
}

.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--text);
}

.badge {
  background: #1f2937;
  color: #93c5fd;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

/* ------------------- Game & Calendar ------------------- */
.game-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

.game-icon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease-in-out;
  cursor: pointer;
}

.game-icon-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  border-color: var(--accent);
}

.game-icon-card img {
  width: 80px;
  height: 80px;
  margin-bottom: 10px;
}

.game-icon-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.canvas-wrap {
  display: grid;
  gap: 8px;
}

canvas#game-canvas {
  display: block;
  width: 100%;
  height: 420px;
  background: #a4aac3;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.placeholder {
  display: grid;
  place-items: center;
  height: 420px;
  border: 1px dashed #355;
  border-radius: 16px;
  color: var(--muted);
  background: #0a0f22;
}

.calendar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.cal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #0e1730;
  border-bottom: 1px solid var(--line);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 12px;
}

.cal-dow,
.cal-cell {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.cal-cell {
  background: #0b1530;
  border: 1px solid #1d2a4f;
  padding: 10px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.cal-cell:hover {
  background: #1b2750;
  transform: scale(1.05);
}

.cal-cell.has-entry {
  outline: 2px solid var(--ok);
}

.cal-cell.today {
  border-color: #64748b;
}

.cal-cell.selected {
  outline: 2px solid #93c5fd;
}
body.light-theme .cal-head {
  background: #e9ecef;
  border-bottom-color: #dee2e6;
  color: var(--text);
}


body.light-theme .cal-dow,
body.light-theme .cal-cell {
  color: var(--muted);
}

body.light-theme .cal-cell {
  background: var(--cal-cell-bg-light);
  border: 1px solid var(--cal-cell-border-light);
}

body.light-theme .cal-cell:hover {
  background: #e9ecef;
}

body.light-theme .cal-cell.has-entry {
  outline: 2px solid var(--cal-has-entry-outline-light);
}

body.light-theme .cal-cell.today {
  border-color: var(--cal-today-border-light);
}

body.light-theme .cal-cell.selected {
  outline: 2px solid var(--cal-selected-outline-light);
}


/* ------------------- Inputs & Forms ------------------- */
.input,
select,
textarea {
  width: 100%;
  background: #0b1530;
  border: 1px solid #203260;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
}

label {
  font-size: 12px;
  color: var(--muted);
}

hr.sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

/* Light Theme Input Overrides */
body.light-theme .input,
body.light-theme select,
body.light-theme textarea {
  background: var(--input-bg-light);
  border: 1px solid var(--input-border-light);
  color: var(--input-text-light);
}

body.light-theme .table th,
body.light-theme .table td {
  border-bottom: 1px solid var(--table-border-light);
}

/* ------------------- Tables & Login ------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid #203260;
  text-align: left;
}

#loginBtn, #logoutBtn {
  padding: 10px 20px;
  margin: 10px;
  border: none;
  background-color: #007bff;
  color: white;
  cursor: pointer;
}

#loginBtn:hover, #logoutBtn:hover {
  background-color: #0056b3;
}

#userInfo {
  margin-top: 20px;
}

/* ------------------- Gemini API Section ------------------- */
#correlation-container {
    background: #f8f5ff;
    padding: 24px;
    border-radius: 12px;
    flex: 1;
    max-width:5000px;
    margin: 32px 0;
}

#ai-analysis-output {
    margin-top: 16px;
    font-size: 0.9em;
    color: #3b2d5c;
    padding: 16px;
    background: #dcdbe0;
    border-radius: 8px;
    min-height: 500px;
}

button {
    padding: 10px 20px;
    font-size: 0.9em;
    background: #6c3ec1;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

input {
    font-size: 0.9em;
    color: #3b2d5c;
    padding: 10px 20px;
    background: #f4f0fa;
    margin-top: 30px;
    border-radius: 6px;
    min-height: 10 px;
}

button:hover {
    background: #9b5ded;
}

/* ------------------- Floating Chatbot Styles ------------------- */
/* The main container for the chatbot */
#floating-chatbot-container {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease-in-out;
}

#floating-chatbot-container.is-visible {
    width: 350px;
}

/* The chatbot toggle button */
#chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001; /* Ensure button is always visible */
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s ease-in-out, background 0.3s;
    border: none;
    padding: 0;
}
#chat-toggle-btn.is-hidden {
    opacity: 0;
    pointer-events: none; /* Prevents button from being clickable when hidden */
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
}

#chat-toggle-btn svg {
    color: currentColor;
    width: 32px;
    height: 32px;
}

/* The chatbot window */
#chat-window {
    width: 100%;
    height: 100%;
    background: var(--card);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chat-window .chat-header {
    background: var(--accent);
    color: white;
    padding: 15px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chat-window .chat-header #close-chat-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
    padding: 0;
}

#chatbox {
    flex-grow: 1; /* Allows it to fill the available space */
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allows scrolling for long chat history */
    gap: 10px; /* Add spacing between messages */
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
}

.user-message {
    background-color: var(--accent);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.system-message {
    background-color: var(--panel);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.typing-indicator {
    background-color: var(--panel);
    color: var(--muted);
    font-style: italic;
    border-radius: 18px;
    padding: 10px 15px;
}

.chat-input-container {
    display: flex;
    align-items: center; /* New: Vertically align items */
    padding: 10px;
    border-top: 1px solid var(--line);
    background: var(--card);
}

.chat-input-container input {
    flex-grow: 1;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid var(--line);
    font-size: 1em;
    outline: none;
    background: var(--panel);
    color: var(--text);
}

.chat-input-container button {
    margin-left: 10px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--accent);
    color: white;
    border: none;
    padding: 0; /* New: Remove default button padding */
}

.chat-input-container button svg {
  color: white;
}