/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    height: 100%;
}

/* Mobile viewport height fix */
:root {
    --vh: 1vh;
}

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Prevent body scrolling when sidebar is open */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Main Container - Full Screen */
.ailp-interface {
    display: flex;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    overflow: hidden;
    background: white;
    border-radius: 0;
    box-shadow: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Sidebar - Session History */
.ailp-sidebar {
    width: 300px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 4px solid #ffd166;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: hidden;
    position: relative;
}

/* Sidebar Header */
.sidebar-header {
    padding: 25px 20px;
    background: rgba(0,0,0,0.1);
    border-bottom: 3px solid #ffd166;
    text-align: center;
    position: relative;
}

.sidebar-header h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: white;
    text-shadow: 2px 2px 0 #ff9a3c;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sidebar-header h2::before {
    content: "🎓";
    font-size: 28px;
}

.sidebar-header p {
    font-size: 14px;
    opacity: 0.9;
    color: #ffd166;
}

/* Close sidebar button (mobile) */
.close-sidebar {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2002;
}

/* New Session Button in Sidebar - Compact size */
#new-session-sidebar {
    margin: 20px;
    background: #ff9a3c !important;
    color: white !important;
    border: 3px solid #ffd166 !important;
    font-size: 15px !important;
    padding: 12px 18px !important;
    border-radius: 12px !important;
    font-weight: bold !important;
    box-shadow: 0 4px 0 #ff7b00;
    transition: all 0.2s !important;
    position: relative;
    overflow: hidden;
    width: calc(100% - 40px);
    box-sizing: border-box;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

#new-session-sidebar:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 0 #ff7b00 !important;
    background: #ff8c2a !important;
}

#new-session-sidebar:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 0 #ff7b00 !important;
}

/* Make the emoji slightly smaller */
#new-session-sidebar span::before {
    content: "✨ ";
    font-size: 14px;
}

/* Sessions List */
.sessions-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: rgba(255,255,255,0.05);
}

