:root {
    --primary: #eaaa43;
    --secondary: #21364b;
    --tertiary: #1b465c;
    --accent: #3594aa;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
}

body {
    font-family: 'Lato', sans-serif;
    background: linear-gradient(135deg, #eaaa4333 0%, #ffffff 100%);
    color: var(--secondary);
    line-height: 1.7;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    padding: 2rem;
}

/* Full width container for OCR tab */
#ocr-tab .container {
    max-width: none;
    padding: 0;
}

@keyframes fluid {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes wave {
    0% {
        transform: translateX(-25%) translateY(0);
    }
    50% {
        transform: translateX(25%) translateY(0);
    }
    100% {
        transform: translateX(-25%) translateY(0);
    }
}

header {
    background: linear-gradient(
        45deg,
        #eaaa43,
        #21364b,
        #1b465c,
        #3594aa,
        #eaaa43,
        #21364b,
        #1b465c,
        #3594aa
    );
    background-size: 400% 400%;
    padding: 2rem 0;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
    animation: fluid 15s ease infinite;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(234, 170, 67, 0.5),
        rgba(33, 54, 75, 0.5),
        rgba(27, 70, 92, 0.5),
        rgba(53, 148, 170, 0.5)
    );
    background-size: 200% 200%;
    animation: wave 8s ease-in-out infinite;
    mix-blend-mode: overlay;
}

header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        circle at center,
        rgba(234, 170, 67, 0.3) 0%,
        rgba(33, 54, 75, 0.3) 25%,
        rgba(27, 70, 92, 0.3) 50%,
        rgba(53, 148, 170, 0.3) 75%
    );
    animation: fluid 12s ease-in-out infinite;
    mix-blend-mode: soft-light;
}

header .container {
    position: relative;
    z-index: 2;
}

header h1 {
    font-family: 'Merriweather', serif;
    color: white;
    font-weight: 700;
    font-size: 2.8rem;
    text-align: center;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: color 0.5s ease;
}

.nav-tabs {
    border-bottom: 2px solid var(--tertiary);
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.nav-tabs .nav-item {
    flex: 1;
    min-width: 0;
}

.nav-tabs .nav-link {
    color: var(--secondary);
    font-weight: 600;
    border: none;
    padding: 1rem 0.75rem;
    margin-bottom: -2px;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.nav-tabs .nav-link:hover {
    border: none;
    color: var(--primary);
    background-color: rgba(234, 170, 67, 0.1);
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: none;
    border: none;
    border-bottom: 2px solid var(--primary);
}

/* Responsive tab adjustments */
@media (max-width: 768px) {
    .nav-tabs .nav-link {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .nav-tabs {
        margin-bottom: 1.5rem;
    }
    
    .nav-tabs .nav-link {
        padding: 0.6rem 0.25rem;
        font-size: 0.85rem;
        line-height: 1.2;
    }
}

@media (max-width: 480px) {
    .nav-tabs .nav-link {
        padding: 0.5rem 0.15rem;
        font-size: 0.8rem;
    }
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.main-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2.5rem;
    align-items: flex-start;
}

.filters {
    background: linear-gradient(180deg, #ffffff 0%, #eaaa4315 100%);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(234, 170, 67, 0.15);
    position: sticky;
    top: 2rem;
    border: 1px solid rgba(234, 170, 67, 0.2);
}

.filter-group {
    margin-bottom: 1.75rem;
}

.filter-group.inline {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--tertiary);
    font-size: 1rem;
}

.filter-group input[type="number"],
.filter-group select,
.filter-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filter-group input[type="number"]:focus,
.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(234, 170, 67, 0.25);
}

/* Search input specific styling */
#search-input {
    position: relative;
}

#search-input::placeholder {
    color: #6c757d;
    font-style: italic;
}

.filter-buttons {
    margin: 0.5rem -0.25rem;
}

.filter-buttons .filter-btn {
    padding: 0.25rem 0.6rem;
    margin: 0.15rem;
    border: 1px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 15px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-buttons .filter-btn:hover {
    background: rgba(234, 170, 67, 0.1);
}

.filter-buttons .filter-btn.selected {
    background: var(--primary);
    color: white;
}

.filter-buttons .filter-btn.selected:hover {
    background: #d99b39;
}

.action-button {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--primary);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    letter-spacing: 0.5px;
    margin-top: 10px;
}

