:root {
    /* Light mode (default) variables */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f5f9;
    --border-color: #e5e7eb;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --accent-color: #3b82f6;
}

[data-theme="dark"] {
    /* Dark mode variables */
    --bg-primary: #18181b;
    --bg-secondary: #23232a;
    --bg-tertiary: #27272a;
    --border-color: #3f3f46;
    --text-primary: #e5e7eb;
    --text-secondary: #a1a1aa;
    --accent-color: #a3e635;
}

* {
    font-family: 'Inter', sans-serif;
}

body,
.gradient-bg {
    background: var(--bg-primary) !important;
    min-height: 100vh;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

.glass-effect {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

.modal {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.locator-card {
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
    backdrop-filter: none;
}

.locator-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--bg-primary);
    border-left-color: var(--bg-tertiary);
    background: var(--bg-tertiary) !important;
}

.ai-content {
    background: var(--bg-secondary) !important;
    border: 2px solid var(--border-color) !important;
}

.ai-badge,
.rule-badge {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
}

.loading-shimmer {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

    100% {
        background-position: -200% 0;
    }
}

.pulse-animation {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.input-section .section-content {
    max-height: 100%;
    min-height: 200px;
    height: 100%;
    overflow: hidden;
}

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

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

.code-block {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: var(--bg-primary) !important;
    color: var(--accent-color) !important;
    border-radius: 8px;
    position: relative;
}

.copy-success {
    background: #22c55e !important;
    color: #18181b !important;
}

.horizontal-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: calc(100vh - 100px);
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.section-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (max-width: 1024px) {
    .horizontal-layout {
        grid-template-columns: 1fr;
        height: auto;
        gap: 1.5rem;
    }

    .input-section,
    .output-section {
        height: 50vh;
    }
}

.ai-icon {
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary) !important;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color) !important;
    font-size: 10px;
    font-weight: bold;
}

.priority-high {
    border-left-color: #22c55e !important;
}

.priority-medium {
    border-left-color: #3b82f6 !important;
}

.priority-low {
    border-left-color: #f59e0b !important;
}

.output-section,
.output-section .section-content {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

#output-container {
    flex: 1 1 0%;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
}

html,
body,
.min-h-screen,
.flex-col {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

main {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.horizontal-layout {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Button and input overrides for theme */
button,
.rounded-xl,
.rounded-lg {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

button:disabled,
.rounded-xl:disabled,
.rounded-lg:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

input,
textarea,
select {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-color) !important;
    outline: none;
}

/* Remove colored backgrounds from badges, etc. */
.bg-blue-100,
.bg-purple-100,
.bg-green-100,
.bg-yellow-100,
.bg-red-100,
.bg-slate-100,
.bg-slate-200,
.bg-green-50,
.bg-red-50,
.bg-yellow-50 {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-blue-800,
[data-theme="dark"] .text-purple-800,
[data-theme="dark"] .text-green-800,
[data-theme="dark"] .text-yellow-800,
[data-theme="dark"] .text-red-800,
[data-theme="dark"] .text-slate-800,
[data-theme="dark"] .text-slate-600,
[data-theme="dark"] .text-slate-400,
[data-theme="dark"] .text-green-700,
[data-theme="dark"] .text-blue-700,
[data-theme="dark"] .text-yellow-700,
[data-theme="dark"] .text-red-700 {
    color: var(--text-primary) !important;
}

/* Toasts */
.bg-green-500,
.bg-red-500,
.bg-blue-500,
.bg-yellow-500 {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Remove box-shadows */
.shadow-lg,
.shadow-xl,
.shadow-2xl {
    box-shadow: none !important;
}

/* Remove gradient from chat bubble */
#chat-bubble {
    background: var(--bg-secondary) !important;
    color: var(--accent-color) !important;
}

.ai-badge,
.rule-badge {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--border-color);
}

.ai-icon {
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary) !important;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary) !important;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid var(--border-color);
}

/* Theme toggle button - simplified version */
.theme-toggle {
    cursor: pointer;
    width: 45px;
    height: 22px;
    position: relative;
    display: block;
    background: var(--bg-tertiary);
    border-radius: 20px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    transition: 0.3s;
}

.theme-toggle:after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 18px;
    top: 2px;
    left: 2px;
    background: var(--accent-color);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    transition: 0.3s;
}

.theme-switch:checked+.theme-toggle:after {
    left: 25px;
}

.theme-switch {
    height: 0;
    width: 0;
    visibility: hidden;
    position: absolute;
}

.hidden {
    display: none !important;
}

/* Custom styles for diff highlighting */
.hljs-addition,
.hljs-diff-add,
.hljs-diff-plus {
    background-color: rgba(34, 197, 94, 0.1) !important;
    color: #22c55e !important;
    display: block;
    width: 100%;
}

.hljs-deletion,
.hljs-diff-delete,
.hljs-diff-minus {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    display: block;
    width: 100%;
}

#diff-block {
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.6;
    white-space: pre;
    word-wrap: normal;
    tab-size: 4;
}

.language-diff {
    counter-reset: line;
}

.language-diff .line {
    display: block;
    padding: 0 1em;
    min-height: 1.5em;
}

.language-diff .line:before {
    counter-increment: line;
    content: counter(line);
    display: inline-block;
    margin-right: 1em;
    width: 2em;
    color: #64748b;
    text-align: right;
}

/* Override the pre styling for diff blocks */
pre code.language-diff {
    display: block;
    overflow-x: auto;
    padding: 1em;
    background: var(--bg-primary);
    border-radius: 0.5em;
}

body {
    font-family: 'Inter', sans-serif;
}

.form-input {
    transition: all 0.3s ease;
    border: 2px solid #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
}

.form-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: all 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.side-by-side-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: calc(100vh - 120px);
}

.input-panel,
.output-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.diff-line {
    font-family: 'JetBrains Mono', monospace;
    white-space: pre-wrap;
    padding: 2px 4px;
}

.diff-line.added {
    background-color: #e6ffed;
    color: #22863a;
}

.diff-line.removed {
    background-color: #ffeef0;
    color: #cb2431;
}

.stat-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.dashboard-card {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.sparkline-container {
    height: 48px;
    width: 100%;
}

/* Agent performance trend indicators */
.trend-up {
    color: #22c55e;
}

.trend-down {
    color: #ef4444;
}

.trend-stable {
    color: #6b7280;
}

/* Animated gradient backgrounds for charts */
@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.animated-gradient {
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #4facfe);
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

/* Performance spike indicators */
.spike-high {
    background: rgba(239, 68, 68, 0.2);
    border-left: 4px solid #ef4444;
}

.spike-medium {
    background: rgba(251, 191, 36, 0.2);
    border-left: 4px solid #fbbf24;
}

.spike-low {
    background: rgba(34, 197, 94, 0.2);
    border-left: 4px solid #22c55e;
}

/* Table enhancements */
tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-tertiary) !important;
    transform: scale(1.01);
}

/* Chart tooltip custom styling */
.chartjs-tooltip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive grid improvements */
@media (max-width: 640px) {
    .grid.grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

/* Loading state for charts */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 14px;
}

.chart-loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* Enhanced scrollbar for tables */
.overflow-auto::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.overflow-auto::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

.overflow-auto::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

.overflow-auto::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}