/* Main CSS for Historical Document Viewer */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color variables */
    --primary-bg: #f5f5f5;
    --secondary-bg: #ffffff;
    --primary-text: #333333;
    --secondary-text: #666666;
    --accent-color: #4a6da7;
    --highlight-color: rgba(255, 230, 0, 0.3);
    --document-bg: #f8f4e9; /* Slightly warm tone for document area */
    --border-color: #e0e0e0;
    --tool-bg: #f0f0f0;
    --header-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --annotation-tooltip-bg: #ffffff;
    --annotation-tooltip-border: #e0e0e0;

    /* Font variables */
    --heading-font: 'Merriweather', 'Georgia', serif;
    --body-font: 'Source Sans Pro', 'Helvetica', sans-serif;
    --mono-font: 'Courier New', monospace;

    /* Size variables */
    --header-height: 4rem;
    --footer-height: 3rem;
    --tool-panel-width: 10rem;
}

body {
    font-family: var(--body-font);
    color: var(--primary-text);
    background-color: var(--primary-bg);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--heading-font);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.25rem;
}

h3 {
    font-size: 1.1rem;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: var(--body-font);
    transition: all 0.2s ease;
}

button:hover {
    background-color: var(--accent-color);
    color: white;
}

/* Layout */
.content-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Top Navigation Bar */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 1rem;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    z-index: 10;
}

.nav-left, .nav-right {
    flex: 1;
}

.nav-center {
    flex: 2;
    text-align: center;
}

.nav-button {
    padding: 0.5rem 1rem;
}

#document-title {
    margin-bottom: 0.25rem;
}

#document-metadata {
    font-size: 0.875rem;
    color: var(--secondary-text);
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--footer-height);
    padding: 0 1rem;
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--secondary-text);
}

.footer-right {
    display: flex;
    gap: 1rem;
}

.footer-link {
    color: var(--secondary-text);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.collapsed {
    transform: translateY(calc(100% - 3rem));
}

/* Loading indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Collection browser */
.collection-browser {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-bg);
    z-index: 100;
    overflow-y: auto;
    padding: 2rem;
}

.browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.collection-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary-text);
    transition: color 0.2s ease;
}

.close-button:hover {
    color: var(--primary-text);
}

/* Search panel */
.search-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--secondary-bg);
    box-shadow: 0 -2px 10px var(--shadow-color);
    transition: transform 0.3s ease;
    z-index: 50;
    padding: 1rem;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#search-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.search-options {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* Error toast */
.error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f44336;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 80%;
}

.error-toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(30px);
    pointer-events: none;
}

.error-message {
    flex: 1;
    margin-right: 12px;
}

.error-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

/* Media queries for responsiveness */
@media (max-width: 768px) {
    .content-container {
        flex-direction: column;
    }
    
    .tool-panel {
        flex-direction: row;
        width: 100%;
        height: var(--tool-panel-width);
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .search-options {
        flex-direction: column;
        gap: 0.5rem;
    }
}