:root {
    --bg-color: #f1f5f9;
    --surface-color: #ffffff;
    --surface-hover: #f8fafc;
    --primary-color: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.25);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #cbd5e1;
    --danger-color: #dc2626;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background elements for abstract premium look */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(241,245,249,0) 70%);
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, rgba(241,245,249,0) 70%);
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100vh;
}

.app-header {
    text-align: center;
    margin-bottom: 0.5rem;
    animation: fadeInDown 0.8s ease-out;
}

.app-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.main-content {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: fadeIn 1s ease-out;
}

.tabs-wrapper {
    background: rgba(241, 245, 249, 0.6);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0.5rem 0 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 1rem 1rem 0 0;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: max-content;
    position: relative;
    outline: none;
}

.tab-button::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-color);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: bottom right;
}

.tab-button:hover {
    background: var(--surface-color);
    color: var(--text-primary);
}

.tab-button:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.tab-button.active {
    background: var(--surface-color);
    color: var(--text-primary);
}

.tab-button.active::after {
    transform: scaleX(1);
}

.tab-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.15rem;
}

.tab-subtitle {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Refresh Button */
.refresh-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.refresh-button:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.refresh-button svg.spin-icon {
    animation: spin-fast 1s ease-in-out;
}

/* Tab Content area */
.tab-content-container {
    flex: 1;
    position: relative;
    padding: 1.5rem;
    background: var(--surface-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Loader */
.loader {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

/* Error Message */
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--danger-color);
    text-align: center;
}

.error-message.hidden {
    display: none;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Table styling for Pandas HTML */
.table-responsive {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.825rem;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Fix sticky header */
.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-hover);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

/* Make first column sticky */
.data-table th:first-child,
.data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    white-space: normal;
    overflow-wrap: break-word;
}

.data-table th:first-child {
    z-index: 30; /* Highest priority for the top-left corner */
}

.data-table td:first-child {
    background-color: #ffffff;
    border-right: 1px solid var(--border-color);
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover td {
    background-color: rgba(37, 99, 235, 0.05);
}

.data-table tbody tr:hover td:first-child {
    background-color: #f8fafc; /* Opaque equivalent of hover color */
}

.data-table tbody td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(203, 213, 225, 0.6);
}

.unmapped-text {
    color: var(--danger-color);
}

/* Alternate row styling */
.data-table tbody tr:nth-child(even) td {
    background-color: rgba(0, 0, 0, 0.02);
}

.data-table tbody tr:nth-child(even) td:first-child {
    background-color: #fafafa; /* Opaque equivalent of even row */
}

.data-table tbody tr:nth-child(even):hover td:first-child {
    background-color: #f1f5f9;
}

/* Number alignment */
.data-table td {
    text-align: right;
}

.data-table td:first-child {
    text-align: left;
    font-weight: 500;
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes spin-fast {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal & Interactive Criteria styling */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--surface-color); padding: 1.5rem 2rem; border-radius: 1rem;
    width: 600px; max-width: 95%; height: 90vh; /* listbox styling height */
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    border: 1px solid var(--border-color); color: var(--text-primary);
    display: flex; flex-direction: column;
}
.modern-listbox {
    flex: 1; /* Stretch to fill modal */
    width: 100%; padding: 0.5rem; margin: 0.5rem 0; border-radius: 0.5rem;
    border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-primary);
    font-family: inherit; font-size: 0.95rem; outline: none;
    overflow-y: auto;
}
.modern-input {
    width: 100%; padding: 0.75rem 1rem; border-radius: 0.5rem;
    border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-primary);
    font-family: inherit; font-size: 0.95rem; outline: none; margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}
.modern-input:focus {
    border-color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-glow);
}
.modern-listbox option {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background-color 0.15s;
}
.modern-listbox option:hover {
    background-color: rgba(37, 99, 235, 0.05);
}
.modern-listbox option:checked {
    background-color: var(--primary-glow);
    color: var(--primary-color);
    font-weight: 500;
}

/* Parent row styled with dynamic color tone */
.data-table tr.parent-row td {
    background-color: var(--parent-bg, #999) !important;
    color: var(--parent-text, #fff) !important;
    font-weight: 700;
    border-color: var(--parent-border, #888) !important;
}
.data-table tr.parent-row:hover td {
    filter: brightness(0.95);
}
.parent-text {
    color: inherit;
}

.clickable-criterion {
    cursor: pointer; text-decoration: underline; text-decoration-style: dashed;
    text-decoration-color: var(--text-secondary);
    transition: color 0.2s ease;
}
.clickable-criterion:hover {
    color: var(--primary-color);
    text-decoration-color: var(--primary-color);
}
