/* Base layout - using Tailwind utilities where possible */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.main-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 64px); /* Adjust for navbar height */
    overflow: hidden;
}

.pdf-wrapper {
    display: flex;
    flex: 1;
    height: 100%;
    flex-direction: row;
    background: #f5f5f5;
    z-index: 2;
}

.result-container {
    width: 400px;
    background: white;
    /* border-left: 2px solid #ddd; */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;

    z-index: 3;
}

/* .results-section {
    margin-top: 20px;
} */

.results-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    /* border-bottom: 2px solid #007bff; */
    padding-bottom: 8px;
    text-align: center;
}

.sidebar {
    width: 150px;
    /* background: #f8f9fa; */
    /* border-right: 2px solid #ddd; */
    overflow-y: auto;
    display: flex;
    flex-direction: column;

    z-index: 4;
}

.sidebar-header {
    padding: 15px;
    background: #e9ecef;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.page-thumbnails {
    flex: 1;
    padding: 10px;
}

.page-thumbnail {
    width: 100%;
    height: 150px;
    margin-bottom: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.2s ease;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.page-thumbnail:hover {
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.page-thumbnail.active {
    border-color: #007bff;
    background: #e3f2fd;
}

.page-thumbnail canvas {
    width: 100%;
    height: 120px;
    display: block;
    object-fit: contain;
}

.page-number {
    text-align: center;
    padding: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    /* background: #f8f9fa; */
    flex-shrink: 0;
}

.page-thumbnail.active .page-number {
    color: #007bff;
    background: #e3f2fd;
}

.pdf-container {
    /* flex: 1; */
    width: 700px;
    background: white;
    border-right: 2px solid #ddd;
    display: flex;
    flex-direction: column;
    /* overflow: hidden; */
    height: 100%; /* Use full height of parent */
    transform-origin: top left;

    z-index: 1;
}

.pdf-container.scaled {
    transform-origin: top left;
}

.pdf-header {
    /* width: 700px; */
    padding: 65px;
    /* background: #f8f9fa; */
    /* border-right: 2px solid #ddd; */
    /* border-bottom: 1px solid #ddd; */
    font-weight: 600;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    box-sizing: border-box;
    z-index: 2;
    position: absolute;
    /* left: 0; */
    bottom: 0;
}

/* Zoom controls now use DaisyUI button classes */

.pdf-viewer {
    flex: 1;
    /* overflow: auto; */
    /* padding: 20px; */
    /* display: flex; */
    justify-content: center;
    /* overflow: auto; */
}

/* #pdfCanvas {
    border: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
} */

.control-container {
    flex: 1;
    height: 100%;
    background: white;
    /* box-shadow: 2px 0px 10px rgba(0, 0, 0, 0.1); */
    z-index: 10;
    display: flex;
    flex-direction: column;
}

/* Tabs now use DaisyUI tabs component */

.query-container {
    display: flex;
    flex-direction: column;
    position: relative;
    height: calc(100% - 55px);
    margin-top: auto;
}


.favorites-container, .history-container {
    /* padding: 20px; */
    flex: 1;
    overflow-y: auto;
    height: calc(100% - 55px);
    display: flex;
    flex-direction: column;
}

.favorites-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* height: 100%; */
    /* overflow-y: auto; */
    padding: 20px;
}

.favorite-item, .history-item {
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.favorite-item:hover, .history-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
    transform: translateY(-1px);
}

.favorite-item h4, .history-item h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.favorite-item p, .history-item p {
    margin: 0 0 5px 0;
    color: #6c757d;
    font-size: 14px;
}

.favorite-item .meta, .history-item .meta {
    font-size: 12px;
    color: #adb5bd;
    margin-top: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 500;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

.history-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.query-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.query-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    flex: 1;
    margin-right: 12px;
}

.query-date {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
}

.query-response {
    margin-bottom: 8px;
}

.query-response p {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

.query-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-name {
    font-size: 12px;
    color: #6c757d;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
}

.vote {
    font-size: 14px;
}

.vote.good {
    color: #28a745;
}

.vote.bad {
    color: #dc3545;
}

.load-more-btn {
    width: auto;
    padding: 12px 20px;
    margin: 20px;
    margin-top: 0;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
}

.load-more-btn:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.load-more-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.load-more-btn.hidden {
    display: none;
}

.container {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* padding-bottom: 120px; Add space for user-feedback section */
}

#queryForm {
    display: flex;
    flex-direction: column;
    margin-top: auto;
}

/* Form layout handled by DaisyUI form-control classes */

.settings-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px;
    padding-top: 5px;
}

