/*ChatABT*/
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --gray-light: #f5f5f5;
  --gray-mid: #e0e0e0;
  --border: #eeeeee;
  --accent: #000000;
  --shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.dark-theme {
  --bg: #121212;
  --text: #ffffff;
  --gray-light: #1e1e1e;
  --gray-mid: #333333;
  --border: #222222;
  --accent: #ffffff;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Prevents horizontal scrolling/zooming */
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: background 0.3s, color 0.3s;
  display: flex;
  flex-direction: column;
}

/* Header & Progress */
header { 
  text-align: center; padding: 2rem 1rem; 
  position: relative; width: 100%;}
/* Title header: align children on the same baseline like a menu bar
   and swap first/last positions so first child appears on the right
   and the last child appears on the left. Using flex + order is
   more robust than float and keeps baseline alignment. */
.titleHeader {
  display: flex;
  align-items: baseline; /* align text baselines */
  gap: 10px;
  width: 100%;
  max-width: 100vw;
  margin: 0 auto; /* center the header row inside the page */
  justify-content: space-between; /* create space between left/right items */
}

.titleHeader h1 {
  margin: 0;
  line-height: 1;
  font-size: 1.5rem;
}

.titleHeader {
  /* Keep the toggle in-flow so it participates in flex ordering */
  position: static;
  padding: .4rem .6rem;
  margin: 0;
  font-size: 12px;
  color: var(--text);
  border-radius: 8px;
}

/* Chat: keep the input area pinned to the bottom of the chat-section */
.chat-section #chatMessages,
.chat-section #chatMessages {
  flex: 1 1 auto; /* let messages grow to fill available space */
  overflow: auto;
  padding: 12px;
}

.chat-input-area {
  margin-top: auto; /* push input area to the bottom of the flex column */
  padding: 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
}

.chat-input-area {
  width: auto;
}

/* Make the chat input fill available space and grow vertically */
.chat-input {
  flex: 1 1 auto; /* take remaining horizontal space */
  min-height: 38px;
  max-height: 220px; /* limit grow to avoid covering the whole screen */
  resize: none; /* users should not manually resize the input */
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  overflow: auto; /* allow scrolling when max-height reached */
}

.chat-input:focus { outline: 2px solid rgba(0,0,0,0.08); }

.chat-input-area button {
  flex: 0 0 auto;
  align-self: flex-end; /* keep send button aligned with bottom of input */
}

.progress-container {
  width: 250px;
  /*height: 8px;*/
  background: var(--gray-mid);
  margin: 15px auto;
  border-radius: 10px;
  overflow: hidden;
}
.progress-bar {
  height: 30px;
  background: var(--accent);
  width: 0%;
  line-height: 30px;
  transition: width 1s ease;
}
.progress-label {
  color: var(--bg);
}

/* The Single Line Input Row */
.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 2rem;
}

input {
  background: var(--gray-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 8px;
  outline: none;
}

#task { flex-grow: 1; } /* Task takes available space */

#deadline {
  width: 60px; /* Square-ish box */
  text-align: center;
}

/* Buttons */
button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}

button:hover { opacity: 0.8; }

#themeToggle {
  position: absolute;
  top: 27px;
  right: 39px;
  background: var(--gray-light);
  color: var(--text);
  font-size: 12px;
}

/* Desktop Layout */
.container {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  max-width: 1200px;
  margin: 0 auto;
  gap: 40px;
  padding: 0 20px;
}

/* Chat Styling */
.chat-section {
  background: var(--gray-light);
  border-radius: 16px;
  height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

/* Mobile & Chat Toggle Logic */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .container { grid-template-columns: 1fr; }
  
  .chat-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    z-index: 100;
    transform: translateY(100%); /* Hidden by default */
    transition: transform 0.3s ease-in-out;
    border-radius: 24px 24px 0 0;
  }

  .chat-section.active { transform: translateY(0); }

  .mobile-only { display: block; }

  #chatToggleBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  }
}

/* Style <p> inside #chatMessages as chat bubbles */
#chatMessages p {
  display: inline-block;
  align-self: flex-start;           /* default: received (left) */
  max-width: 75%;
  margin: 6px 0;
  padding: 10px 14px;
  border-radius: 16px;
  background: #e9eaee;              /* received bubble color */
  color: #111;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  word-break: break-word;
  white-space: pre-wrap;            /* preserve newlines */
  font-size: 14px;
  line-height: 1.35;
}

/* Sent message variant - align right and use accent color */
#chatMessages p.sent {
  align-self: flex-end;
  background: var(--accent-color, #0b93f6);
  color: #fff;
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 16px;
}

/* Received explicit variant (redundant with default but handy) */
#chatMessages p.received {
  align-self: flex-start;
  background: #e9eaee;
  color: #111;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 16px;
}

/* Small, subtle timestamp inside a message (optional markup: <p>Hi <span class="ts">12:34</span></p>) */
#chatMessages p .ts {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  color: rgba(0,0,0,0.45);
  vertical-align: middle;
}

/* Responsive tweak for narrow screens */
@media (max-width: 480px) {
  #chatMessages p { max-width: 86%; font-size: 13px; padding: 8px 12px; }
}
  
/*Update*/



/* --- 3. Layout Container --- */
.container {
  display: grid;
  grid-template-columns: 1fr 1.5fr; /* Chat slightly larger on Desktop */
  max-width: 1200px;
  margin: 0 auto;
  gap: 40px;
  padding: 20px;
  flex-grow: 1;
}

/* --- 4. To-Do Section & Inputs --- */
.input-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  width: 100%; /* Fills the container exactly */
  max-width: 100%; /* Prevents pushing out */
  box-sizing: border-box;
}

input {
  background: var(--gray-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 15px;
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  transition: border 0.2s;
}

input:focus {
  border-color: var(--accent);
}

#task { 
  flex: 1; 
  min-width: 0; 
}

#deadline {
  width: 60px; /* Square number box */
  text-align: center;
  -moz-appearance: textfield; /* Hide arrows in Firefox */
}

#deadline::-webkit-inner-spin-button, 
#deadline::-webkit-outer-spin-button { 
  -webkit-appearance: none; /* Hide arrows in Chrome/Safari */
}


/* --- 6. Task List Styling --- */
#tasksList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#tasksList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.days-left {
  color: var(--danger);
  font-weight: bold;
  font-size: 12px;
}

/* --- 7. Chat Section --- */
.chat-section {
  background: var(--gray-light);
  border-radius: 20px;
  height: 65vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-header {
  padding: 15px 20px;
  background: var(--gray-mid);
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#chatMessages {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
}

.chat-input-area {
  padding: 15px;
  display: flex;
  gap: 8px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

#chatInput { flex: 1; }

/* --- 8. Mobile Responsiveness --- */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  /* Chat is completely hidden on mobile until 'active' */
  .chat-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 84vh;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 25px 25px 0 0;
  }

  .chat-section.active {
    transform: translateY(0);
  }

  .mobile-only { display: block; }

  #chatToggleBtn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    z-index: 999;
  }
  
  #closeChat {
    background: transparent;
    color: var(--text);
    padding: 5px;
    font-size: 18px;
  }
  
  #saveTaskBtn {
  flex: 0 0 auto; /* Button stays exactly as wide as its text */
  padding: 10px 15px;
  white-space: nowrap; /* Prevents "Save" from wrapping to two lines */
}
  #task {
    width: 55%;
  }
  }