.action-button:hover {
    background-color: #d99b39;
    transform: translateY(-1px);
}

.action-button:active {
    transform: translateY(0);
}

.results-area {
    background: linear-gradient(180deg, #ffffff 0%, #eaaa4308 100%);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(234, 170, 67, 0.1);
    min-height: 300px;
    border: 1px solid rgba(234, 170, 67, 0.15);
}

/* Selection layout - side by side */
.selection-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Question selection styling */
.question-selector {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.question-checkbox {
    margin-top: 0.3rem;
    cursor: pointer;
}

.drag-handle {
    color: #6c757d;
    cursor: grab;
    font-size: 1.2rem;
    margin-top: 0.2rem;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.question-content {
    flex: 1;
    cursor: pointer;
}

.question-item.selected {
    background-color: rgba(234, 170, 67, 0.1);
    border-left: 3px solid var(--primary);
    padding-left: 0.75rem;
}

/* Selected questions panel */
.selected-panel {
    background: white;
    border: 1px solid rgba(234, 170, 67, 0.2);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(234, 170, 67, 0.1);
}

.selected-panel h3 {
    color: var(--secondary);
    font-family: 'Merriweather', serif;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.selection-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.selection-controls .btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
}

.selected-questions-list {
    min-height: 200px;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    transition: all 0.3s ease;
}

.selected-questions-list.drag-over {
    border-color: var(--primary);
    background-color: rgba(234, 170, 67, 0.05);
}

.selected-questions-list.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-style: italic;
}

.selected-question-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: move;
    transition: all 0.2s ease;
}

.selected-question-item:hover {
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
}

.selected-question-item.sortable-ghost {
    opacity: 0.5;
    background-color: rgba(234, 170, 67, 0.1);
}

.selected-question-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.selected-question-number {
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

.remove-question {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0.2rem;
}

.remove-question:hover {
    color: #bb2d3b;
}

.question-count {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 1rem;
}

.results-header h2 {
    font-family: 'Merriweather', serif;
    color: var(--secondary);
    margin: 0;
}

.results-header .action-buttons-group {
     display: flex;
     gap: 0.5rem;
     flex-wrap: wrap;
}

.results-header .action-button {
    background-color: var(--accent);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: auto;
    white-space: nowrap;
}

.results-header .action-button:hover {
    background-color: #2d7c8f;
    transform: translateY(-1px);
}

/* Print dropdown styling */
.dropdown-toggle {
    background-color: var(--accent);
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    width: auto;
    border: none;
    border-radius: 0.375rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-toggle:hover {
    background-color: #2d7c8f;
    transform: translateY(-1px);
}

.dropdown-toggle:focus {
    background-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(234, 170, 67, 0.25);
}

.dropdown-menu {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 1000;
}

.dropdown-item {
    padding: 0.6rem 1rem;
    color: #333;
    text-decoration: none;
    display: block;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background-color: rgba(234, 170, 67, 0.1);
    color: var(--primary);
}

.dropdown-item:active {
    background-color: rgba(234, 170, 67, 0.2);
}

.dropdown-item.disabled {
    color: #6c757d;
    pointer-events: none;
    opacity: 0.5;
}

/* Responsive dropdown adjustments */
@media (max-width: 768px) {
    .dropdown-menu {
        min-width: 180px;
        font-size: 0.85rem;
    }
    
    .dropdown-item {
        padding: 0.5rem 0.75rem;
    }
}

#questions-container-gen, #answers-container-gen {
    padding-top: 1rem;
}

.question-item {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.question-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.question-header {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* Show full header on screen, hide compact header */
.print-header {
    display: none;
}
.screen-header {
    display: inline;
}

/* Show full answers on screen */
.screen-answer {
    display: block;
}

.question-text {
    white-space: normal;
    font-size: 1.05rem;
}

/* Image styling */
.image-container {
    margin: 15px 0;
}

.question-image {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    display: block;
    margin: 10px auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background-color: white;
}

.image-error {
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    margin: 15px 0;
}

.image-error ul {
    text-align: left;
    display: inline-block;
    margin: 10px 0;
}        .question-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
    border: 1px solid rgba(234, 170, 67, 0.2);
}

.question-text th, .question-text td {
    border: 1px solid rgba(234, 170, 67, 0.2);
    padding: 0.6rem;
    text-align: left;
}

.question-text th {
    background-color: rgba(234, 170, 67, 0.1);
    font-weight: 700;
    color: var(--primary);
}

.message {
    color: var(--secondary-color);
    text-align: center;
    padding: 3rem 1rem;
    font-size: 1.1rem;
    font-style: italic;
}

#answers-section-gen {
    margin-top: 4rem;
}

.chart-container {
    margin-bottom: 3rem;
}

.chart-title {
    font-family: 'Merriweather', serif;
    font-size: 1.5rem;
    color: var(--heading-color);
    margin-bottom: 1.5rem;
}

.bar-item {
    margin-bottom: 1rem;
}

.bar-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.bar-wrapper {
    display: flex;
    align-items: center;
    height: 25px;
}

.bar {
    height: 100%;
    background-color: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease-in-out;
}

.bar-info {
    padding-left: 8px;
    font-size: 0.9rem;
    white-space: nowrap;
    color: var(--text-color);
}

@media (max-width: 992px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .filters {
        position: static;
        margin-bottom: 2rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }
    header h1 {
        font-size: 2.2rem;
    }
    .container {
        padding: 1rem;
    }
    .filters, .results-area {
        padding: 1.5rem;
    }
    .results-header {
        flex-direction: column;
        text-align: center;
    }
}
@media print {
    body {
        font-size: 11pt !important;
        line-height: 1.3 !important;
        color: #000;
        background-color: #fff;
        margin: 0 !important;
        padding: 0 !important;
    }
    .filters, header, .results-header .action-buttons-group, .action-button, .tabs, .nav-tabs {
        display: none !important;
    }
    .main-layout {
        display: block !important;
        grid-template-columns: none !important;
    }
    .container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0.25in !important;
    }
    .results-area {
        background: none !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
    }
    
    /* Compact question items */
    .question-item {
        page-break-inside: avoid;
        border-bottom: 1px solid #ddd;
        margin-bottom: 0.4rem !important;
        padding-bottom: 0.2rem !important;
    }
    
    /* Condensed question headers - just Q1, Q2, etc. */
    .question-header {
        font-size: 0.9rem !important;
        font-weight: bold !important;
        margin-bottom: 0.05rem !important;
        color: #333 !important;
    }
    
    /* Show only compact headers when printing */
    .screen-header {
        display: none !important;
    }
    .print-header {
        display: inline !important;
    }
    
    /* Hide screen answers, show compact answers */
    .screen-answer {
        display: none !important;
    }
    
    /* Format compact answers in print */
    #answers-container-gen .question-header .print-header {
        display: block !important;
        font-size: 0.85rem !important;
        margin-bottom: 0.1rem !important;
    }
    
    #answers-container-gen .question-text {
        display: none !important;
    }
    
    /* Smaller question text */
    .question-text {
        font-size: 0.85rem !important;
        line-height: 1.2 !important;
        margin: 0 !important;
    }
    
    /* Original size images with minimal margin */
    .question-image {
        max-width: 100% !important;
        max-height: none !important;
        border: 1px solid #ccc !important;
        padding: 2px !important;
        margin: 0.05rem auto !important;
        box-shadow: none !important;
        display: block !important;
    }
    
    /* Hide image error messages */
    .image-error {
        display: none !important;
    }
    
    /* Minimal image container margins */
    .image-container {
        margin: 0.05rem 0 !important;
    }
    
    /* Compact tables */
    .question-text table {
        font-size: 0.75rem !important;
        margin: 0.2rem 0 !important;
    }
    
    .question-text th, .question-text td {
        padding: 0.15rem !important;
    }
    
    /* Hide results header and selection interface when printing */
    .results-header {
        display: none !important;
    }
    
    #selection-interface {
        display: none !important;
    }
    
    /* Answers on same page, not new page */
    #answers-section-gen {
        page-break-before: auto !important;
        margin-top: 0.8rem !important;
    }
    
    /* Print control classes */
    .print-questions-only #answers-section-gen {
        display: none !important;
    }
    
    .print-answers-only #questions-container-gen {
        display: none !important;
    }
    
    .print-answers-only #printable-title-gen {
        display: none !important;
    }
    
    .print-answers-only #answers-section-gen {
        page-break-before: auto !important;
    }
    
    .print-answers-only #answers-section-gen .results-header h2 {
        margin-top: 0 !important;
    }
    
    /* Compact answer layout - vertical columns */
    .print-answers-only #answers-container-gen {
        column-count: 2;
        column-gap: 0.4rem;
        column-rule: 1px solid #ddd;
    }
    
    .print-answers-only .question-item {
        break-inside: avoid;
        margin-bottom: 0.25rem !important;
        padding-bottom: 0.15rem !important;
    }
    
    /* Multi-column layout for answers when printing both */
    body:not(.print-questions-only):not(.print-answers-only) #answers-container-gen {
        column-count: 2;
        column-gap: 0.4rem;
        column-rule: 1px solid #ddd;
    }
    
    body:not(.print-questions-only):not(.print-answers-only) #answers-container-gen .question-item {
        break-inside: avoid;
        margin-bottom: 0.25rem !important;
        padding-bottom: 0.15rem !important;
    }
    
    .chart-container {
        page-break-inside: avoid;
    }
}