.session-item {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.session-item:hover {
    background: rgba(255,255,255,0.2);
    border-color: #ffd166;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.session-item.active {
    background: rgba(255, 218, 102, 0.2);
    border-color: #ffd166;
    box-shadow: 0 0 20px rgba(255, 218, 102, 0.3);
}

.session-info {
    pointer-events: none;
}

.session-subject {
    font-weight: bold;
    font-size: 15px;
    color: white;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-subject::before {
    content: "📚";
    font-size: 16px;
}

.session-date {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
    margin-bottom: 8px;
}

.session-grade {
    display: inline-block;
    background: #ff9a3c;
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    margin-right: 8px;
    border: 2px solid #ffd166;
}

.active-badge {
    display: inline-block;
    background: #4cd964;
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid #ffd166;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.session-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Main Chat Area */
.ailp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

/* Chat Header - FIXED: Added right padding for logout button */
.ailp-chat-header {
    background: linear-gradient(135deg, #ff9a3c 0%, #ff6b6b 100%);
    padding: 15px 40px 15px 70px; /* Increased right padding to 40px */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 4px solid #ffd166;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    flex-shrink: 0;
    min-height: 100px;
}

/* Left side: Title and Subject Info */
.chat-header-left {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 8px;
}

/* Top row: Title and User Info */
.chat-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.chat-title-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-title-area h3 {
    font-size: 20px;
    color: white;
    text-shadow: 2px 2px 0 #ff7b00;
    margin: 0;
    white-space: nowrap;
}

.chat-title-area::before {
    content: "🤖";
    font-size: 28px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* User Info Area - Now on top row with proper spacing */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-right: 30px; /* Increased from 25px to 30px */
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 3px solid #ffd166;
    color: #ff9a3c;
    font-weight: bold;
    flex-shrink: 0;
}

#logout-btn {
    background: white !important;
    color: #ff6b6b !important;
    border: 3px solid white !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-weight: bold !important;
    font-size: 13px !important;
    box-shadow: 0 4px 0 #ff9a3c;
    transition: all 0.2s !important;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

#logout-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 0 #ff9a3c !important;
    background: #fff9f0 !important;
}

/* Bottom row: Subject and Grade */
.subject-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
    margin-top: 5px;
}

/* Subject info - FIXED: Not full width, only takes needed space */
.subject-info {
    background: rgba(255,255,255,0.2);
    padding: 8px 15px;
    border-radius: 15px;
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 14px;
    font-weight: bold;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0; /* Don't shrink */
    max-width: 70%; /* Limit maximum width */
}

.grade-badge {
    background: rgba(255, 255, 255, 0.9);
    color: #ff6b6b;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: bold;
    border: 2px solid #ffd166;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Chat Messages Area */
.ailp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: url('data:image/svg+xml,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="%23f8f9fa"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="%23e9ecef" stroke-width="0.5"/></svg>');
    background-size: 40px 40px;
    position: relative;
    min-height: 0;
}

/* Welcome Screen in Main Area */
.welcome-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    background: linear-gradient(135deg, rgba(255,218,102,0.1) 0%, rgba(102,126,234,0.1) 100%);
}

.welcome-main h2 {
    font-size: 36px;
    color: #667eea;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #ffd166;
    display: flex;
    align-items: center;
    gap: 15px;
}

.welcome-main h2::before {
    content: "🎓";
    font-size: 42px;
}

.welcome-main p {
    font-size: 20px;
    color: #666;
    max-width: 600px;
    margin-bottom: 40px;
    line-height: 1.6;
}

/* Subject Selection - Fixed sizes */
.subject-selection {
    background: white;
    padding: 30px;
    border-radius: 20px;
    border: 4px solid #ffd166;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    max-width: 500px;
    width: 100%;
}

.input-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.input-group select {
    padding: 15px;
    border: 3px solid #667eea;
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Comic Sans MS', sans-serif;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
    min-width: 200px;
    width: 100%;
    box-sizing: border-box;
}

.input-group select:focus {
    outline: none;
    border-color: #ff9a3c;
    box-shadow: 0 0 0 3px rgba(255, 154, 60, 0.2);
}

#start-learning-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: 3px solid #ffd166 !important;
    padding: 16px 40px !important;
    font-size: 18px !important;
    border-radius: 15px !important;
    font-weight: bold !important;
    cursor: pointer;
    transition: all 0.3s !important;
    box-shadow: 0 6px 0 #5a6fd8;
    position: relative;
    overflow: hidden;
}

#start-learning-btn:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 0 #5a6fd8 !important;
}

#start-learning-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 4px 0 #5a6fd8 !important;
}

/* Messages */
.message {
    max-width: 70%;
    margin-bottom: 25px;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    border: 3px solid;
}

.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: #ff9a3c;
    border-color: #ffd166;
    color: white;
}

.user-message .message-avatar::after {
    content: "👦";
}

.ai-message .message-avatar {
    background: #667eea;
    border-color: #ffd166;
    color: white;
}

.ai-message .message-avatar::after {
    content: "🤖";
}

.message-content {
    padding: 20px;
    border-radius: 20px;
    line-height: 1.6;
    font-size: 16px;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.user-message .message-content {
    background: linear-gradient(135deg, #ff9a3c 0%, #ff6b6b 100%);
    color: white;
    border-bottom-right-radius: 5px;
    border: 3px solid #ffd166;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border: 3px solid #667eea;
    border-bottom-left-radius: 5px;
}

/* Chat Input */
.ailp-chat-input {
    padding: 20px 30px;
    background: white;
    border-top: 4px solid #ffd166;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    flex-shrink: 0;
}

.ailp-chat-input .input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 0;
}

#user-message-input {
    flex: 1;
    padding: 18px 25px;
    border: 3px solid #667eea;
    border-radius: 25px;
    font-size: 16px;
    font-family: 'Comic Sans MS', sans-serif;
    transition: all 0.3s;
    background: white;
    color: #333;
    min-width: 0;
}

