:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    height: 100vh;
    padding: 0;
    overflow-y: auto;
    /* Allow scroll if needed */
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
}

.app-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

h1 {
    font-size: 2.5rem;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    color: var(--text-muted);
}

/* LAYOUT GRID */
.split-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Two equal columns */
    gap: 2rem;
    flex-grow: 1;
    align-items: start;
    /* Align items to top */
    min-height: 0;
    /* Prevent overflow issues */
}

/* CARDS */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.input-card {
    height: 100%;
    min-height: 400px;
}

/* RIGHT PANEL (RESULTS) */
.right-panel {
    height: 100%;
    overflow-y: auto;
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.3);
    /* Subtle bg for the 'empty' slot */
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* PLACEHOLDER STATE */
#placeholder-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

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

/* DEBUG DETAILS */
.debug-details {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.4);
    transition: all 0.2s;
}

.debug-details[open] {
    background: rgba(15, 23, 42, 0.8);
    border-color: var(--primary);
}

.debug-details summary {
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    /* Hide default triangle */
    transition: color 0.2s;
}

/* Custom arrow/icon */
.debug-details summary::before {
    content: '▶';
    font-size: 0.8em;
    transition: transform 0.2s;
    display: inline-block;
}

.debug-details[open] summary::before {
    transform: rotate(90deg);
}

.debug-details summary:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.debug-details pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    margin: 0;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    font-size: 0.85rem;
    color: #a5b4fc;
    /* Light indigo for code */
    max-height: 300px;
    /* Limit height */
    overflow-y: auto;
}

/* TABS */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 0.75rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    border-radius: 0.5rem;
}

.tab-btn.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* INPUTS */
textarea {
    width: 100%;
    height: 300px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-main);
    padding: 1rem;
    font-family: inherit;
    resize: none;
    font-size: 1rem;
    line-height: 1.5;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 0.5rem;
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

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

.action-btn {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.action-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

/* RESULTS STYLING */
.hidden {
    display: none !important;
}

.result-card {
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary);
}

.summary-card p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #e2e8f0;
}

#explanations-list li {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

/* TABLE */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    display: inline-block;
}

.status-low {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.status-high {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.status-normal {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

/* SPINNER */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 300px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    body {
        padding: 0;
        overflow-y: auto;
    }

    .app-wrapper {
        padding: 1rem;
        height: auto;
        display: block;
        /* Remove flex column behavior on mobile to allow natural scroll */
    }

    .split-view {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        display: block;
        /* Stack blocks naturally */
    }

    .left-panel,
    .right-panel {
        margin-bottom: 2rem;
        height: auto;
        /* Allow auto height */
        overflow: visible;
        /* Remove internal scrollbars on mobile */
    }

    .right-panel {
        background: transparent;
        border: none;
        padding: 0;
    }

    .card {
        margin-bottom: 1rem;
        max-height: none;
        /* Remove height limits */
    }

    h1 {
        font-size: 1.75rem;
    }

    textarea {
        height: 150px;
    }

    .upload-area {
        padding: 2rem 1rem;
        height: 200px;
    }

    /* Make table scrollable */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}