body {
    --primary: #3b82f6;
    --primary-dark: #1d4ed8;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: rgba(255, 255, 255, 0.92);
    --border: rgba(148, 163, 184, 0.35);
    --text: #1f2937;
    --text-muted: #64748b;
    height: 100vh;
    --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.18);
    box-sizing: border-box;
    --radius-lg: 18px;
    overflow-y: hidden;
    --sidebar-shift: 420px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at 0% 0%, #e0e7ff 0%, #f8fafc 45%, #ffffff 100%);
    color: var(--text);
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    position: relative;
    padding: 0;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(1200px circle at 85% 10%, rgba(59, 130, 246, 0.09), transparent 60%),
        radial-gradient(900px circle at 10% 75%, rgba(14, 165, 233, 0.08), transparent 55%);
    pointer-events: none;
    z-index: -1;
}

body.sidebar-open {
    --sidebar-shift: 420px;
}

body.player-active #mainContent {
    justify-content: flex-start;
    align-items: stretch;
}

#mainContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 100vw;
}

body.sidebar-open #mainContent {
    max-width: calc(100vw - var(--sidebar-shift));
}

#pdfDropArea {
    display: flex;
    width: min(100%, 820px);
    min-height: 500px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px dashed rgba(148, 163, 184, 0.6);
    border-radius: var(--radius-lg);
    margin: auto;
    cursor: pointer;
    background: var(--surface);
    color: var(--text-muted);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
    padding: 48px 30px;
    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

body.player-active #pdfDropArea {
    display: none;
}

#pdfDropArea.dragover {
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 28px 55px rgba(37, 99, 235, 0.18);
    transform: translateY(-4px);
}

#pdfDropArea p {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

#pdfViewerContainer {
    display: none;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
}

#pdfNativeViewerContainer {
    width: 100%;
    height: 100%;
    background: white;
    overflow: hidden;
    padding: 0;
}

#pdfNativeViewer {
    border: none;
    width: 100%;
    height: 100%;
}

/* AI Chat Sidebar */
#aiChatSidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.92) 100%);
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.15);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(148, 163, 184, 0.2);
}

#aiChatSidebar.open {
    transform: translateX(0);
}

#sidebarCloseBtn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: var(--text);
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
}

#sidebarCloseBtn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    transform: scale(1.05);
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

.sidebar-icon-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text);
}

.sidebar-icon-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

#sidebarChatHistory {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-message,
.ai-message {
    padding: 14px 16px;
    border-radius: 12px;
    animation: messageSlideIn 0.3s ease;
}

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

.user-message {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(14, 165, 233, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.2);
    align-self: flex-end;
    max-width: 85%;
}

.ai-message {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    align-self: flex-start;
    max-width: 95%;
}

.ai-message a {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 500;
}

.ai-message a:hover {
    color: var(--primary-dark);
}

#quickPromptButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.quick-prompt-btn {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    transition: all 0.2s ease;
}

.quick-prompt-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.sidebar-input-area {
    padding: 16px 20px 20px;
}

.sidebar-context {
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.context-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

#sidebarSentenceContext {
    width: 100%;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    line-height: 1.5;
}

#sidebarSentenceContext:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.sidebar-send-row {
    display: flex;
    gap: 8px;
}

#sidebarQuestionInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
}

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

#sidebarSendQuestionBtn {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

#sidebarSendQuestionBtn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Correction Modal */
.correction-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.correction-modal.open {
    opacity: 1;
    pointer-events: all;
}

.correction-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.correction-modal__dialog {
    position: relative;
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.correction-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(148, 163, 184, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: var(--text);
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
}

.correction-modal__close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.correction-modal h4 {
    margin: 0 0 8px;
    font-size: 24px;
    color: var(--text);
}

.correction-modal__hint {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.correction-modal__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.correction-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.correction-modal__field span {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.correction-modal__field input,
.correction-modal__field textarea {
    padding: 10px 14px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.correction-modal__field input:focus,
.correction-modal__field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.correction-modal__actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn--primary {
    background: var(--primary);
    color: white;
}

.modal-btn--primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.modal-btn--secondary {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.modal-btn--secondary:hover {
    background: rgba(148, 163, 184, 0.25);
}

.correction-modal__feedback {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    min-height: 20px;
}

.correction-modal__feedback--error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}
