body {
    margin: 0;
    padding: 0;
    padding-top: 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Initial state and animation for the landing page container */
.initial-container.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 10rem);
    text-align: center;
    transition: margin 0.3s ease;
}

.initial-container {
    display: none;
}

.logo-text {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 2rem;
    font-family: monospace;
    font-size: 1.8rem;
    color: #333;
}

/* Search bar with custom placeholder overlay */
.search-bar-container {
    position: relative;
    width: 600px;
    max-width: 90%;
    margin: 0 auto;
    position: relative; /* ensure container is positioned for overlay */
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.search-bar {
    width: 100%;
    padding: 1rem 1.5rem;
    padding-right: 3rem; /* room for the button */
    font-size: 1.1rem;
    border: 2px solid #eee;
    border-radius: 12px;
    outline: none;
    box-sizing: border-box;
}

.search-bar:focus {
    outline: none;
}

.custom-search-placeholder.hidden {
    display: none;
}

.custom-search-placeholder {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
    font-size: 1.1rem;
    user-select: none;
}
.custom-search-placeholder a {
    color: #007bff;
    text-decoration: underline;
    pointer-events: auto;
}

.search-btn {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.search-btn img {
    width: 24px;
    height: 24px;
}

/* Canvas container for PDF display */
.canvas-container {
    display: none;
}

.canvas-container.active {
    display: block;
    margin-top: 1rem;
    opacity: 1;
    height: auto;
    transition: opacity 0.3s ease;
    width: 90%;
    max-width: 1200px;
}

/* Main PDF canvas wrapper with floating controls */
.canvas-wrapper {
    margin: 0rem auto 1rem auto; /* Center the contents horizontally */
    display: flex;
    justify-content: center; /* Center the canvas inside the wrapper */
    position: relative;
    overflow: visible;
}

#pdfCanvas {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: block;
}

.floating-download {
    position: absolute;
    width: 36px;
    height: 36px;
    background: white url('download.svg') center/20px no-repeat;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000;
    font-size: 0; /* Hide any text content */
    color: #666;
    padding: 0;
}

.floating-download:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Floating controls for PDF interactions */
.floating-island {
    position: absolute;
    display: flex;
    gap: 8px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    z-index: 1000;
}
.floating-island button {
    width: 36px;
    height: 36px;
    background: center/20px no-repeat;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0; /* hide text */
    color: #666;
    padding: 0;
}
.floating-island button:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.pdf-controls {
    display: none;
}

.pdf-controls.active {
    display: flex;
}

#to-crop {
    display: none;
}

#to-crop.active {
    display: flex;
}

.page-nav {
    display: none;
}

/* Navigation controls for PDF viewing */
.page-nav.active {
    position: fixed;
    top: 0.8rem;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
}

.page-nav button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.page-nav button:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.page-nav button img {
    width: 20px;
    height: 20px;
}

#prev img {
    transform: rotate(180deg);
}

#prev.pdf-controls,
#next.pdf-controls {
    display: none;
}

#prev.pdf-controls.active,
#next.pdf-controls.active {
    display: flex;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.page-info input {
    width: 40px;
    padding: 2px 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
    /* Remove spinners */
    -moz-appearance: textfield;
}

.page-info input:focus {
    outline: none;
}

/* Hide number input spinners across browsers */
.page-info input::-webkit-outer-spin-button,
.page-info input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#home img {
    width: 20px;
    height: 20px;
    opacity: 0.6;
}

#home:hover img {
    opacity: 0.8;
}

/* Loading indicator with spinning animation */
#loadingIndicator {
    position: fixed;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
}
#loadingIndicator img {
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#figureListContainer {
    display: none;
}

/* Figure list display container */
#figureListContainer.active {
    display: block;
    max-width: 800px;
    overflow-y: auto;
    position: relative; /* Ensure relative positioning for the button */
}

#figureListHeader {
    display: flex;
    align-items: center;
}

#figureListHeader button {
    width: 36px;
    height: 36px;
    background: center/20px no-repeat;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0; /* hide text */
    color: #666;
    padding: 0;
    background-image: url('download.svg');
}

#figureListHeader button:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

#figureList {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    margin: 1rem;
}
.figure-item {
    width: 100%;
    max-width: 600px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    text-align: center;
    background: white;
    position: relative; /* Ensure relative positioning for the button */
}

.figure-header {
    display: flex;
    justify-content: flex-end; /* Right align the button */
    align-items: center;
    padding: 0.4rem;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.figure-header button {
    width: 36px;
    height: 36px;
    background: center/20px no-repeat;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0; /* hide text */
    color: #666;
    padding: 0;
    background-image: url('download.svg');
}

.figure-header button:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

#figureList img, #figureList canvas {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    padding-top: 0.1rem;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .canvas-container {
        width: 98%;
    }
    .search-bar {
        width: 90%;
    }
}