#user-message-input:focus {
    outline: none;
    border-color: #ff9a3c;
    box-shadow: 0 0 0 3px rgba(255, 154, 60, 0.2);
}

/* SEND Button - FIXED: Removed duplicate text */
#send-message-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: 3px solid #ffd166 !important;
    padding: 14px 20px !important;
    border-radius: 25px !important;
    font-size: 15px !important;
    font-weight: bold !important;
    cursor: pointer;
    transition: all 0.3s !important;
    box-shadow: 0 4px 0 #5a6fd8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    min-width: 90px !important;
    max-width: 100px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop: Add "Send" text */
#send-message-btn::before {
    content: "Send";
}

/* Desktop: Add rocket emoji */
#send-message-btn::after {
    content: "🚀";
    font-size: 16px;
}

#send-message-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 0 #5a6fd8 !important;
}

#send-message-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 3px 0 #5a6fd8 !important;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: white;
    border-radius: 20px;
    border: 3px solid #667eea;
    max-width: 200px;
}

.typing-text {
    color: #667eea;
    font-weight: bold;
    font-size: 16px;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    background: #ff9a3c;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-8px); opacity: 1; }
}

/* Loading State */
.ailp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,218,102,0.1) 0%, rgba(102,126,234,0.1) 100%);
}

.spinner {
    width: 70px;
    height: 70px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #ff9a3c;
    border-right: 6px solid #667eea;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
    margin-bottom: 25px;
    position: relative;
}

.spinner::after {
    content: "🎓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #764ba2;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alerts */
.ailp-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 20px 25px;
    border-radius: 15px;
    z-index: 1000;
    animation: slideInRight 0.3s ease;
    border: 3px solid;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.ailp-alert.error {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff9a3c 100%);
    color: white;
    border-color: #ffd166;
}

.ailp-alert.info {
    background: linear-gradient(135deg, #4cd964 0%, #5ac8fa 100%);
    color: white;
    border-color: #ffd166;
}

/* Login Modal */
.ailp-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 25px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    border: 4px solid #ffd166;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    animation: scaleIn 0.3s ease;
    max-height: 90vh;
    max-height: calc(var(--vh, 1vh) * 90);
    overflow-y: auto;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    border-bottom: 4px solid #ffd166;
}

.modal-header h3 {
    margin: 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.modal-header h3::before {
    content: "🔐";
    font-size: 28px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    color: #ff6b6b;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    border: 3px solid #ffd166;
}

.modal-close:hover {
    background: #fff9f0;
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

#login-form {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input {
    width: 100%;
    padding: 16px 20px;
    border: 3px solid #667eea;
    border-radius: 15px;
    font-size: 16px;
    font-family: 'Comic Sans MS', sans-serif;
    transition: all 0.3s;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: #ff9a3c;
    box-shadow: 0 0 0 3px rgba(255, 154, 60, 0.2);
}

#submit-login-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: 3px solid #ffd166 !important;
    padding: 16px 30px !important;
    border-radius: 15px !important;
    font-size: 18px !important;
    font-weight: bold !important;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s !important;
    box-shadow: 0 4px 0 #5a6fd8;
}

#submit-login-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 0 #5a6fd8 !important;
}

.form-links {
    text-align: center;
    margin-top: 20px;
    color: #666;
    font-size: 14px;
}

.form-links a {
    color: #ff9a3c;
    text-decoration: none;
    font-weight: bold;
}

.form-links a:hover {
    text-decoration: underline;
}

