* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --volt-purple: #502379;
    --volt-light-purple: #6b3399;
    --volt-lighter-purple: #8e4bb8;
    --volt-accent: #a855f7;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --background: #f9fafb;
    --white: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--volt-purple), var(--volt-light-purple));
    border-radius: 12px;
    color: var(--white);
    box-shadow: 0 4px 6px rgba(80, 35, 121, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

#pdf-viewer {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

.pdf-page-container {
    position: relative; /* Stacking context for canvas + text layer */
    margin-bottom: 20px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: visible;
}

.pdf-page-canvas {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

.text-layer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1; /* Above canvas */
}

.text-layer-overlay > * {
    pointer-events: auto;
}

/* PDF.js text layer for selectable text */
.textLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 1;
    line-height: 1.0;
    z-index: 2; /* Above canvas, below hitboxes */
    pointer-events: none; /* Allow mouse events to pass through */
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.textLayer span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
    pointer-events: auto; /* Enable selection on spans */
}

.textLayer ::selection {
    background: rgba(80, 35, 121, 0.3);
}

.textLayer ::-moz-selection {
    background: rgba(80, 35, 121, 0.3);
}

.paragraph {
    position: absolute;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: transparent;
    z-index: 3; /* Above text layer */
}

.paragraph:hover {
    background-color: rgba(80, 35, 121, 0.15);
}

.paragraph.selected {
    background-color: rgba(80, 35, 121, 0.25);
    outline: 2px solid var(--volt-purple);
}

/* Table of Contents Links */
.toc-link {
    position: absolute;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
}

.toc-link:hover {
    background-color: rgba(80, 35, 121, 0.15);
    text-decoration: underline;
}

.feedback-btn {
    display: none;
    position: absolute;
    right: 5px;
    top: 5px;
    background: var(--volt-purple);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(80, 35, 121, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.feedback-btn:hover {
    background: var(--volt-light-purple);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(80, 35, 121, 0.6);
}

.feedback-btn.visible {
    display: flex;
}

/* Speech bubble icon */
.feedback-btn::before {
    content: '💬';
    font-size: 1.1rem;
}

/* Overlay Styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.overlay.hidden {
    display: none;
    opacity: 0;
}

.overlay-content {
    background: var(--white);
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

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

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--background);
    color: var(--text-dark);
}

.feedback-form {
    padding: 40px;
}

.feedback-form h2 {
    color: var(--volt-purple);
    font-size: 2rem;
    margin-bottom: 30px;
    font-weight: 700;
}

.selected-paragraph {
    background: var(--background);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 4px solid var(--volt-purple);
}

.selected-paragraph h3 {
    color: var(--volt-purple);
    font-size: 1rem;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.selected-paragraph p {
    color: var(--text-dark);
    line-height: 1.8;
}

.form-section {
    margin-bottom: 30px;
}

.form-section h3 {
    color: var(--text-dark);
    font-size: 1.3rem;
    margin-bottom: 15px;
    font-weight: 600;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--volt-purple);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: var(--text-dark);
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--volt-purple);
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    gap: 12px;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 4px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--volt-purple);
}

.checkbox-label span {
    flex: 1;
    line-height: 1.6;
    color: var(--text-dark);
}

.submit-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--volt-purple), var(--volt-light-purple));
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(80, 35, 121, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(80, 35, 121, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 320px;
    max-width: 480px;
    padding: 16px 20px;
    border-radius: 10px;
    color: var(--white);
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: toastIn 0.35s ease;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-success {
    background: linear-gradient(135deg, #16a34a, #22c55e);
}

.toast-error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.toast-warning {
    background: linear-gradient(135deg, #d97706, #f59e0b);
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.toast-message {
    opacity: 0.95;
    font-size: 0.9rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--white);
    opacity: 0.7;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .feedback-form {
        padding: 30px 20px;
    }
    
    .overlay-content {
        margin: 20px;
    }
    
    .feedback-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    /* Mobile page viewer */
    #pdf-viewer {
        padding: 10px;
        padding-bottom: 80px;
    }
    
    .pdf-page-container {
        margin-bottom: 0;
        display: flex;
        justify-content: center;
        align-items: flex-start;
    }
    
    .pdf-page-canvas {
        max-width: 100%;
        height: auto !important;
        width: auto !important;
    }
    
    /* Hide header on mobile for more space */
    header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .container {
        padding: 10px;
    }
}