.settings-container #logoutBtn {
    background: transparent;
    color: #6c757d;
    border: 2px solid #6c757d;
    padding: 8px 18px;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
}

.settings-container #logoutBtn:hover {
    background: #6c757d;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.2);
}

#feedbackBtn {
    background: transparent;
    color: #007bff;
    border: 2px solid #007bff;
    padding: 8px 18px;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;

    margin-top: 20px;
    margin-left: 30px;
    margin-right: 30px;
    text-align: center;
}

#feedbackBtn:hover {
    background: #007bff;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.2);
}

/* Switch Button Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 18px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: #007bff;
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    line-height: 0px;
    flex-wrap: wrap;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
}

/* Form groups now use DaisyUI form-control classes */

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

/* Form inputs now use DaisyUI input/textarea classes */

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

/* Buttons now use DaisyUI button classes */

#submitBtn {
    width: 150px;
    margin-left: auto;
    display: block;
}

.loading {
    text-align: center;
    color: #666;
    margin: 20px 0;
    background: linear-gradient(90deg, #e3f2fd 25%, #bbdefb 50%, #e3f2fd 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    min-height: 200px;
}

.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer-wave 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes shimmer-wave {
    0% {
        left: 100%;
    }
    100% {
        left: -100%;
    }
}

.results {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #007bff;
}

.result-item {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.result-item:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.result-item.selected {
    background: #e3f2fd;
    border-color: #007bff;
    border-width: 2px;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,123,255,0.25);
}

.result-score {
    color: #007bff;
    font-weight: 600;
    font-size: 14px;
}

.result-text {
    margin-top: 8px;
    line-height: 1.5;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    margin-top: 20px;
}

.success-info {
    display: none;

    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #c3e6cb;
    margin-bottom: 20px;
}

.ai-response {
    margin-top: 10px;
    padding: 15px;
    border-radius: 6px;
    min-height: 0;
}

.bbox-highlight {
    position: absolute;
    background: rgba(255, 255, 0, 0.3);
    border: 2px solid #ff6b35;
    pointer-events: none;
    z-index: 10;
    transition: all 0.3s ease;
}

.bbox-highlight:hover {
    background: rgba(255, 107, 53, 0.4);
    border-color: #ff4500;
}

.pdf-viewer {
    position: relative;
}

.highlight-controls {
    display: none;

    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    background: white;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.highlight-controls button {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 5px;
}

.highlight-controls button:hover {
    background: #218838;
}

.highlight-controls button.clear {
    background: #dc3545;
}

.highlight-controls button.clear:hover {
    background: #c82333;
}

.coordinate-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
    color: #666;
    font-size: 10px;
    font-family: monospace;
}

.coordinate-marker {
    position: absolute;
    width: 2px;
    height: 2px;
    background: red;
    pointer-events: none;
}

.feedback-section {
    margin-top: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    /* border-left: 4px solid #28a745; */
}

.feedback-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

.feedback-section button {
    width: auto;
    padding: 10px 20px;
    background: #28a745;
    margin-top: 10px;
}

.feedback-section button:hover {
    background: #218838;
}

.feedback-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 4px;
    display: none;
}

.feedback-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.feedback-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.debug-fields {
    display: none;
}

.debug-mode .debug-fields {
    display: block !important;
}

/* .debug-mode .success-info {
    display: block !important;
} */

/* .debug-mode .feedback-section {
    display: block !important;
} */

/* .debug-mode .user-feedback {
    opacity: 0.5 !important;
} */

.vote-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* margin-top: 20px; */
    /* padding: 20px; */
    /* background: #f8f9fa; */
    /* border-radius: 6px; */
    /* border-left: 4px solid #007bff; */
}

.vote-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vote-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

.vote-wrapper h3 {
    margin: 0;
    color: #333;
}

.vote-buttons {
    display: flex;
    gap: 3px;
    /* margin-bottom: 15px; */
}

.vote-btn {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 3px 25px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
    min-width: 80px;
}

.vote-btn:hover {
    border-color: #007bff;
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.15);
}

.vote-btn.selected {
    border-color: #007bff;
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.25);
}

.vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.vote-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 4px;
    display: none;
    width: 100%;
    box-sizing: border-box;
}

.vote-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.vote-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.ai-answer {
    margin-bottom: 15px;
}

.ai-answer h4 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