/* OCR Tab Styles - Bootstrap 5 Optimized */
.ocr-full-layout {
    padding: 2rem 1.5rem;
    max-width: none;
    width: 100%;
    min-height: 100vh;
}

.ocr-gradio-container {
    width: 100%;
    height: 80vh;
    min-height: 600px;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: auto;
    background-color: white;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

gradio-app {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: none;
}

/* Hide specific Gradio component that shows up initially */
#component-1 > div.html-container.svelte-phx28p.padding,
gradio-app #component-1 > div.html-container.svelte-phx28p.padding,
.ocr-gradio-container #component-1 > div.html-container.svelte-phx28p.padding {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Alternative selector in case the component structure changes */
gradio-app div.html-container.svelte-phx28p.padding:first-child,
.ocr-gradio-container div.html-container.svelte-phx28p.padding:first-child {
    display: none !important;
}

.ocr-instructions {
    background-color: rgba(234, 170, 67, 0.05);
    border-left: 4px solid var(--primary);
    border-radius: 0.375rem;
}

.ocr-instructions h5 {
    color: var(--secondary);
    font-family: 'Merriweather', serif;
    margin-bottom: 0.75rem;
}

.ocr-instructions ul {
    margin-bottom: 0;
    color: #6c757d;
}

/* Override main layout for OCR tab */
#ocr-tab .main-layout {
    display: block;
    grid-template-columns: none;
}

