/* Using CSS Variables for easy color changes */
:root {
  --primary-blue: #00A9CE;
  --accent-yellow: #FFC107;
  --light-bg: #F0F4F8;
  --dark-text: #334E68;
  --light-text: #F0F4F8;
  --card-bg: #FFFFFF;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --font-family: 'Nunito', sans-serif;
}

/* Basic Reset & Body Styling */
body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--light-bg);
  color: var(--dark-text);
}

/* Header, Logo, and Navigation */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--card-bg);
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--primary-blue);
}

.main-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.main-nav a {
  text-decoration: none;
  color: var(--dark-text);
  font-weight: 700;
  padding: 0.5rem 0;
  position: relative;
  transition: color 0.3s ease;
}

.main-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background-color: var(--accent-yellow);
  transition: width 0.3s ease;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--primary-blue);
}

.main-nav a:hover::after,
.main-nav a.active::after {
  width: 100%;
}

/* Main Dashboard Area */
.dashboard {
  padding: 2rem 3rem;
}

.welcome-message {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.card {
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.12);
}

.card-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}

.card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  color: var(--dark-text);
}

.card p {
  margin: 0 0 1.5rem 0;
  color: #627D98;
  flex-grow: 1; /* Makes cards in the same row equal height */
}

.card-button {
  display: inline-block;
  text-decoration: none;
  font-weight: 700;
  color: var(--card-bg);
  background-color: var(--primary-blue);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  transition: background-color 0.3s ease;
}

.card-button:hover {
  background-color: #007A9B; /* A darker shade of the primary blue */
}

/* --- CHAT PAGE STYLES --- */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 84px); /* Full height minus header */
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--card-bg);
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.chat-window {
  flex-grow: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

#messages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#messages li {
  display: flex;
  max-width: 75%;
  /* NEW: Add animation for message bubbles */
  opacity: 0;
  transform: translateY(15px);
  animation: slide-in 0.5s forwards;
}

#messages li span {
  padding: 0.75rem 1rem;
  border-radius: 18px;
  line-height: 1.5;
}

.tutor-message {
  justify-content: flex-start;
}

.tutor-message span {
  background-color: #EBF4F8;
  color: var(--dark-text);
  border-top-left-radius: 4px;
}

.user-message {
  align-self: flex-end; /* Correctly align user messages to the right */
}
.user-message span {
  background-color: var(--primary-blue);
  color: var(--light-text);
  border-top-right-radius: 4px;
}

/* --- SUBJECT BAR (NEW) --- */
.subject-bar {
    padding: 0.75rem 1.5rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.subject-bar input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 1.25rem;
    border-radius: 20px;
    border: 1px solid #ced4da;
    font-size: 0.95rem;
    font-family: var(--font-family);
    color: #495057;
}
.subject-bar input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 169, 206, 0.2);
}


/* --- CHAT FORM UPDATES --- */

.chat-form {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: var(--card-bg);
    border-top: 1px solid #dde7f0;
}

.chat-form input {
    flex-grow: 1;
    border: 1px solid #CFD8DC;
    border-radius: 25px; /* Bubbly and friendly */
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-family: var(--font-family);
    margin-right: 0.75rem; /* Space between input and button */
    box-sizing: border-box;
}

.chat-form input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 169, 206, 0.2); /* Softer focus glow */
}

.chat-form button {
  border: none;
  background-color: var(--primary-blue);
  color: white;
  font-weight: 700;
  font-family: var(--font-family);
  padding: 0.75rem 1.5rem;
  border-radius: 25px; /* Match input bubble style */
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  flex-shrink: 0;
}

.chat-form button:hover {
  background-color: #007A9B;
  transform: scale(1.05); /* Fun pop effect */
}

.play-audio-btn {
  background-color: var(--accent-yellow);
  border: none;
  border-radius: 50%;
  width: 40px; /* Increased size */
  height: 40px; /* Increased size */
  cursor: pointer;
  margin-left: 12px; /* Adjusted margin */
  font-size: 20px; /* Larger icon */
  color: white;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s, transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.play-audio-btn:hover {
    background-color: #ffda73; /* Lighter yellow */
    transform: scale(1.1);
}

/* --- CHAT HISTORY SIDEBAR STYLES --- */

.chat-container {
    display: flex;
    flex-direction: row; /* Changed from column to row */
    height: calc(100vh - 84px);
    max-width: 1200px; /* Widen the container to fit the sidebar */
}

.chat-sidebar {
    width: 250px;
    flex-shrink: 0; /* Prevents the sidebar from shrinking */
    background-color: #EBF4F8;
    padding: 1rem;
    border-right: 1px solid #CFD8DC;
    overflow-y: auto;
}

.chat-sidebar h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--dark-text);
}

#sessionList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#sessionList li a {
    display: block;
    padding: 0.75rem;
    text-decoration: none;
    color: #334E68;
    border-radius: 6px;
    font-weight: 700;
    transition: background-color 0.2s;
}

