@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap');

:root {
    --app-header-height: 72px;
    --search-shell-height: 100px;
    --page-gutter: 20px;
    --surface-border: #d9d9d9;
    --surface-bg: #ffffff;
    --page-bg: #f5f5f5;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Crimson Text', Georgia, serif;
    line-height: 1.6;
    color: #333;
    background: var(--page-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    min-height: var(--app-header-height);
    box-sizing: border-box;
    background: var(--surface-bg);
    border-bottom: 1px solid var(--surface-border);
    position: sticky;
    top: 0;
    z-index: 300;
    flex-shrink: 0;
}

.brand-block {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.brand-version {
    color: #888;
    font-size: 0.9rem;
}

.login-prompt {
    min-height: calc(100vh - var(--app-header-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-prompt-inner {
    width: min(560px, 100%);
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

.login-prompt-inner h1 {
    margin: 0 0 0.75rem;
    font-size: 2rem;
    line-height: 1.1;
}

.login-prompt-inner p {
    margin: 0;
    color: #666;
}

.auth-buttons {
    margin-top: 1.25rem;
}

.container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: calc(100vh - var(--app-header-height));
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

header {
    text-align: initial;
    margin-bottom: 0;
}

main {
    display: block;
    min-height: 0;
}

.content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for Firefox */
}

.content-container ::selection {
    background-color: #fdf6e3;
    color: inherit;
    padding: 2px 1px;
}

.annotation-container {
    padding: 2rem;
    background: #fff;
    border-radius: 8px;
    position: sticky;
    top: 2rem;
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    font-family: 'Source Sans Pro', sans-serif;
}

#annotation-text {
    font-size: 1.1rem;
    transition: margin-top 0.3s ease;
    line-height: 1.5;
}

.empty-state {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: #666;
}

.empty-state-title {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.empty-state-copy {
    font-size: 1rem;
}

button {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #34495e;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2c3e50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.search-container {
    position: relative;
    display: block;
    max-width: 600px;
    margin: 0 auto;
    z-index: 250;
}

.panel-heading {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.panel-title {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.panel-subtitle {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.9rem;
    color: #666;
}

.search-input {
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    background-color: white;
    margin: 1rem 0;
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.search-result {
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-result:hover {
    background-color: #f5f5f5;
}

.search-result-error {
    cursor: default;
    color: #b3261e;
    white-space: pre-wrap;
}

.result-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.result-snippet {
    font-size: 0.9em;
    color: #666;
}

.followup-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    display: none;  /* Hidden by default, shown when there's an annotation */
    max-width: 80%;  /* Make container narrower */
    margin-left: auto;  /* Center it */
    margin-right: auto;
}

.followup-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Source Sans Pro', sans-serif;
}

.followup-input:focus {
    outline: none;
    border-color: #2c3e50;
} 

.chat-entry {
    margin-bottom: 1.5rem;
}

.chat-question {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.chat-response {
    border-left: 2px solid #2c3e50;
    padding-left: 1rem;
}

.chat-entry:first-child .chat-question {
    display: none;
} 

.content-container iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
}

#content-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.login-container {
    width: 100%;
    min-height: 100vh;
    padding: 40px 20px;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: white;
    box-sizing: border-box;  /* Prevent overflow */
}

.login-container h1 {
    font-size: 120px;  /* Much larger title */
    margin-bottom: 60px;
    text-align: center;
}

.form-group {
    margin-bottom: 30px;
    width: 100%;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    font-size: 200px;  /* MUCH bigger labels */
    margin-bottom: 15px;
    color: #333;
}

.form-group input {
    width: 100%;
    height: 80px;
    padding: 0 25px;
    font-size: 72px;  /* Much bigger input text */
    border: 2px solid #ddd;
    border-radius: 12px;
    background: white;
    box-sizing: border-box;
}

button[type="submit"] {
    width: 100%;
    height: 100px;
    margin-top: 40px;
    font-size: 72px;  /* Much bigger button text */
    font-weight: bold;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 12px;
    box-sizing: border-box;
}

.error-message {
    padding: 20px;
    margin: 20px;
    background: #fff3f3;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
}

.error-message h3 {
    color: #d32f2f;
    margin-top: 0;
}

.error-message p {
    margin: 10px 0;
    color: #666;
}

/* Desktop overrides */
@media (min-width: 1001px) {
    .login-container {
        max-width: 500px;
        margin: 100px auto;
        min-height: 0;
        padding: 40px;
        border-radius: 12px;
    }

    .login-container h1 {
        font-size: 36px;
        margin-bottom: 40px;
    }

    .form-group input {
        height: 50px;
        font-size: 18px;
    }

    button[type="submit"] {
        height: 50px;
        font-size: 18px;
    }
}

/* Desktop layout (above 1000px) */
@media (min-width: 1001px) {
    .container {
        display: grid;
        grid-template-columns: 320px minmax(0, 1fr) 340px;
        gap: var(--page-gutter);
        padding: var(--page-gutter);
        align-items: stretch;
    }

    .search-container {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        max-width: none;
        margin: 0;
        display: flex;
        flex-direction: column;
        background: var(--surface-bg);
        border: 1px solid var(--surface-border);
        border-radius: 8px;
        overflow: hidden;
        min-height: 0;
    }

    .search-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.9rem;
        min-height: auto;
        margin: 0;
        padding: 20px 20px 16px;
        box-sizing: border-box;
        border-bottom: 1px solid var(--surface-border);
    }

    .search-input {
        width: 100%;
        margin: 0;
        padding: 0 15px;
        border-radius: 8px;
        border: 2px solid #ddd;
        font-size: 18px;
        min-height: 52px;
        box-sizing: border-box;
        background: #fff;
    }

    .search-input:focus {
        outline: none;
        border-color: #2c3e50;
    }

    /* Search results overlay */
    #search-results {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: auto;
        background: var(--surface-bg);
        border: 0;
        border-radius: 0;
        max-height: none;
        overflow-y: auto;
        z-index: 1;
        flex: 1;
        min-height: 0;
        display: block;
    }

    .content-area {
        grid-column: 2 / span 2;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 340px;
        gap: 20px;
        min-height: 0;
        width: auto;
        max-width: none;
        margin: 0;
        padding-top: 0;
        box-sizing: border-box;
    }

    .content-container {
        grid-column: 1;
        min-width: 0;
        min-height: 0;
        background: var(--surface-bg);
        border: 1px solid var(--surface-border);
        border-radius: 8px;
        overflow: hidden;
    }

    .annotation-container {
        grid-column: 2;
        min-height: 0;
        overflow-y: auto;
        padding: 20px;
        background: var(--surface-bg);
        border: 1px solid var(--surface-border);
        border-radius: 8px;
        position: relative;
        top: auto;
        max-height: none;
    }

    .content-area.search-hidden {
        padding-top: 0;
    }

    .search-toggle {
        display: none !important;
    }
}

/* Mobile layout (1000px and below) */
@media (max-width: 1000px) {
    :root {
        --app-header-height: 68px;
        --search-shell-height: 100px;
        --page-gutter: 16px;
    }

    body {
        margin: 0;
        padding: 0;
        height: 100vh;
        overflow: hidden;
        font-size: 16px;  /* Base font size for mobile */
    }

    /* Mobile login form */
    .login-container {
        max-width: none;
        margin: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 20px;
        box-shadow: none;
        border-radius: 0;
        font-size: 18px;
    }

    .login-container h1 {
        font-size: 32px;
        margin-bottom: 40px;
        text-align: center;
    }

    .form-group input {
        padding: 20px;
        font-size: 20px;
        min-height: 60px;
        border-radius: 8px;
        margin-bottom: 20px;
    }

    button[type="submit"] {
        width: 100%;
        padding: 20px;
        font-size: 20px;
        min-height: 60px;
        border-radius: 8px;
        margin-top: 20px;
        background-color: #2c3e50;
        color: white;
        font-weight: bold;
    }

    .error-message {
        font-size: 18px;
        padding: 15px;
        margin: 20px 0;
        border-radius: 8px;
    }

    .container {
        padding: 0;
        max-width: none;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Search bar fixed at top */
    .search-container {
        position: fixed;
        top: var(--app-header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--surface-bg);
        display: flex;
        flex-direction: column;
        z-index: 250;
        transition: transform 0.3s ease;
    }

    .search-container.hidden {
        transform: translateY(-100%);
    }

    .search-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        min-height: 100px;
        padding: 20px;
        border-bottom: 1px solid #eee;
    }

    .search-input {
        width: 90%;  /* Not full width to show it's an input */
        align-self: center;
        padding: 0 15px;
        border-radius: 12px;
        border: 2px solid #ddd;
        font-size: 24px;
        min-height: 60px;
        box-sizing: border-box;
        background: #fff;
    }

    .search-input:focus {
        outline: none;
        border-color: #2c3e50;
    }

    /* Search results as full-screen overlay */
    #search-results {
        position: relative;
        flex: 1;
        overflow-y: auto;
    }

    .search-result {
        padding: 30px 20px;
        border-bottom: 1px solid #eee;
    }

    .result-title {
        font-size: 24px;
        margin-bottom: 8px;
        font-weight: bold;
    }

    .result-snippet {
        font-size: 18px;
        line-height: 1.5;
        color: #666;
    }

    /* PDF viewer takes full screen when active */
    .content-container {
        position: fixed;
        top: var(--app-header-height);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 80;
        background: var(--surface-bg);
    }

    /* Annotation popup */
    .mobile-annotation-popup {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        max-height: 60vh;
        padding: 20px;
        padding-bottom: 40px; /* Make room for watermark */
        border-radius: 20px 20px 0 0;
        z-index: 1000;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
    }

    .mobile-annotation-popup::after {
        content: 'poetnotes.com';
        position: absolute;
        bottom: 10px;
        right: 15px;
        color: #ccc;
        font-size: 14px;
        font-family: monospace;
        pointer-events: none;
    }

    .popup-header {
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        display: flex;
        align-items: center;
    }

    .popup-handle {
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: -10px auto 15px;
    }

    .popup-content {
        font-size: 18px;
        line-height: 1.4;
    }

    .popup-close {
        position: absolute;
        top: 15px;
        right: 15px;
        padding: 8px;
        background: none;
        border: none;
        font-size: 24px;
        color: #666;
    }

    /* Hide desktop elements */
    .annotation-container {
        display: none;
    }

    /* Followup input in popup */
    .followup-container {
        position: sticky;
        bottom: 0;
        padding: 10px 20px;
        background: white;
        border-top: 1px solid #eee;
    }

    .chat-question {
        font-size: 16px;
        color: #666;
        margin-bottom: 15px;
    }

    .chat-response {
        font-size: 18px;
        line-height: 1.4;
        padding-left: 20px;
    }

    .followup-input {
        font-size: 18px;
        padding: 20px;
        border-radius: 12px;
    }
}

/* Prevent text selection while scrolling */
.prevent-selection {
    user-select: none;
    -webkit-user-select: none;
}

/* PDF text layer improvements */
.textLayer {
    opacity: 1 !important;
    line-height: 1.5 !important;
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.textLayer > span {
    cursor: text;
    position: absolute !important;
    white-space: pre;
    transform-origin: 0% 0%;
    line-height: 1;
    padding: 0;
    margin: 0;
    display: inline-block;
}

/* Mobile-specific improvements */
@media (max-width: 1000px) {
    .textLayer > span {
        padding: 2px 0 !important;
        margin-bottom: 4px !important;
    }
}

/* Mobile annotation popup */
@media (max-width: 1000px) {
    .mobile-annotation-popup {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        max-height: 60vh;
        padding: 20px;
        padding-bottom: 40px; /* Make room for watermark */
        border-radius: 20px 20px 0 0;
        z-index: 1000;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
    }

    .mobile-annotation-popup.active {
        transform: translateY(0);
    }

    .popup-handle {
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: -10px auto 15px;
    }

    .popup-close {
        position: absolute;
        top: 15px;
        right: 15px;
        padding: 8px;
        background: none;
        border: none;
        font-size: 24px;
        color: #666;
    }

    /* Hide desktop annotation container on mobile */
    .annotation-container {
        display: none;
    }

    /* Make PDF view full height on mobile */
    .content-container {
        height: 100vh !important;
    }
}

/* Search toggle button */
.search-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 110;
    display: none; /* Hidden by default */
    border: none;
    padding: 0;
}

.search-toggle svg {
    width: 30px;
    height: 30px;
    stroke: #666;  /* Icon color */
    transition: stroke 0.2s;
}

.search-toggle:hover svg {
    stroke: #333;  /* Darker on hover */
}

.version-number {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #ccc;
    font-size: 14px;
    z-index: 1000;
}

/* Make version number larger on mobile */
@media (max-width: 1000px) {
    .version-number {
        font-size: 24px;
        color: #eee;
    }
}