/* Bootstrap 5 responsive breakpoints for OCR tab */
@media (max-width: 1200px) {
    .ocr-full-layout {
        padding: 1.5rem 1rem;
    }
    
    .ocr-gradio-container {
        height: 75vh;
        min-height: 550px;
    }
}

@media (max-width: 992px) {
    .ocr-full-layout {
        padding: 1rem 0.75rem;
    }
    
    .ocr-gradio-container {
        height: 70vh;
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .ocr-full-layout {
        padding: 0.75rem 0.5rem;
        min-height: calc(100vh - 120px);
    }
    
    .ocr-gradio-container {
        height: 65vh;
        min-height: 450px;
        border-radius: 0.25rem;
    }
    
    .ocr-instructions {
        margin-top: 0.75rem;
        padding: 0.75rem;
    }
    
    .ocr-instructions div[style*="grid-template-columns"] {
        display: block !important;
        grid-template-columns: none !important;
    }
    
    .ocr-instructions ul {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 576px) {
    .ocr-full-layout {
        padding: 0.5rem 0.25rem;
        min-height: calc(100vh - 100px);
    }
    
    .ocr-gradio-container {
        height: 60vh;
        min-height: 400px;
        border-radius: 0.2rem;
    }
    
    gradio-app {
        min-height: 400px;
    }
    
    .results-header h2 {
        font-size: 1.25rem;
    }
    
    .ocr-instructions {
        padding: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .ocr-instructions h5 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
}

/* Ensure OCR tab is displayed properly */
#ocr-tab.active {
    display: block;
}

/* PDF Tools Styles */
.pdf-full-layout {
    max-width: none;
    padding: 0 1rem;
}

.upload-zone {
    border: 3px dashed var(--primary);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(234, 170, 67, 0.05) 0%, rgba(255, 255, 255, 0.8) 100%);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-zone:hover, .upload-zone.drag-over {
    background: linear-gradient(135deg, rgba(234, 170, 67, 0.1) 0%, rgba(255, 255, 255, 0.9) 100%);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.upload-content h4 {
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.upload-content p {
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.file-list-panel {
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: var(--shadow);
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h5 {
    margin: 0;
    color: var(--secondary);
}

.file-controls {
    display: flex;
    gap: 0.25rem;
}

.file-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.file-item:hover {
    background: rgba(234, 170, 67, 0.05);
}

.file-item.selected {
    background: rgba(234, 170, 67, 0.1);
    border-color: var(--primary);
}

.file-item .file-icon {
    font-size: 1.5rem;
}

.file-item .file-info h6 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--secondary);
}

.file-item .file-info small {
    color: #6c757d;
}

.pdf-viewer-container {
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.pdf-toolbar {
    padding: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    background: #f8f9fa;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.zoom-level {
    font-weight: 600;
    color: var(--secondary);
    min-width: 50px;
    text-align: center;
}

.page-input {
    width: 60px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.25rem;
    font-size: 0.85rem;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--secondary);
    font-size: 0.9rem;
}

.pdf-viewer {
    height: 600px;
    overflow: auto;
    background: #f5f5f5;
    position: relative;
}

.viewer-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6c757d;
}

.pdf-canvas {
    display: block;
    margin: 1rem auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background: white;
    pointer-events: none;
}

#pdf-edit-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    pointer-events: auto;
    z-index: 10;
}

/* Fabric.js creates a wrapper div around the canvas */
.canvas-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: auto !important;
    z-index: 100 !important;
}

/* Fabric.js upper canvas - this is what receives mouse events */
.upper-canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    cursor: crosshair !important;
    pointer-events: auto !important;
    z-index: 101 !important;
}