/* Login Messages */
.login-message {
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
    border: 3px solid;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.login-error {
    background: #fff5f5;
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.login-success {
    background: #f0fff4;
    border-color: #4cd964;
    color: #2ecc71;
}

/* No Sessions State */
.no-sessions-sidebar {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255,255,255,0.8);
}

.no-sessions-sidebar p {
    margin-bottom: 20px;
    font-size: 16px;
}

/* Kid-friendly decorations */
.floating-emoji {
    position: absolute;
    font-size: 24px;
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

/* Hamburger Menu Button - Always visible on mobile */
.hamburger-menu {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: #ff9a3c;
    border: 3px solid #ffd166;
    border-radius: 10px;
    width: 50px;
    height: 50px;
    display: none; /* Hidden by default, shown on mobile */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 4px 0 #ff7b00;
    transition: all 0.3s;
}

/* When logged out, show hamburger to access login */
.hamburger-menu.logged-out {
    background: #667eea;
    border-color: #ffd166;
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

/* Mobile floating new session button */
.mobile-new-session-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: #ff9a3c !important;
    color: white !important;
    border: 3px solid #ffd166 !important;
    border-radius: 50% !important;
    width: 60px;
    height: 60px;
    display: none !important; /* Hidden by default */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 100;
    font-size: 24px !important;
    padding: 0 !important;
    cursor: pointer;
}

.mobile-new-session-btn::after {
    content: "✨";
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    /* Show hamburger menu on mobile */
    .hamburger-menu {
        display: flex;
    }
    
    /* Mobile floating new session button - show when logged in */
    .mobile-new-session-btn {
        display: flex !important;
    }
    
    /* Sidebar fixed positioning for mobile */
    .ailp-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        z-index: 1002;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 5px 0 20px rgba(0,0,0,0.2);
        display: flex !important;
    }
    
    /* Show sidebar when active */
    .ailp-sidebar.active {
        transform: translateX(0);
    }
    
    /* Show close button in sidebar */
    .close-sidebar {
        display: flex;
    }
    
    /* Full screen main area - FIXED LAYOUT */
    .ailp-interface {
        flex-direction: column;
    }
    
    .ailp-main {
        width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* When sidebar is open, shift main content */
    .ailp-sidebar.active + .ailp-main {
        transform: translateX(85%);
        transition: transform 0.3s ease;
    }
    
    /* Chat header adjustments - FIXED: Added more margin to logout button */
    .ailp-chat-header {
        padding: 10px 30px 10px 65px; /* Increased right padding from 25px to 30px */
        min-height: 90px;
        flex-wrap: nowrap;
        align-items: flex-start;
    }
    
    .chat-header-left {
        gap: 5px;
    }
    
    .chat-top-row {
        align-items: flex-start;
    }
    
    .chat-title-area {
        gap: 8px;
    }
    
    .chat-title-area h3 {
        font-size: 16px;
    }
    
    .chat-title-area::before {
        font-size: 22px;
    }
    
    .user-info {
        margin-top: 0;
        gap: 8px;
        margin-right: 25px; /* Increased from 20px to 25px */
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-width: 2px;
    }
    
    #logout-btn {
        padding: 5px 10px !important;
        font-size: 11px !important;
        border-width: 2px !important;
        border-radius: 15px !important;
    }
    
    .subject-info-row {
        gap: 8px;
        margin-top: 3px;
    }
    
    /* Subject info - MOBILE: Not full width */
    .subject-info {
        font-size: 13px;
        padding: 6px 10px;
        border-radius: 12px;
        max-width: 60%; /* Limit width on mobile */
    }
    
    .grade-badge {
        font-size: 12px;
        padding: 4px 8px;
        border-radius: 10px;
    }
    
    /* Chat messages area */
    .ailp-chat-messages {
        padding: 15px;
        height: calc(100vh - 90px - 70px);
        height: calc(calc(var(--vh, 1vh) * 100) - 90px - 70px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
    }
    
    .message {
        max-width: 85%;
    }
    
    .message-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .message-content {
        padding: 15px;
        font-size: 15px;
    }
    
    /* Chat input at bottom */
    .ailp-chat-input {
        padding: 10px 15px;
        background: white;
        z-index: 10;
        height: 70px;
        min-height: 70px;
        max-height: 70px;
        flex-shrink: 0;
        border-top: 3px solid #ffd166;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    }
    
    .ailp-chat-input .input-group {
        flex-direction: row;
    }
    
    #user-message-input {
        flex: 1;
        padding: 12px 15px;
        font-size: 15px;
        min-height: 45px;
        border-width: 2px;
    }
    
    /* SEND Button - MOBILE FIX: Remove rocket emoji, show only "SEND" */
    #send-message-btn {
        min-width: 75px !important;
        max-width: 85px;
        padding: 10px 12px !important;
        font-size: 13px !important;
        height: 45px;
        border-width: 2px !important;
    }
    
    /* Mobile: Remove rocket emoji, show only text */
    #send-message-btn::before {
        content: "SEND 🚀";
    }
    
    #send-message-btn::after {
        content: "" !important; /* Remove emoji on mobile */
    }
    
    /* Welcome/new session screen */
    .welcome-main {
        padding: 60px 20px 80px;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        overflow-y: auto;
    }
    
    /* Sidebar content adjustments */
    .sidebar-header {
        padding: 20px;
        position: relative;
    }
    
    #new-session-sidebar {
        margin: 15px;
        width: calc(100% - 30px);
        font-size: 14px !important;
        padding: 10px 15px !important;
    }
    
    .sessions-container {
        max-height: calc(100vh - 200px);
        max-height: calc(calc(var(--vh, 1vh) * 100) - 200px);
        overflow-y: auto;
    }
    
    .session-item {
        min-width: auto;
        margin: 0 15px 10px;
    }
    
    /* When not logged in, make sidebar more compact */
    .no-sessions-sidebar {
        padding: 20px;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    /* Make login button in sidebar more prominent on mobile */
    .no-sessions-sidebar #show-login-btn {
        margin-top: 15px !important;
        padding: 12px 20px !important;
        font-size: 16px !important;
        width: 80%;
        align-self: center;
    }
    
    .subject-selection {
        padding: 20px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .input-group {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* Loading state adjustments */
    .ailp-loading {
        padding: 40px 20px;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .spinner {
        width: 50px;
        height: 50px;
        margin-bottom: 20px;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    /* Alerts position for mobile */
    .ailp-alert {
        left: 20px;
        right: 20px;
        max-width: calc(100% - 40px);
        text-align: center;
    }
    
    /* Floating emojis - hide on mobile */
    .floating-emoji {
        display: none;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .hamburger-menu {
        top: 8px;
        left: 8px;
        width: 40px;
        height: 40px;
        border-width: 2px;
    }
    
    .hamburger-menu span {
        width: 20px;
        height: 2px;
    }
    
    .ailp-chat-header {
        padding: 8px 25px 8px 55px; /* Increased right padding from 20px to 25px */
        min-height: 85px;
    }
    
    .chat-title-area h3 {
        font-size: 15px;
    }
    
    .chat-title-area::before {
        font-size: 20px;
    }
    
    .user-info {
        margin-right: 20px; /* Increased from 15px to 20px */
    }
    
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    #logout-btn {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }
    
    /* Subject info - Extra small screens */
    .subject-info {
        font-size: 12px;
        padding: 5px 8px;
        max-width: 55%; /* Even smaller on extra small screens */
    }
    
    .grade-badge {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .ailp-chat-messages {
        height: calc(100vh - 85px - 65px);
        height: calc(calc(var(--vh, 1vh) * 100) - 85px - 65px);
    }
    
    /* SEND Button - Extra small screen fix */
    #send-message-btn {
        min-width: 70px !important;
        max-width: 75px;
        padding: 8px 10px !important;
        font-size: 12px !important;
        height: 40px;
    }
    
    #user-message-input {
        padding: 10px 12px;
        font-size: 14px;
        min-height: 40px;
    }
    
    .ailp-chat-input {
        height: 65px;
        min-height: 65px;
        max-height: 65px;
        padding: 8px 12px;
    }
    
    .mobile-new-session-btn {
        bottom: 60px;
        right: 12px;
        width: 45px;
        height: 45px;
        font-size: 20px !important;
        border-width: 2px !important;
    }
    
    .sidebar-header h2 {
        font-size: 18px;
    }
    
    .sidebar-header p {
        font-size: 11px;
    }
    
    .welcome-main h2 {
        font-size: 22px;
    }
    
    .welcome-main p {
        font-size: 14px;
    }
    
    #start-learning-btn {
        padding: 12px 20px !important;
        font-size: 15px !important;
    }
#ailp-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: none; /* Hidden by default */
}

#ailp-wrapper.active {
    display: block;
}

/* Make sure the AI interface is contained within the wrapper */
#ailp-wrapper .ailp-interface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10001;
}

