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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
}

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

header {
    background-color: #006341;
    color: white;
    text-align: center;
    padding: 15px 0;
    margin-bottom: 10px;
    border-radius: 5px;
}

.pdf-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
}

#page-info {
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 20px;
}

main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-container {
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

canvas {
    border: 1px solid #ddd;
    max-width: 100%;
    height: auto;
    transition: all 0.2s ease;
}

canvas.page-jump-highlight {
    box-shadow: 0 0 15px rgba(0, 99, 65, 0.8);
    transform: scale(1.02);
}

#page-jump-notification {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    background-color: rgba(0, 99, 65, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

#page-jump-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* App-wide notification */
#app-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 14px;
    max-width: 80%;
    text-align: center;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#app-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.text-header, .qa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.text-header h2, .qa-header h2 {
    margin-bottom: 0;
    color: #006341;
    display: flex;
    align-items: center;
}

.text-controls {
    display: flex;
    gap: 10px;
}

.toggle-btn {
    background-color: #2980b9;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    min-width: 100px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    line-height: 1.2;
}

.toggle-btn:hover {
    background-color: #1c638e;
}

.toggle-btn.active {
    background-color: #e67e22;
}

.toggle-btn.active:hover {
    background-color: #d35400;
}

.visibility-btn {
    background-color: #7f8c8d;
}

.visibility-btn:hover {
    background-color: #636e72;
}

.visibility-btn.hidden-state {
    background-color: #e74c3c;
}

.visibility-btn.hidden-state:hover {
    background-color: #c0392b;
}

.clear-btn {
    background-color: #7f8c8d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s;
    min-width: 100px;
    height: 36px;
}

.clear-btn:hover {
    background-color: #636e72;
}

#extracted-text-container {
    transition: max-height 0.5s ease, opacity 0.5s ease;
    max-height: 333px;
    opacity: 1;
    overflow: hidden;
    width: 100%;
    position: relative;
}

#extracted-text-container.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    visibility: hidden;
    position: absolute;
    pointer-events: none;
}

button {
    background-color: #006341;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 100px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    background-color: #004a31;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    min-width: 0;
}

.text-container, .qa-container {
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

#text-mode-indicator {
    font-size: 14px;
    font-weight: normal;
    color: #777;
    margin-left: 8px;
}

#extracted-text {
    line-height: 1.8;
    white-space: pre-wrap;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
}

.page-marker {
    font-weight: bold;
    color: #006341;
    background-color: #e8f5e9;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 10px 0;
    display: inline-block;
}

#chat-history {
    display: flex;
    flex-direction: column;
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #eee;
}

.chat-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 85%;
    position: relative;
}