.pdf-viewer > canvas:first-child,
.pdf-viewer > img:first-child {
    position: relative;
}

.tools-panel {
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.tool-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.tool-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tool-section h6 {
    color: var(--secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    color: var(--secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(234, 170, 67, 0.05);
    border-color: var(--primary);
    color: var(--primary);
}

.tool-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tool-icon {
    font-size: 1.2rem;
}

.property-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.property-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.property-item span:first-child {
    color: #6c757d;
}

.property-item span:last-child {
    color: var(--secondary);
    font-weight: 500;
}

.merge-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.merge-preview-item {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.merge-preview-item:hover {
    border-color: var(--primary);
}

.merge-preview-item.selected {
    border-color: var(--accent);
    background: rgba(53, 148, 170, 0.1);
}

.merge-preview-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.merge-preview-item .page-label {
    font-size: 0.8rem;
    color: var(--secondary);
    font-weight: 500;
}

/* Compact tool section styles */
.tool-section.compact {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.tool-section.compact .section-title {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 600;
}

.property-list-compact {
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.property-list-compact small {
    color: var(--secondary);
    line-height: 1.6;
}

#text-size-control,
#draw-size-control {
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Active tool button styling */
.btn-outline-primary.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Responsive adjustments for PDF tools */
@media (max-width: 992px) {
    .pdf-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .toolbar-group {
        justify-content: center;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

    .merge-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .pdf-full-layout .row {
        margin: 0;
    }

    .pdf-viewer {
        height: 400px;
    }

    .upload-zone {
        padding: 1.5rem 1rem;
    }

    .upload-icon {
        font-size: 2rem;
    }
}

/* Ensure PDF tab is displayed properly */
#pdf-tab.active {
    display: block;
}