/* ===================================
   Reset & Base Styles
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Vibrant Color Palette */
    --primary-color: #3B82F6;
    --primary-dark: #1E40AF;
    --primary-light: #60A5FA;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --success-color: #22C55E;
    --info-color: #06B6D4;
    --purple-color: #A855F7;
    --pink-color: #EC4899;
    --indigo-color: #6366F1;
    
    /* Background Colors */
    --bg-gradient-1: #667EEA;
    --bg-gradient-2: #764BA2;
    --bg-gradient-3: #F093FB;
    --bg-gradient-4: #F5576C;
    --bg-color: #F0F9FF;
    --surface-color: #FFFFFF;
    
    /* Text Colors */
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-white: #FFFFFF;
    
    /* Border & Shadows */
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 25%, #F093FB 50%, #F5576C 100%);
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-primary);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===================================
   Header - Fixed Position
   =================================== */
.header {
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 30px -10px rgba(59, 130, 246, 0.5);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo i {
    font-size: 2rem;
    color: #FCD34D;
    filter: drop-shadow(0 0 10px rgba(252, 211, 77, 0.5));
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--text-white);
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.score-board {
    background: rgba(255, 255, 255, 0.9);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 5px 20px -5px rgba(0, 0, 0, 0.2);
}

.score-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.score-value {
    background: linear-gradient(135deg, #22C55E, #16A34A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    font-size: 1.1rem;
}

/* ===================================
   Main Content - Fixed Padding
   =================================== */
.main-content {
    flex: 1;
    padding: 90px 20px 20px 20px; /* Top padding for fixed header */
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 110px);
}

/* ===================================
   Welcome Screen - Centered Properly
   =================================== */
.welcome-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 150px);
    padding: 20px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    padding: 2.5rem;
    border-radius: 25px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.3);
    max-width: 850px;
    width: 100%;
    text-align: center;
    animation: fadeIn 0.6s ease;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    margin: auto;
}

