* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

#math-chatbot-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
	margin-top: 60px;
}

#start-screen {
    height: 100%;
    text-align: center;
    padding: 0px;
}

#start-screen .startinner {
  background: #ea4435;
  border-radius: 25px 25px 25px 25px;
  padding: 30px;
  min-height: 250px;
  margin: 0px 0px 25px 0px;
  border-bottom: 5px solid #cc202a;
}

#start-screen h1 {
    color: #ffffff;
    font-size: 30px;
    font-weight: 600;
    max-width: 600px;
	line-height: 30px;
	margin: 25px auto;
}

#start-screen p {
    color: #fff;
    font-size: 16px;
    margin: -20px 0px 25px 0px;
	line-height: normal;
	text-align: center;
}

.start-btn {
    background-color: #cd202a;
    color: #fff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(205, 32, 42, 0.3);
}

.start-btn:hover {
    background-color: #b01821;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(205, 32, 42, 0.4);
}

.start-btn:active {
    transform: translateY(0);
}

/* ====================================
   CHAT AREA - CHATGPT STYLE
   ==================================== */
#chat-area {
    flex: 1;
    display: none;
	background: none;
    overflow-y: auto;
    scroll-behavior: smooth;
    min-height: 0;
	/*padding-top: 100px;*/
}

#chat-area::-webkit-scrollbar {
    width: 4px;
}

#chat-area::-webkit-scrollbar-track {
    background: transparent;
}

#chat-area::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

#chat-area::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

#chat-messages {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100%;
    padding-bottom: 20px;
}

/* ====================================
   MESSAGE STYLES - CHATGPT LIKE
   ==================================== */
   
