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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background: url('background.jpg') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    padding: 20px;
}

/* Remove the body overlay */
body::before {
    display: none;  /* Remove the white overlay */
}

/* Login section */
#login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#signin {
    padding: 12px 24px;
    font-size: 16px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#signin:hover {
    background-color: #357abd;
}

#signin:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Content section */
#content {
    display: flex;
    gap: 40px;
    padding: 20px;
    min-height: 100vh;
}

#images-panel, #documents-panel {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 20px;
    background: transparent;
    border-radius: 8px;
    align-content: start;
    min-width: 0;
}

.thumb-container {
    width: 110px;
    height: 140px;
    margin: 0 auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    background: transparent;  /* Make container transparent */
    justify-self: center;
}

.thumb {
    width: 110px;
    height: 110px;
    object-fit: contain;
    padding: 5px;
    transition: opacity 0.3s ease;
    background: transparent;  /* Remove white background from image area */
}

.thumb[alt="Image not available"] {
    background: #f5f5f5;
    border: 1px dashed #ddd;
    padding: 20px;
}

.page-indicators {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 2;
}

.page-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.page-dot.active {
    background: white;
}

.page-count {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    z-index: 2;
}

.thumb-content {
    position: relative;
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Document thumbnails */
.doc-thumb {
    width: 110px;
    height: 140px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
    border-radius: 4px;
}

.doc-thumb > div:first-child {  /* Date */
    color: #1976d2;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.doc-thumb > div:nth-child(2) {  /* Text content */
    margin-top: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
}

.thumb-label {
    color: #000000;
    font-size: 14px;
    font-weight: bold;
    padding: 8px;
    height: 30px;
    border-bottom: 1px solid #eee;
}

/* Hover effect */
.thumb-container:hover {
    background: rgba(255, 255, 255, 0.9);  /* More opaque on hover */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

#images-grid img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

#images-grid img:hover {
    transform: scale(1.05);
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    #images-panel, #documents-panel {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    #images-panel, #documents-panel {
        grid-template-columns: repeat(1, 1fr);
    }
}

.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 80%;
}

.error-message h2 {
    color: #d32f2f;
    margin-bottom: 1rem;
}

.error-message a {
    color: #1976d2;
    text-decoration: none;
}

.error-message a:hover {
    text-decoration: underline;
}

.image-container {
    position: relative;
    margin-bottom: 20px;
}

.document-link {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: #1976d2;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.document-link:hover {
    background: white;
    text-decoration: underline;
}

.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    z-index: 1000;
}

.modal-half {
    flex: 1;  /* Make each half equal width */
    width: 50%;  /* Enforce 50% width */
    max-width: 50%;  /* Prevent overflow */
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;  /* Prevent content from pushing width */
}

.modal-image {
    max-width: 100%;  /* Ensure image fits within its container */
    max-height: calc(100vh - 100px);  /* Account for header and padding */
    object-fit: contain;  /* Maintain aspect ratio */
    margin: auto;
    width: auto;  /* Let width adjust based on height */
    height: auto;  /* Let height adjust based on width */
}

.modal-doc {
    width: 100%;
    height: 90vh;
    background: white;
    border: none;
}

.modal-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
}

.modal-nav button {
    padding: 5px 10px;
    background: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.modal-nav button:hover {
    background: #eee;
}

.modal-close {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #1976d2;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1000;
}

.modal-close:hover {
    background: #1565c0;
}

.error-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.error-modal {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.error-modal h2 {
    color: #d32f2f;
    margin-bottom: 1rem;
}

.error-modal p {
    margin: 0.5rem 0;
    color: #333;
}

.error-modal button {
    margin-top: 1.5rem;
    padding: 0.5rem 2rem;
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.error-modal button:hover {
    background: #b71c1c;
}

.initial-background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(245,245,245,0.1) 0%, rgba(224,224,224,0.1) 100%);
    z-index: -1;
}

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

#loading-percentage {
    position: fixed;
    top: calc(50% + 40px);
    left: 50%;
    transform: translateX(-50%);
    color: #3498db;
    font-family: Arial, sans-serif;
    font-size: 14px;
    z-index: 9999;
}

.thumb-placeholder {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 245, 245, 0.7);  /* Semi-transparent placeholder */
    color: #666;
    font-size: 14px;
}

.thumb-placeholder.error {
    background: rgba(255, 243, 243, 0.7);  /* Semi-transparent error state */
    color: #d32f2f;
}

.doc-thumb-date {
    color: #000000;
    font-size: 14px;
    font-weight: bold;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.doc-thumb-content {
    margin: 10px auto;
    display: block;
    width: 98px;
    height: 110px;
    border-radius: 2px;
}

.doc-thumb-content.error {
    margin-top: 8px;
    text-align: center;
    color: #d32f2f;
    font-style: italic;
}

.modal-doc-content {
    width: 100%;
    height: calc(100vh - 100px);  /* Full height minus header and padding */
    border: none;
    margin: 0;
    padding: 0;
}

.modal-doc-error {
    display: none;  /* Or remove entirely */
}

.doc-thumb-header {
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.doc-thumb-filename {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.modal-header {
    padding: 10px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    color: #1976d2;  /* Match the doc date color */
    font-size: 14px;
    font-weight: bold;
    font-family: Arial, sans-serif;  /* More readable than monospace */
}

.pdf-icon {
    width: 48px;
    height: 48px;
    fill: #1976d2;
    margin: 20px auto 10px;
    display: block;
}

.gallery-exit {
    position: fixed;  /* Fixed position instead of absolute */
    z-index: 100;    /* Lower than modal but above content */
}

/* Adjust modal-close z-index to ensure it's above gallery-exit */
.modal-container .modal-close {
    z-index: 1001;
}