#sessionList li a:hover {
    background-color: #DCEAF1;
}

.chat-main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flexbox from causing overflow with wide content */
}

/* --- PROFILE PAGE STYLES --- */
.profile-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.profile-container h1 {
    text-align: center;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #CFD8DC;
    border-radius: 8px;
    box-sizing: border-box;
    font-family: var(--font-family);
}

#profileForm button {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-blue);
    color: var(--light-text);
    cursor: pointer;
    transition: background-color 0.2s;
}

#profileForm button:hover {
    background-color: #007A9B;
}

.save-message {
    text-align: center;
    margin-top: 1rem;
    color: #007A9B;
    font-weight: 700;
}

/* --- WELCOME/LOGIN PAGE STYLES --- */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100vh;
  padding: 2rem;
  box-sizing: border-box;
}

.welcome-container .logo {
    /* NEW: Add floating animation to the logo */
    animation: float 4s ease-in-out infinite;
}

.welcome-container h1 {
  font-size: 2.8rem; /* Slightly larger for impact */
  color: var(--dark-text);
  margin-top: 1.5rem;
}

.welcome-container p {
  font-size: 1.2rem;
  color: #627D98;
  margin-bottom: 2.5rem; /* More space */
}

#loginForm {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 400px;
  gap: 1rem; /* NEW: Add space between form elements */
}

/* NEW: Unified style for both inputs */
#loginForm input {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  border: 2px solid #CFD8DC; /* Slightly thicker border */
  border-radius: 30px; /* More rounded */
  text-align: center;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

#loginForm input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 4px rgba(0, 169, 206, 0.2);
}

#loginForm button {
  width: 100%;
  padding: 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: 30px; /* Match input rounding */
  background-color: var(--primary-blue);
  color: var(--light-text);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#loginForm button:hover {
  background-color: #007A9B;
  transform: translateY(-2px); /* Lift effect */
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* --- CUTE ANIMATIONS --- */

/* For the recording button */
#recordButton {
    background-color: #f2a2a2; /* A soft red to indicate recording capability */
    color: white;
}

#recordButton.is-recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(242, 162, 162, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(242, 162, 162, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(242, 162, 162, 0);
    }
}

/* Floating animation for the login page logo */
@keyframes float {
	0% {
		transform: translatey(0px);
	}
	50% {
		transform: translatey(-20px);
	}
	100% {
		transform: translatey(0px);
	}
}

/* NEW: Message bubble slide-in animation */
@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* NEW: Typing indicator animation */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
}
.typing-indicator span {
    height: 10px;
    width: 10px;
    background-color: #9E9E9E;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* --- RESPONSIVE STYLES --- */
@media (max-width: 768px) {
    /* General body/layout adjustments */
    body {
        -webkit-text-size-adjust: 100%; /* Prevent font scaling on iOS */
    }

    .dashboard {
        padding: 1rem;
    }

    /* Header */
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .main-nav a {
        padding: 0.5rem; /* Better tap target */
    }

    /* Card Grid for Dashboard */
    .card-grid {
        grid-template-columns: 1fr; /* Stack cards on mobile */
        gap: 1rem;
    }

    /* --- Chat Page Mobile --- */
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 150px); /* Adjust height for new header size */
        max-width: 100%;
    }

    .chat-sidebar {
        width: 100%;
        max-height: 30vh; /* Limit sidebar height */
        border-right: none;
        border-bottom: 1px solid #CFD8DC;
    }

    .chat-main-area {
        min-width: 100%;
    }
    
    .chat-window {
        padding: 1rem;
    }

    #messages li {
        max-width: 90%;
    }

    .chat-form {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .input-wrapper {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .chat-form input {
        width: 100%;
        margin-right: 0;
    }
    
    .chat-form button {
        width: 100%;
    }

    /* --- Profile Page Mobile --- */
    .profile-container {
        margin: 1rem auto;
        padding: 1.5rem;
        box-shadow: none;
        border-radius: 0;
    }

    /* --- Welcome/Login Page Mobile --- */
    .welcome-container {
        padding: 1rem;
    }
    
    .welcome-container h1 {
        font-size: 2.2rem;
    }

    .welcome-container p {
        font-size: 1.1rem;
    }
    
    #loginForm {
        padding: 0 1rem;
    }
}

/* Recording Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 169, 206, 0.8); /* Use primary color with transparency */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: transparent; /* Make modal background transparent */
    text-align: center;
    padding: 0; /* Remove padding */
    box-shadow: none; /* Remove shadow */
}

.mic-icon-container {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: var(--accent-yellow);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: pulse-mic 1.5s infinite;
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.6);
}

.modal-content p {
    margin-top: 20px;
    font-size: 1.8em; /* Larger, more readable text */
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3); /* Add text shadow for readability */
}

@keyframes pulse-mic {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 20px rgba(255, 193, 7, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}