.passcode-yes-btn { background: #10b981 !important; color: #fff !important; border: none !important;}
.passcode-no-btn { background: #ea4435 !important; color: #fff !important; border: none !important;}

.message {
    max-width: 100%;
    padding: 16px 20px;
    border-radius: 12px 12px 0px 12px;
    font-size: 15px;
    line-height: 1.5;
    animation: messageIn 0.3s ease-out;
    word-wrap: break-word;
    position: relative;
}

.message.bot {
    background-color: #fff;
    color: #00234b;
    align-self: flex-start;
    border: 1px solid #e5e5e5;
    margin-right: 80px;
	border-bottom: 2px solid #d6d5d0;
}

.message.bot::before {
    content: '';
    position: absolute;
    left: -2px;
    top: -4px;
    width: 12px;
    height: 12px;
    background-color: #ea4435;
    border-radius: 50%;
    background-size: 14px 14px;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 0 rgba(234, 68, 53, 0.4);
    animation: breathe-ring 3s ease-in-out infinite;
}

@keyframes breathe-ring {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(234, 68, 53, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(234, 68, 53, 0.1);
    }
}

.message.user {
    background-color: #feed5a;
    color: #000;
    align-self: flex-end;
    margin-left: 80px;
    font-weight: 500;
	border-bottom: 2px solid #dccd48;
}

.message.user i { color: #000000; margin-right: 10px; margin-bottom: 0px !important;}

.message.user.correct {
    background-color: #10b981;
    color: white;
}

.message.user.incorrect {
    background-color: #ef4444;
    color: white;
}

.message.fade-out {
    animation: fadeOut 0.3s ease-in-out forwards;
}

.more-tests-question { margin-top: 20px;}

/* ====================================
   QUESTION TIMER
   ==================================== */
.message.bot.question {
    position: relative;
    padding-right: 60px;
}

.message.bot.question .question-timer {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: conic-gradient(#10b981 100%, #e5e7eb 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #00234b;
    background-color: white;
    border: 2px solid #e5e7eb;
}

.message.bot.question .question-timer .timer-text {
    position: absolute;
    font-weight: 600;
    color: #00234b;
}

.message.bot.question .question-timer.urgent {
    background: conic-gradient(#ef4444 var(--progress, 100%), #e5e7eb var(--progress, 100%));
    border-color: #ef4444;
    animation: urgentPulse 0.5s infinite alternate;
}

/* ====================================
   ANSWER ICONS
   ==================================== */
.answer-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.answer-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

/* ====================================
   BUTTON GROUPS
   ==================================== */
.operation-buttons, .grade-buttons, .test-buttons, .result-buttons, .subject-buttons, .sub-topic-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Common Button Styles */
.operation-btn, .grade-btn, .test-btn, .show-more-tests-btn, .show-all-tests-again-btn, .subject-btn, .sub-topic-btn, .show-more-sub-topics-btn, .show-all-sub-topics-again-btn {
    color: #00234b;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #fdc4ed; /* Default color */
}

/* Individual button colors using nth-child selector */
.operation-btn:nth-child(1), .grade-btn:nth-child(1), .test-btn:nth-child(1), .subject-btn:nth-child(1), .sub-topic-btn:nth-child(1) {
    background-color: #b8a8ff;
}

.operation-btn:nth-child(2), .grade-btn:nth-child(2), .test-btn:nth-child(2), .subject-btn:nth-child(2), .sub-topic-btn:nth-child(2) {
    background-color: #76edf6;
}

.operation-btn:nth-child(3), .grade-btn:nth-child(3), .test-btn:nth-child(3), .subject-btn:nth-child(3), .sub-topic-btn:nth-child(3) {
    background-color: #99bbff;
}

.operation-btn:nth-child(4), .grade-btn:nth-child(4), .test-btn:nth-child(4), .subject-btn:nth-child(4), .sub-topic-btn:nth-child(4) {
    background-color: #ffdaa3;
}

.operation-btn:nth-child(5), .grade-btn:nth-child(5), .test-btn:nth-child(5), .subject-btn:nth-child(5), .sub-topic-btn:nth-child(5) {
    background-color: #ffd4ca;
}

.operation-btn:nth-child(6), .grade-btn:nth-child(6), .test-btn:nth-child(6), .subject-btn:nth-child(6), .sub-topic-btn:nth-child(6) {
    background-color: #fdc4ed;
}

.operation-btn:nth-child(7), .grade-btn:nth-child(7), .test-btn:nth-child(7), .subject-btn:nth-child(7), .sub-topic-btn:nth-child(7) {
    background-color: #daffa4;
}

/* Cycle through colors for buttons beyond 7 */
.operation-btn:nth-child(8), .grade-btn:nth-child(8), .test-btn:nth-child(8), .subject-btn:nth-child(8), .sub-topic-btn:nth-child(8) {
    background-color: #b8a8ff;
}

.operation-btn:nth-child(9), .grade-btn:nth-child(9), .test-btn:nth-child(9), .subject-btn:nth-child(9), .sub-topic-btn:nth-child(9) {
    background-color: #76edf6;
}

/* Hover effects for all buttons */
.operation-btn:hover, .grade-btn:hover, .test-btn:hover, .show-more-tests-btn:hover, .show-all-tests-again-btn:hover, .subject-btn:hover, .sub-topic-btn:hover, .show-more-sub-topics-btn:hover, .show-all-sub-topics-again-btn:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.operation-btn:active, .grade-btn:active, .test-btn:active, .show-more-tests-btn:active, .show-all-tests-again-btn:active, .subject-btn:active, .sub-topic-btn:active, .show-more-sub-topics-btn:active, .show-all-sub-topics-again-btn:active {
    background-color: #f3f4f6;
}

.completed-test { background: #10b981 !important; color: #fff !important;}

/* Multiple Choice Answer Options */
.answer-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}
.answer-option {
    background-color: #ffffff;
    color: #00234b;
    border: 1px solid #d1d5db;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    text-align: left;
    min-height: 48px;
    display: flex;
    align-items: center;
}
.answer-option:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}
.answer-option:active {
    background-color: #f3f4f6;
}
.answer-option:disabled {
    background-color: #f9fafb;
    color: #6b7280;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

/* Result Buttons */
.save-btn {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.retry-btn {
    background-color: #6b7280;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.save-btn:hover {
    background-color: #059669;
}

.retry-btn:hover {
    background-color: #4b5563;
}

/* ====================================
   CHAT INPUT AREA - BOTTOM FIXED LIKE CHATGPT
   ==================================== */
#chat-input-area {
    display: none;
    background-color: #ffffff;
    border-top: 1px solid #e5e5e5;
    padding: 20px;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 35, 75, 0.05);
    position: relative;
    z-index: 20;
	margin-bottom: 60px;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
    background-color: #ffffff;
    color: #00234b;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
}

#chat-input:focus {
    border-color: #9ca3af;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.1);
}

#chat-input:disabled {
    background-color: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
}

#send-answer {
    background-color: #feed5a;
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    position: relative;
}

#send-answer:hover {
    background-color: #dfcd34;
}