.ai-answer p {
    margin: 0;
    line-height: 1.5;
    color: #34495e;
}

.ai-sources {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    /* border-left: 3px solid #007bff; */
    margin-bottom: 15px;
}

.ai-sources h4 {
    margin: 0 0 5px 0;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
}

.ai-sources p {
    margin: 0;
    color: #6c757d;
    font-size: 13px;
}

.clickable-page {
    color: #007bff;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.clickable-page:hover {
    color: #0056b3;
    text-decoration: none;
}

.user-feedback {
    margin-top: 20px;
    /* position: absolute;
    bottom: 0;
    left: 0;
    right: 0; */
    /* background: white;
    border-top: 1px solid #ddd; */
    /* padding: 20px; */
    /* z-index: 10; */
}

.auth-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    font-size: 18px;
    color: #333;
}

.auth-loading.hidden {
    display: none !important;
}

@media (max-width: 1024px) {
    body {
        height: auto;
        overflow: auto;
    }

    .main-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .pdf-wrapper {
        flex-direction: column-reverse;
        height: auto;
        min-height: calc(100vh - 64px); /* Full height minus navbar */
        flex: 1;
    }

    .pdf-header {
        width: 100%;
        order: 2; /* Show header after PDF content on mobile */
    }

    .pdf-container {
        width: 100%;
        height: auto; /* Let JavaScript set height based on scaling */
        min-height: 300px; /* Minimum height */
        order: 1; /* Show PDF content first on mobile */
        overflow: hidden !important; /* Prevent scrolling */
    }

    /* Reduce padding around PDF on mobile */
    .pdf-wrapper > div.px-6 {
        padding-left: 8px !important;
        padding-right: 8px !important;
        overflow: hidden !important;
        max-width: 100%;
        box-sizing: border-box;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Ensure canvas fits on mobile */
    #pdfCanvas {
        max-width: 100% !important;
        max-height: 100% !important;
        height: auto !important;
        width: 100% !important;
        object-fit: contain;
        display: block;
    }

    .pdf-viewer {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        overflow: hidden !important; /* Prevent scrolling on mobile */
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    .pdf-container {
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .control-container {
        width: 100%;
    }

    .query-container {
        width: 100%;
    }

    /* Reduce padding on query container for small screens */
    .query-container .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .result-container {
        width: 100%;
    }

    .sidebar {
        flex-direction: row;
        height: 300px;
        overflow-x: auto;
        width: 100%;
    }

    .sidebar .page-thumbnails {
        height: 250px;
        overflow-y: auto;
        flex-direction: row;
        width: 150px;
        display: flex;
    }

    .sidebar .page-thumbnail {
        height: 200px;
        width: 150px;
        min-width: 150px;
        margin-bottom: 0;
        overflow-y: auto;
        overflow: auto;
    }

    .page-thumbnail canvas {
        height: 150px;
        width: 150px;
        min-width: 150px;
        object-fit: none;
    }

    .query-container {
        flex-direction: column-reverse;
    }
}

/* Navbar responsive styles for small phone screens */
@media (max-width: 640px) {
    .navbar {
        flex-wrap: wrap;
        padding: 12px 8px !important;
        gap: 8px;
    }

    .navbar > div:first-child {
        margin-right: 8px !important;
    }

    .navbar > div:first-child img {
        width: 32px !important;
        height: 32px !important;
    }

    .navbar > div:nth-child(2) {
        flex: 1;
        min-width: 0;
        max-width: calc(100% - 100px);
    }

    .navbar select {
        font-size: 14px !important;
        padding: 6px 8px !important;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .navbar > div:nth-child(3) {
        display: none;
    }

    .navbar > div:last-child {
        margin-left: auto;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 10px 6px !important;
    }

    .navbar > div:first-child img {
        width: 28px !important;
        height: 28px !important;
    }

    .navbar > div:nth-child(2) {
        max-width: calc(100% - 80px);
    }

    .navbar select {
        font-size: 12px !important;
        padding: 4px 6px !important;
    }

    .navbar .btn {
        padding: 6px !important;
        min-width: 36px !important;
        height: 36px !important;
    }

    .navbar .btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Minimal padding for PDF wrapper on very small screens */
    .pdf-wrapper > div.px-6 {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    .pdf-container {
        height: auto !important;
        min-height: 300px !important;
        overflow: hidden !important;
    }

    /* Further reduce padding on very small phone screens */
    .query-container .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    #pdfCanvas {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
}