:root {
    --primary: #416666;
    --cream: #fef6eb;
    --coral: #c36c57;
    --tan: #eebd86;
    --light-cream: #fef6e9;
    --white: #ffffff;
    --black: #000000;
    --shadow: rgba(65, 102, 102, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f6f4ef;
    color: var(--black);
    line-height: 1.6;
}

.container {
    width: 100%;
    height: 100vh;
    margin: 0 auto;
    padding: 24px 16px 24px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Main container scrollbar styling */
.container::-webkit-scrollbar {
    width: 10px;
}

.container::-webkit-scrollbar-track {
    background: #e5e7eb;
    border-radius: 5px;
}

.container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

.container::-webkit-scrollbar-thumb:hover {
    background: #2d4a4a;
}

.results-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--primary);
    color: var(--white);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.header p {
    font-size: 0.95rem;
    opacity: 0.85;
}

/* Tabs */
.tabs-container {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    border-bottom: 2px solid var(--cream);
}

.tab-button {
    flex: 1;
    padding: 16px 24px;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tab-button:hover {
    background: var(--light-cream);
}

.tab-button.active {
    color: var(--primary);
    background: var(--cream);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Results Comparison Section */
.results-comparison-section {
    padding: 20px;
}

.comparison-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.comparison-box {
    background: var(--white);
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.comparison-title {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--cream);
}

.comparison-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comparison-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--cream);
    border-radius: 8px;
}

.comparison-item-label {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
}

.comparison-item-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.comparison-value {
    flex: 1;
    padding: 8px 12px;
    background: var(--white);
    border-radius: 6px;
    font-size: 0.9rem;
}

.comparison-status {
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.comparison-status.match {
    background: #d4edda;
    color: #155724;
}

.comparison-status.no-match {
    background: #f8d7da;
    color: #721c24;
}

.comparison-status.unknown {
    background: #fff3cd;
    color: #856404;
}

.comparison-status.not-applicable {
    background: #e2e3e5;
    color: #383d41;
}

.validation-status-box {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.validation-status-box.valid {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.validation-status-box.invalid {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.validation-errors-list,
.validation-warnings-list {
    margin-top: 12px;
    padding-left: 20px;
}

.validation-errors-list li,
.validation-warnings-list li {
    margin-bottom: 8px;
    padding: 8px;
    background: var(--white);
    border-radius: 4px;
}

.no-results-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.1rem;
}

/* Workflow Layout */
.workflow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: stretch;
    margin-bottom: 24px;
}

.drop-panel,
.status-panel {
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.status-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.status-list {
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 10px;
}

.status-item {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fdf9f0;
    border-left: 3px solid var(--tan);
    font-size: 0.9em;
    color: var(--primary);
}

.status-item.success {
    border-color: var(--primary);
}

.status-item.error {
    border-color: var(--coral);
    color: var(--coral);
    background: #ffe5e5;
}

.status-item:last-child {
    margin-bottom: 0;
}

/* Upload Section */
.upload-section {
    background: var(--white);
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.drop-zone {
    border: 2px dashed var(--tan);
    padding: 36px 24px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    background: #fffdf8;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--coral);
    background: var(--cream);
    transform: translateY(-2px);
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 3em;
    color: var(--primary);
    margin-bottom: 12px;
}

.drop-zone h3 {
    color: var(--primary);
    font-size: 1.2em;
    margin-bottom: 6px;
}

.drop-zone p {
    color: var(--primary);
    opacity: 0.7;
    font-size: 0.95em;
}

.file-types {
    margin-top: 15px;
    font-size: 0.85em;
    color: var(--coral);
}

#file-input {
    display: none;
}

.btn-upload {
    display: block;
    margin: 16px auto 0;
    padding: 12px 28px;
    background: var(--coral);
    color: var(--white);
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-upload:hover:not(:disabled) {
    background: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-upload:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Selected Files */
.selected-files {
    margin-top: 20px;
    padding: 18px;
    background: #fffdf8;
    border-radius: 10px;
    display: none;
}

.selected-files h3 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.3em;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid var(--tan);
}

.file-item:last-child {
    margin-bottom: 0;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--primary);
}

.file-size {
    font-size: 0.9em;
    color: var(--coral);
}

.file-status {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.file-status.upload {
    background: var(--tan);
    color: var(--white);
}

.file-status.uploading {
    background: var(--coral);
    color: var(--white);
}

.file-status.processed {
    background: var(--primary);
    color: var(--white);
}

.file-status.fake {
    background: #dc2626;
    color: var(--white);
}

.file-status-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.file-not-verified-note {
    color: #dc2626;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

/* Progress Bar */
.progress-bar-container {
    margin: 0;
    padding: 16px;
    background: #fffdf8;
    border-radius: 10px;
    border: 1px dashed var(--tan);
    display: none;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.progress-title {
    font-size: 1em;
    font-weight: 600;
    color: var(--primary);
}

.progress-percentage {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--coral);
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--cream);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: var(--coral);
    border-radius: 10px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-status {
    color: var(--primary);
    font-size: 1em;
    text-align: center;
}

/* Results Section */
.results-section {
    background: var(--white);
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 60px);
}

/* Results section scrollbar styling */
.results-section::-webkit-scrollbar {
    width: 8px;
}

.results-section::-webkit-scrollbar-track {
    background: var(--cream);
    border-radius: 4px;
}

.results-section::-webkit-scrollbar-thumb {
    background: var(--tan);
    border-radius: 4px;
}

.results-section::-webkit-scrollbar-thumb:hover {
    background: var(--coral);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--cream);
}

.results-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.results-title {
    font-size: 1.4em;
    color: var(--primary);
    font-weight: 600;
}

.action-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.action-btn:hover {
    background: var(--coral);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Preview Panel Styles */
.results-section {
    flex: 1;
    min-width: 0;
}

.preview-panel {
    width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    overflow-x: hidden;
}

.preview-panel.active {
    width: 500px;
    min-width: 400px;
}


.preview-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: ew-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s;
}

.preview-resize-handle:hover {
    background: var(--primary);
}

.preview-header {
    padding: 16px 20px;
    border-bottom: 2px solid var(--cream);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}


.preview-title {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.preview-close {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.preview-close:hover {
    background: var(--cream);
}

.preview-content {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 0;
    position: relative;
}

/* Preview panel scrollbar styling - different color to distinguish */
.preview-content::-webkit-scrollbar {
    width: 10px;
}

.preview-content::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 5px;
}

.preview-content::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: 5px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.preview-content-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.preview-content img {
    max-width: 100%;
    width: 100%;
    height: auto;
    box-shadow: none;
    transition: transform 0.3s ease;
    transform-origin: top center;
    display: block;
    padding: 10px;
    box-sizing: border-box;
}

.preview-content iframe {
    width: 100%;
    min-height: 100vh;
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: block;
    overflow: hidden;
}

.preview-content-wrapper {
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

.preview-placeholder {
    text-align: center;
    color: #666;
    padding: 40px;
}

.preview-file-selector {
    padding: 12px 20px;
    border-bottom: 1px solid var(--cream);
    background: var(--light-cream);
}

.preview-file-selector select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--cream);
    border-radius: 6px;
    background: var(--white);
    color: var(--primary);
    font-size: 0.9rem;
    cursor: pointer;
}

@media (max-width: 1200px) {
    .preview-panel.active {
        width: 400px;
        min-width: 300px;
    }
}

@media (max-width: 1200px) {
    .results-wrapper {
        flex-direction: column;
    }

    .preview-panel.active {
        width: 100%;
        min-width: 0;
        position: relative;
        top: 0;
    }
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 25px;
    background: var(--cream);
    color: var(--primary);
    border: 2px solid var(--cream);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: var(--tan);
    border-color: var(--tan);
    color: var(--white);
}

.tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* Data Tables */
.category-content {
    display: none;
}

.category-content.active {
    display: block;
}

.data-card {
    background: var(--light-cream);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border-left: 5px solid var(--coral);
}

.data-card h3 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.3em;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.data-field {
    background: var(--white);
    padding: 15px;
    border-radius: 8px;
}

.data-label {
    font-size: 0.85em;
    color: var(--coral);
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-value {
    font-size: 1.1em;
    color: var(--primary);
    font-weight: 600;
}

/* Table Wrapper for Horizontal Scroll */
.table-wrapper {
    width: 100%;
    overflow-x: visible;
    overflow-y: visible;
    margin-top: 20px;
    border-radius: 8px;
}

/* Items Table */
.items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
}

.items-table thead {
    background: var(--primary);
    color: var(--white);
}

.items-table th,
.items-table td {
    padding: 10px 6px;
    text-align: left;
    border-bottom: 1px solid var(--cream);
    font-size: 0.8em;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.items-table th {
    font-weight: 600;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.items-table tbody tr {
    transition: background 0.2s ease;
    opacity: 0;
    animation: fadeInRow 0.5s ease forwards;
}

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.items-table tbody tr:hover {
    background: var(--light-cream);
}

.items-table tbody tr:nth-child(even) {
    background: var(--cream);
}

.items-table tbody tr:nth-child(even):hover {
    background: var(--light-cream);
}

.line-item-type-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.line-item-type-header .type-fr {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.line-item-type-header .type-en {
    font-size: 0.95em;
    color: #666;
    font-style: italic;
    font-weight: 400;
}

.items-table tbody tr.subtotal-row {
    background: #eef6ff;
    border-top: 2px solid var(--primary);
    font-weight: 600;
}

.items-table tbody tr.subtotal-row:hover {
    background: #e2efff;
}

/* Alerts */
.alert {
    padding: 20px 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    display: none;
    border-left: 5px solid;
}

.alert.success {
    background: var(--cream);
    border-color: var(--primary);
    color: var(--primary);
}

.alert.error {
    background: #ffe5e5;
    border-color: var(--coral);
    color: var(--coral);
}

.alert.warning {
    background: #fff8e6;
    border-color: #d97706;
    color: #92400e;
}

.alert.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--cream);
    border-top-color: var(--coral);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--primary);
    color: var(--white);
    padding: 16px;
    border-radius: 10px;
    text-align: center;
}

.summary-card.coral {
    background: var(--coral);
}

.summary-card.tan {
    background: var(--tan);
}

.summary-value {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 6px;
}

.summary-label {
    font-size: 0.85em;
    opacity: 0.9;
}

/* Badge Styles for Medical Bot Results */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    text-align: center;
    min-width: 50px;
}

.badge-yes {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.badge-no {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.badge:not(.badge-yes):not(.badge-no) {
    background: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

/* Responsive */
@media (max-width: 1400px) {
    .items-table th,
    .items-table td {
        padding: 8px 4px;
        font-size: 0.75em;
    }

    .items-table th {
        font-size: 0.7em;
    }
}

@media (max-width: 768px) {
    .workflow {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .data-grid {
        grid-template-columns: 1fr;
    }

    .items-table th,
    .items-table td {
        padding: 6px 3px;
        font-size: 0.7em;
    }

    .items-table th {
        font-size: 0.65em;
        letter-spacing: 0.2px;
    }
}
