:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --chat-bg-user: #eff6ff;
    --chat-bg-ai: #f1f5f9;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 98vh;
    width: 100vw;
}

/* PDF Section */
.pdf-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background-color: #525659;
    /* PDF viewer standard dark grey */
    min-width: 300px;
}

.pdf-header {
    height: 60px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

#file-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    font-variant-numeric: tabular-nums;
}

.pdf-viewer-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #525659;
}

.pdf-viewer-container {
    flex: 1;
    overflow: auto;
    position: relative;
    width: 100%;
    height: 100%;
    /* Removed display: flex to allow canvas to expand naturally */
}

#pdf-render {
    display: block;
    margin: 20px auto;
    /* Center horizontally with margin */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    /* max-width: 95%; Removed to allow zooming */
}

#pdf-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: #94a3b8;
    position: absolute;
    /* Position absolute to center within the container */
    top: 0;
    left: 0;
}

.placeholder-content {
    text-align: center;
}

/* Chat Section */
.chat-section {
    width: 40%;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-color);
    border-left: 1px solid var(--border-color);
}

.chat-header {
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

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

.message {
    max-width: 85%;
    line-height: 1.5;
    font-size: 0.95rem;
}

.message.user {
    align-self: flex-end;
}

.message.ai,
.message.system {
    align-self: flex-start;
}

.message-content {
    padding: 10px 15px;
    border-radius: 12px;
    position: relative;
}

.message.user .message-content {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.ai .message-content {
    background-color: var(--chat-bg-ai);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.message.system .message-content {
    background-color: #fff7ed;
    color: #9a3412;
    border: 1px solid #ffedd5;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.context-toggle {
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#user-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    outline: none;
    max-height: 100px;
}

#user-input:focus {
    border-color: var(--primary-color);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    border: none;
    transition: background-color 0.2s;
}

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

.btn-send {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.icon-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    width: 400px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
}

/* Markdown Styles in Chat */
.message-content p {
    margin-bottom: 0.5em;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message-content pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
}

/* Page Input */
.page-input {
    width: 50px;
    padding: 2px 5px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    font-family: inherit;
    font-size: inherit;
    -moz-appearance: textfield;
    /* Firefox */
    appearance: textfield;
}

.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Overlay Navigation */
.nav-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    width: 80px;
    background-color: transparent;
    /* Transparent by default */
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 20;
    opacity: 0;
}

/* Show on hover */
.nav-overlay:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
    /* Subtle background on hover */
}

/* Active state for feedback */
.nav-overlay:active {
    background-color: rgba(0, 0, 0, 0.2);
}

.nav-overlay.prev {
    left: 0;
}

.nav-overlay.next {
    right: 0;
}

/* Hide overlays if no PDF loaded? Handled by JS or just let them sit there? 
   If placeholder is visible, maybe hide them? 
   They are inside .pdf-viewer-container. 
*/

/* Resizer */
.resizer {
    width: 5px;
    background-color: var(--border-color);
    cursor: col-resize;
    transition: background-color 0.2s;
    z-index: 50;
}

.resizer:hover,
.resizer.resizing {
    background-color: var(--primary-color);
}