.welcome-icon {
    font-size: 3.5rem;
    background: linear-gradient(135deg, #F59E0B, #EF4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    filter: drop-shadow(0 5px 10px rgba(245, 158, 11, 0.3));
}

.welcome-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Topic Grid - Responsive */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.topic-btn {
    background: white;
    border: 2px solid transparent;
    padding: 1.2rem 1rem;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Topic Button Colors */
.topic-btn[data-topic="data-structures"] {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-color: #FCD34D;
}

.topic-btn[data-topic="algorithms"] {
    background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
    border-color: #60A5FA;
}

.topic-btn[data-topic="operating-systems"] {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
    border-color: #34D399;
}

.topic-btn[data-topic="dbms"] {
    background: linear-gradient(135deg, #FED7E2, #FBCFE8);
    border-color: #F9A8D4;
}

.topic-btn[data-topic="networks"] {
    background: linear-gradient(135deg, #E9D5FF, #DDD6FE);
    border-color: #C4B5FD;
}

.topic-btn[data-topic="oop"] {
    background: linear-gradient(135deg, #FED7AA, #FDBA74);
    border-color: #FB923C;
}

.topic-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

.topic-btn i {
    font-size: 1.8rem;
    transition: transform 0.3s ease;
}

.topic-btn span {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.difficulty-selector select {
    padding: 0.5rem 1rem;
    border: 2px solid #3B82F6;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    background: white;
}

/* ===================================
   Chat Interface - Fixed Positioning
   =================================== */
.chat-interface {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    border-radius: 25px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.3);
    height: calc(100vh - 120px);
    max-height: 750px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    margin: 0 auto;
    width: 100%;
    max-width: 1100px;
}

.topic-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #3B82F6, #8B5CF6, #EC4899);
    color: white;
    border-radius: 23px 23px 0 0;
    flex-shrink: 0;
    min-height: 60px;
}

.topic-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 10px;
}

/* ===================================
   Chat Messages - Fixed Container
   =================================== */
.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: linear-gradient(135deg, #F8FAFC 0%, #EFF6FF 100%);
    max-height: calc(100vh - 350px);
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 0.5rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message.user {
    justify-content: flex-end;
}

.message-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 3px 10px -3px rgba(0, 0, 0, 0.2);
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #F59E0B, #EF4444);
    color: white;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    order: 2;
}

.message-content {
    max-width: 70%;
    padding: 1rem 1.2rem;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.95rem;
}

.message.bot .message-content {
    background: white;
    color: var(--text-primary);
    border-bottom-left-radius: 5px;
    box-shadow: 0 3px 10px -3px rgba(0, 0, 0, 0.1);
}

.message.user .message-content {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    border-bottom-right-radius: 5px;
    order: 1;
    box-shadow: 0 3px 10px -3px rgba(59, 130, 246, 0.3);
}

/* Feedback Messages */
.message-content.feedback {
    padding: 1rem 1.2rem;
    border-left: 4px solid;
}

.message-content.correct {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0) !important;
    color: #065F46 !important;
    border-left-color: #10B981;
}

.message-content.incorrect {
    background: linear-gradient(135deg, #FEE2E2, #FECACA) !important;
    color: #991B1B !important;
    border-left-color: #EF4444;
}

/* ===================================
   Chat Input - Fixed Bottom
   =================================== */
.chat-input-container {
    padding: 1.2rem 1.5rem;
    border-top: 2px solid var(--border-color);
    background: white;
    flex-shrink: 0;
    border-radius: 0 0 23px 23px;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 45px;
}

#userInput:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-btn {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    min-width: 45px;
    min-height: 45px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 15px -5px rgba(59, 130, 246, 0.5);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hint-btn {
    background: linear-gradient(135deg, #FCD34D, #F59E0B);
    color: white;
}

.skip-btn {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
}

.end-btn {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
}

/* ===================================
   Results Screen - Centered Properly
   =================================== */
.results-screen {
    display: none;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 150px);
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

.results-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    padding: 2.5rem;
    border-radius: 25px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    text-align: center;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    margin: auto;
}

.results-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, #FCD34D, #F59E0B);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    animation: bounce 1s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.results-card h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem 0;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3B82F6, #8B5CF6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.performance-message {
    background: linear-gradient(135deg, #F0F9FF, #E0F2FE);
    padding: 1.2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.primary-btn, .secondary-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.primary-btn {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
}

.secondary-btn {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
}

.primary-btn:hover, .secondary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px -5px rgba(0, 0, 0, 0.2);
}

/* ===================================
   Footer - Fixed Bottom
   =================================== */
/* .footer {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    box-shadow: 0 -5px 20px -10px rgba(0, 0, 0, 0.1);
    margin-top: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 0.9rem;
}

.footer i {
    color: #EF4444;
    animation: heartbeat 1.5s ease infinite;
} */

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===================================
   Scrollbar Styling
   =================================== */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Firefox */
.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F5F9;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
    .header {
        padding: 0.8rem 1rem;
        height: 60px;
    }
    
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 75px 15px 15px 15px;
    }
    
    .welcome-card {
        padding: 1.5rem;
    }
    
    .welcome-icon {
        font-size: 2.5rem;
    }
    
    .welcome-card h2 {
        font-size: 1.4rem;
    }
    
    .topic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .topic-btn {
        padding: 1rem 0.5rem;
    }
    
    .topic-btn i {
        font-size: 1.4rem;
    }
    
    .topic-btn span {
        font-size: 0.8rem;
    }
    
    .chat-interface {
        height: calc(100vh - 90px);
        max-height: none;
        border-radius: 20px;
    }
    
    .topic-header {
        padding: 1rem;
        flex-wrap: wrap;
        min-height: auto;
    }
    
    .topic-header h3 {
        font-size: 1rem;
    }
    
    .back-btn, .timer {
        font-size: 0.8rem;
        padding: 0.4rem 0.7rem;
    }
    
    .chat-messages {
        padding: 1rem;
        max-height: calc(100vh - 280px);
    }
    
    .message-content {
        max-width: 85%;
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    .message-avatar {
        width: 35px;
        height: 35px;
        min-width: 35px;
        min-height: 35px;
        font-size: 1rem;
    }
    
    .chat-input-container {
        padding: 1rem;
    }
    
    #userInput {
        padding: 0.7rem;
        font-size: 0.9rem;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .action-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .results-card {
        padding: 1.5rem;
    }
    
    .results-icon {
        font-size: 3rem;
    }
    
    .results-card h2 {
        font-size: 1.4rem;
    }
    
    .results-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .primary-btn, .secondary-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* .footer {
        font-size: 0.8rem;
        padding: 0.7rem;
    } */
}

@media (max-width: 480px) {
    .topic-grid {
        grid-template-columns: 1fr;
    }
    
    .message-content {
        max-width: 90%;
    }
}

/* ===================================
   Utility Classes
   =================================== */
.hidden {
    display: none !important;
}

.visible {
    display: flex !important;
}

/* Disable scrolling on body when modal is open */
body.modal-open {
    overflow: hidden;
}