/* Global Styles & Variables */
:root {
    --primary-color: #6a11cb;
    --secondary-color: #2575fc;
    --text-color: #333;
    --bg-color: #f4f7f6;
    --widget-bg: #ffffff;
    --header-bg: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --user-msg-bg: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --bot-msg-bg: #f1f1f1;
    --border-radius: 15px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.main-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
}

.main-content h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.main-content p {
    font-size: 1.2rem;
    margin-top: 1rem;
    color: #666;
}

/* Chat Launcher */
.chat-launcher {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: var(--header-bg);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 999;
}

.chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

/* Chat Widget Container */
.chat-widget-container {
    position: fixed;
    bottom: 100px;
    left: 30px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transform: scale(0.5) translateY(50%);
    opacity: 0;
    transform-origin: bottom left;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
    display: flex;
    pointer-events: none;
}

.chat-widget-container.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chat-widget-container.fullscreen {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    bottom: 0;
    border-radius: 0;
    max-height: 100vh;
}

.chat-widget {
    width: 100%;
    height: 100%;
    background: var(--widget-bg);
    display: flex;
    flex-direction: column;
}

/* Chat Header */
.chat-header {
    background: var(--header-bg);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-title h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.chat-header-buttons {
    display: flex;
    gap: 10px;
}

.chat-header-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header-btn:hover {
    opacity: 1;
}

/* Chat Views */
.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
}

/* Main Menu */
#main-menu {
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    overflow-y: auto;
}

.main-menu-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.main-menu-header {
    background: var(--header-bg);
    color: white;
    padding: 30px 20px;
    text-align: center;
    border-bottom: 3px solid rgba(255, 255, 255, 0.2);
}

.platform-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
}

.platform-subtitle {
    font-size: 0.95rem;
    margin: 8px 0 0 0;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.menu-cards {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    flex: 1;
    justify-content: center;
}

.menu-card {
    background: white;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(106, 17, 203, 0.15);
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #ffffff 0%, #f8f5ff 100%);
}

.menu-card-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.menu-card h3 {
    font-size: 1.25rem;
    color: var(--primary-color);
    margin: 0 0 8px 0;
    font-weight: 600;
}

.menu-card p {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* Back Button */
.back-button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 20px;
    align-self: flex-start;
}

/* Assignment View Header */
.assignment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 20px;
    border-bottom: 1px solid #eee;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.session-badge {
    background: #eee;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-secondary {
    background: none;
    border: 1px solid #ccc;
    color: #555;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #eee;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--widget-bg);
}

/* Messages */
.message {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.bot-avatar {
    background: var(--header-bg);
    color: white;
}

.user-avatar {
    background: #ddd;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    padding: 12px 18px;
    border-radius: var(--border-radius);
    line-height: 1.6;
    font-size: 0.95rem;
    color: var(--text-color);
    word-wrap: break-word;
}

.bot-message .message-text {
    background: var(--bot-msg-bg);
    border-top-left-radius: 0;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-text {
    background: var(--user-msg-bg);
    color: white;
    border-top-right-radius: 0;
}

.message-text strong {
    font-weight: 600;
}

.message-text p, .message-text ul {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.message-text ul {
    padding-left: 1.2em;
}

/* Input Container */
.input-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-top: 1px solid #eee;
    background: #fff;
    gap: 12px;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.input-field {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--header-bg);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
    align-self: center;
}

.btn-send:hover {
    transform: scale(1.1);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Microphone Button */
.btn-mic {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: #f5f5f5;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    font-size: 18px;
    align-self: center;
}

.btn-mic:hover {
    background: #e8e8e8;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.btn-mic:active {
    transform: scale(0.95);
}

.btn-mic.recording {
    background: #ff4444;
    border-color: #cc0000;
    color: white;
    animation: mic-pulse 1.5s infinite;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
}

@keyframes mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
    }
}

/* Modal Confirmation Popup */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeInOverlay 0.3s ease;
}

.modal-overlay.active {
    display: flex;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.modal-content p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn-cancel {
    background: #f0f0f0;
    color: #555;
}

.modal-btn-cancel:hover {
    background: #e0e0e0;
}

.modal-btn-confirm {
    background: var(--header-bg);
    color: white;
}

.modal-btn-confirm:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Scrollbar */
.chat-container::-webkit-scrollbar { width: 6px; }
.chat-container::-webkit-scrollbar-track { background: #f1f1f1; }
.chat-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.chat-container::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Responsive */
@media (max-width: 480px) {
    .chat-widget-container {
        width: calc(100% - 40px);
        left: 20px;
        bottom: 90px;
        height: calc(100vh - 110px);
    }
    .chat-launcher {
        bottom: 20px;
        left: 20px;
    }

    .input-container {
        padding: 12px;
        gap: 10px;
    }

    .input-wrapper {
        gap: 6px;
    }

    .btn-send,
    .btn-mic {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .input-field {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .input-container {
        padding: 14px;
        gap: 11px;
    }
}