/* Educational Images Styles - Add to your existing CSS */
.educational-image-container {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0ff 100%);
    border-radius: 12px;
    border: 1px solid #e0e7ff;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.1);
}

.image-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #d0d7ff;
}

.image-label {
    font-weight: 600;
    color: #4a90e2;
    margin-right: 8px;
    font-size: 14px;
}

.image-title {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.educational-image {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.educational-image img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 300px;
    object-fit: contain;
    background: #fff;
}

.image-caption {
    margin-top: 10px;
    text-align: center;
    color: #666;
    font-size: 12px;
    font-style: italic;
}

.image-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #f0f5ff 0%, #e0ebff 100%);
    border: 2px dashed #c2d6ff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-placeholder.error {
    background: linear-gradient(135deg, #fff0f0 0%, #ffe0e0 100%);
    border-color: #ffc2c2;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.7;
}

.placeholder-text {
    font-weight: 500;
    color: #555;
    text-align: center;
    margin-bottom: 8px;
}

.placeholder-hint {
    font-size: 11px;
    color: #888;
    text-align: center;
    max-width: 300px;
}

.image-search-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 13px;
}

.spinner.small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(74, 144, 226, 0.3);
    border-top-color: #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mobile Responsive Images */
@media (max-width: 768px) {
    .educational-image {
        max-width: 100%;
    }
    
    .educational-image img {
        max-height: 200px;
    }
    
    .image-placeholder {
        height: 150px;
    }
    
    .placeholder-icon {
        font-size: 36px;
    }
}
/* SVG Placeholder Styles */
.svg-placeholder {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.svg-placeholder svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Enhanced placeholder styles */
.image-placeholder {
    width: 100%;
    min-height: 200px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0ff 100%);
    border: 2px dashed #c2d6ff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
}

