@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700&display=swap');

:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --background-color: #f4f7f9;
    --text-color: #34495e;
    --panel-bg: rgba(255, 255, 255, 0.75); /* Enhanced transparency */
    --border-radius: 15px;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

/* Animation Keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body {
    font-family: 'Noto Serif SC', serif; /* Switched to a more elegant font */
    margin: 0;
    background-image: url('https://images.unsplash.com/photo-1497290756760-23f55ba9af86?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1964&q=80');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.8;
}

.main-container {
    display: flex;
    max-width: 1600px;
    margin: 20px auto;
    gap: 20px;
    padding: 20px;
}

.left-panel, .right-panel {
    padding: 30px;
    animation: fadeInUp 0.8s ease-out forwards;
}

.left-panel {
    flex: 3;
    overflow-y: auto;
    height: calc(100vh - 80px);
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: relative; /* For positioning the textbook info */
}

/* Custom Scrollbar for Left Panel */
.left-panel::-webkit-scrollbar {
    width: 8px;
}
.left-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}
.left-panel::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}
.left-panel::-webkit-scrollbar-thumb:hover {
    background-color: #2980b9; /* A slightly darker shade for hover */
}

.right-panel {
    flex: 1;
    height: fit-content;
    animation-delay: 0.2s; /* Stagger animation */
}

.textbook-info {
    position: absolute;
    top: 25px;
    left: 30px;
    background: var(--primary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 500;
}

h1, h2 {
    color: var(--primary-color);
    text-align: center;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.article-section {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 10px;
    background-color: rgba(236, 245, 239, 0.5); /* Faint, semi-transparent green */
    border: 1px solid rgba(0,0,0,0.05);
}

.article-content p {
    text-indent: 2em;
    font-size: 1.1em;
}

.section-title {
    font-size: 1.5em; /* Reduced font size */
    font-weight: bold;
    color: #2c3e50; /* Darker, more elegant color */
    text-align: center;
    margin: 20px 0 20px;
}

.interactive-sentence {
    color: #16a085; /* A different shade of green */
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.3s ease;
}

.interactive-sentence:hover {
    color: var(--secondary-color);
}

.control-section {
    margin-bottom: 20px;
    padding: 20px;
    border-radius: var(--border-radius);
    background: rgba(227, 236, 245, 0.7); /* Faint, semi-transparent blue */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-section h4 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
    border-left: 4px solid var(--secondary-color);
    padding-left: 10px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.gradient-btn {
    background-image: linear-gradient(to right, #2ecc71 0%, #3498db 51%, #2ecc71 100%);
    margin: 5px 0;
    padding: 12px 20px;
    text-align: center;
    text-transform: uppercase;
    transition: background-position 0.5s, transform 0.15s ease; /* Added transform transition */
    background-size: 200% auto;
    color: white;
    border-radius: 10px;
    display: block;
    border: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
}

.gradient-btn:hover {
    background-position: right center;
    color: #fff;
    text-decoration: none;
}

.gradient-btn:active { /* Added active state for click feedback */
    transform: scale(0.96);
}

.gradient-btn:disabled {
    background-image: linear-gradient(to right, #95a5a6 0%, #bdc3c7 51%, #95a5a6 100%);
    cursor: not-allowed;
}

/* Loading Spinner Style */
.loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 12px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 0; /* Removed padding */
    border: none; /* Removed border for a cleaner look */
    width: 80%;
    max-width: 700px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    position: relative;
    animation: modal-pop-in 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Using new animation */
    overflow: hidden; /* Ensures content respects border-radius */
}

#modal-video, #generated-image {
    width: 100%;
    height: auto;
    max-height: 80vh;
    display: block; /* Removes bottom space under image/video */
}

#analysis-content {
    padding: 30px;
    font-size: 1.1em;
}

.ai-creation-description {
    font-size: 0.9em;
    color: #555;
    padding: 0 0 15px 0;
    line-height: 1.6;
}

/* New, smoother modal animation */
@keyframes modal-pop-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close-btn {
    color: white;
    background-color: rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.3s ease;
    z-index: 10; /* Ensure it's above video/image */
}

.modal-close-btn:hover, .modal-close-btn:focus {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
}

#ai-prompt {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    margin-bottom: 10px;
    resize: vertical;
}

.info-grid {
    display: flex;
    gap: 20px;
}
.info-grid .info-item {
    flex: 1;
}
.info-grid h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
    border-left: 4px solid var(--secondary-color);
    padding-left: 10px;
    color: var(--primary-color);
}
.info-grid p {
    font-size: 0.95em;
    line-height: 1.7;
    text-align: justify;
    margin: 0;
}

/* --- Enhanced Chat Modal Styles --- */
.chat-modal-content {
    max-width: 500px;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 650px;
    background-color: #f4f7f9;
}

.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    flex-shrink: 0;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
}

.chat-window {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    display: flex;
    align-items: flex-end;
    max-width: 85%;
}

.chat-message .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

.chat-message .bubble {
    padding: 12px 18px;
    border-radius: 20px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
}
.chat-message.user .bubble {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 5px;
}

.chat-message.ai {
    align-self: flex-start;
}
.chat-message.ai .bubble {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #eee;
    border-bottom-left-radius: 5px;
}

.suggested-questions {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    flex-shrink: 0;
}

.suggestion-btn {
    background-color: #e0f7fa;
    color: #00796b;
    border: 1px solid #b2dfdb;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s;
}

.suggestion-btn:hover {
    background-color: #b2dfdb;
    transform: translateY(-2px);
}

.chat-input-area {
    padding: 15px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    flex-shrink: 0;
}

.mic-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    background-image: linear-gradient(to right, #2ecc71 0%, #3498db 51%, #2ecc71 100%);
    background-size: 200% auto;
    color: white;
    font-size: 2.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.mic-btn:hover {
    background-position: right center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.mic-btn.listening {
    animation: pulse 1.5s infinite;
    background: #e74c3c;
}

#mic-status {
    margin: 0;
    color: #666;
    font-size: 0.9em;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}
/* --- End of Chat Modal Styles --- */

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    .left-panel, .right-panel {
        flex: 1;
        height: auto;
    }
    .left-panel {
        max-height: 60vh;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 14px;
    }
    .left-panel, .right-panel {
        padding: 20px;
    }
    h1 {
        font-size: 1.8em;
        margin-top: 30px; /* Pushes title down on mobile to avoid overlap */
    }
    .textbook-info {
        top: 15px;
        left: 20px;
    }
}