#send-answer:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Send button arrow icon */
#send-answer::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 10px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-40%, -50%);
}

#send-answer:disabled::after {
    border-left-color: #9ca3af;
}

/* ====================================
   UTILITY CLASSES
   ==================================== */
.badge {
    background-color: #fff04b;
    color: #00234b;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
    margin: 0 2px;
    border: 1px solid #e6d643;
}

.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ====================================
   ANIMATIONS
   ==================================== */
@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes spin {
    0% { 
        transform: translateY(-50%) rotate(0deg); 
    }
    100% { 
        transform: translateY(-50%) rotate(360deg); 
    }
}

@keyframes urgentPulse {
    from { 
        box-shadow: 0 0 0 rgba(239, 68, 68, 0.4); 
    }
    to { 
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); 
    }
}

@keyframes typingBounce {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

/* ====================================
   RESPONSIVE DESIGN - MOBILE OPTIMIZED
   ==================================== */
@media (max-width: 768px) {
    #math-chatbot-container {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
	
	#chatbot-header {
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 30;
    }
    
    #start-screen {
        padding: 0px !important;
    }
	
	#start-screen .startinner {
  background: #ea4435;
  border-radius: 0px 0px 30px 30px;
  padding: 30px;
  min-height: 250px;
  margin: 0px 0px 25px 0px;
  border-bottom: 5px solid #cc202a;
}
    
    #chat-area {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #chat-messages {
        /*padding: 16px;
        gap: 16px;
        padding-bottom: 20px;*/
    }
    
    .message {
        font-size: 14px;
        padding: 12px 16px;
    }

    /* Fixed input area for mobile */
    #chat-input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 12px 16px;
        background-color: #ffffff;
        border-top: 1px solid #e5e5e5;
        box-shadow: 0 -2px 10px rgba(0, 35, 75, 0.1);
        z-index: 1000;
        max-height: 25vh;
        overflow: visible;
		margin-bottom: 0px;
    }
    
    .input-container {
        max-width: none;
        margin: 0;
        gap: 8px;
    }
    
    #chat-input {
        font-size: 16px;
        padding: 12px 14px;
        border-radius: 20px;
        max-height: 100px;
        overflow-y: auto;
    }
    
    #send-answer {
        width: 40px;
        height: 40px;
        border-radius: 20px;
        flex-shrink: 0;
    }
    
    /* Better arrow icon for mobile */
    #send-answer::after {
        border-left: 8px solid #00234b;
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        transform: translate(-35%, -50%);
    }
    
    #send-answer:disabled::after {
        border-left-color: #9ca3af;
    }
    
    /* Adjust chat area bottom padding when input is visible */
    body.keyboard-open #chat-area {
        padding-bottom: 0;
    }
    
    body:not(.keyboard-open) #chat-area {
        /*padding-bottom: 80px;*/
    }
    
    .grade-checkboxes {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
        padding: 12px;
    }
    
    .grade-checkbox {
        padding: 6px 8px;
    }
    
    .grade-checkbox input[type="radio"],
    .grade-checkbox input[type="checkbox"] {
        width: 14px;
        height: 14px;
    }
    
    .grade-checkbox label {
        font-size: 13px;
    }
    
    .operation-buttons, .grade-buttons, .test-buttons, .result-buttons, .subject-buttons, .sub-topic-buttons {
        gap: 8px;
    }
    
    .operation-btn, .grade-btn, .test-btn, .subject-btn, .sub-topic-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 40px;
    }
}

/* Extra Small Screens */
@media (max-width: 480px) {
    
    .message.bot {
        margin-right: 10px;
    }
    
    .message.user {
        margin-left: 10px;
    }
    
    #chat-input-area {
        padding: 10px 12px;
		margin-bottom: 0px;
    }
	
	#start-screen .startinner {
  background: #ea4435;
  border-radius: 0px 0px 30px 30px;
  padding: 30px;
  min-height: 250px;
  margin: 0px 0px 25px 0px;
  border-bottom: 5px solid #cc202a;
}
    
    #chat-input {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    #send-answer {
        width: 36px;
        height: 36px;
    }
    
    #send-answer::after {
        border-left: 7px solid #00234b;
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
    }
    
}