.image-placeholder .placeholder-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.8;
}

.image-placeholder .placeholder-text {
    font-weight: 600;
    color: #4a90e2;
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
}

.image-placeholder .placeholder-hint {
    font-size: 14px;
    color: #666;
    text-align: center;
    max-width: 300px;
    line-height: 1.4;
}
/* Simplified Text Formatting */
.message-content p {
    margin-bottom: 16px;
    line-height: 1.6;
    color: #333;
    font-size: 16px;
}

.message-content .lesson-separator {
    display: block;
    border: none;
    border-top: 2px dashed #c2d6ff;
    margin: 24px 0;
    height: 1px;
}

.message-content .lesson-title,
.message-content .step-heading {
    background: linear-gradient(135deg, #4a90e2, #2c6bb5);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
    margin: 20px 0;
    font-size: 18px;
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.2);
}

.message-content .step-heading {
    background: linear-gradient(135deg, #51cf66, #2f9e44);
}

/* Lists - Much simpler */
.message-content ol.numbered-list {
    margin: 16px 0;
    padding-left: 24px;
}

.message-content ul.bullet-list {
    margin: 16px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: #444;
}

.message-content li.numbered-item {
    list-style-type: decimal;
}

.message-content li.bullet-item {
    list-style-type: disc;
}

/* Spacing */
.message-content p + .lesson-title,
.message-content p + .step-heading,
.message-content .lesson-title + p,
.message-content .step-heading + p {
    margin-top: 20px;
}

.message-content ol + p,
.message-content ul + p {
    margin-top: 16px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .message-content p {
        font-size: 15px;
        line-height: 1.5;
    }
    
    .message-content .lesson-title,
    .message-content .step-heading {
        font-size: 16px;
        padding: 10px 12px;
    }
}