.user-message {
    background-color: #e8f5e9;
    color: #006341;
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

.ai-message {
    background-color: #f1f1f1;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

.page-link {
    color: #e74c3c;
    font-weight: bold;
    text-decoration: none;
    background-color: #ffecec;
    padding: 0 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.page-link:hover {
    background-color: #e74c3c;
    color: white;
    text-decoration: none;
}

.qa-input {
    display: flex;
    gap: 10px;
}

#question-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    height: 36px;
}

#question-input:focus {
    outline: none;
    border-color: #006341;
}

#loading-indicator {
    color: #666;
    font-style: italic;
    margin: 10px 0;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.hidden {
    display: none;
}

.error {
    background-color: #fff8f8;
    border-left: 4px solid #e74c3c;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    color: #c0392b;
}

.info {
    background-color: #f0f9ff;
    border-left: 4px solid #3498db;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    color: #2980b9;
}

.error-actions {
    margin-top: 15px;
    display: flex;
    justify-content: center;
}

.download-button {
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    min-width: 100px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.download-button:hover {
    background-color: #219653;
}

strong {
    color: #006341;
    font-weight: bold;
}

@media (min-width: 992px) {
    main {
        flex-direction: row;
        gap: 20px;
    }
    
    .left-panel, .right-panel {
        flex: 1;
        min-width: 0;
        max-width: 50%;
    }
}

@media (max-width: 991px) {
    main {
        gap: 10px;
    }
    
    .left-panel, .right-panel {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 767px) {
    main {
        gap: 5px;
    }
    
    .container {
        padding: 5px;
    }
    
    .pdf-navigation-section,
    .pdf-update-section {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 5px;
        padding: 10px;
    }
    
    .pdf-container {
        padding: 10px;
    }
    
    .text-container, .qa-container {
        padding: 15px;
        margin-bottom: 5px;
    }
    
    .pdf-controls {
        justify-content: center;
    }
    
    .pdf-update-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    
    #check-update-button, 
    .pdf-status {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 auto !important;
        box-sizing: border-box;
        height: auto;
        min-height: 50px;
    }
    
    #extracted-text {
        width: 100%;
        overflow-wrap: break-word;
        word-wrap: break-word;
        hyphens: auto;
        margin-bottom: 15px;
    }
    
    .text-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .text-header h2 {
        margin-bottom: 10px;
        width: 100%;
    }
    
    .text-controls {
        flex-direction: column;
        width: 100%;
        gap: 5px;
    }
    
    .text-controls button {
        width: 100%;
        margin-bottom: 5px;
        height: auto;
        min-height: 36px;
        white-space: normal;
        padding: 8px;
    }
    
    .extracted-text-container button {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .toggle-btn, button {
        white-space: normal;
        line-height: 1.2;
    }
    
    .modal-content {
        width: 90%;
        margin: 25% auto;
        padding: 15px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 5px;
    }
    
    .modal-footer button {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* Add styles for PDF update features */

/* PDF update controls in header */
.pdf-update-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: space-between;
    width: 100%;
}

#check-update-button {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s;
    min-width: 100px;
    height: 50px;
    flex: 0 0 auto;
    width: 30%;
    box-sizing: border-box;
}

#check-update-button:hover {
    background-color: #2980b9;
}

.pdf-status {
    font-size: 0.9em;
    color: #555;
    flex: 1;
    width: 55%;
    text-align: left;
    background-color: #f9f9f9;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #eee;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.status-line {
    font-weight: bold;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.modified-line {
    font-size: 0.85em;
    color: #777;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* PDF update status indicators */
.status-updated {
    color: #27ae60;
}

.status-checking {
    color: #f39c12;
}

.status-error {
    color: #e74c3c;
}

/* Modal for PDF updates */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 60%;
    max-width: 500px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
}

.modal h2 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

#update-status-content {
    padding: 15px 0;
    min-height: 50px;
}

.modal-footer {
    margin-top: 15px;
    text-align: right;
    border-top: 1px solid #eee;
    padding-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer button {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    min-width: 100px;
    height: 36px;
}

.modal-footer button:hover {
    background-color: #2980b9;
}

.modal-footer .reload-button {
    background-color: #27ae60;
}

.modal-footer .reload-button:hover {
    background-color: #219653;
}

/* Update message styling */
.update-message {
    margin: 15px 0;
    padding: 10px 15px;
    border-left: 4px solid #f39c12;
    background-color: #fff8e1;
    font-style: italic;
    color: #664d03;
    border-radius: 0 4px 4px 0;
}

.update-success {
    margin-bottom: 10px;
}

.loading {
    display: none;
    text-align: center;
    padding: 15px;
    color: #666;
}

.loading:after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* PDF update notification */
#update-notification {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #27ae60;
    color: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 300px;
    animation: slide-in 0.5s ease-out;
}

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

.pdf-navigation-section {
    background: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pdf-update-section {
    background: white;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

#ask-button {
    min-width: 100px;
    height: 36px;
}

/* Footer Styles */
.site-footer {
    background-color: #24292e; /* GitHub dark */
    color: #ffffff;
    padding: 20px 0;
    margin-top: 20px;
    border-radius: 5px;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 20px;
    padding: 0 20px;
}

.footer-section {
    flex: 1;
    min-width: 200px;
}

.footer-section h4 {
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.footer-links {
    list-style: none;
    padding: 0;
}

.footer-links li {
    margin-bottom: 8px;
}

.footer-links a, .footer-section a {
    color: #58a6ff; /* GitHub blue for links */
    text-decoration: none;
    transition: opacity 0.3s;
}

.footer-links a:hover, .footer-section a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.footer-bottom {
    text-align: center;
    padding-top: 15px;
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.9em;
}

.footer-bottom a {
    color: #58a6ff; /* GitHub blue for links */
    text-decoration: none;
}

@media (max-width: 767px) {
    .footer-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .footer-section {
        min-width: 100%;
    }
    
    .site-footer {
        padding: 15px 0;
        margin-top: 10px;
    }
} 