:root {
    --primary-color: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary-color: #ec4899;
    --bg-dark: #09090b;
    /* Zinc 950 */
    --glass-bg: rgba(24, 24, 27, 0.6);
    /* Zinc 900 low opacity */
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-success: #10b981;
    --accent-error: #ef4444;
}

.text-primary {
    color: var(--primary-color);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.1), transparent 40%);
    z-index: -1;
    animation: pulseBg 10s ease-in-out infinite alternate;
}

@keyframes pulseBg {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.1);
        opacity: 1;
    }
}

.container {
    width: 100%;
    max-width: 950px;
    opacity: 0;
    animation: fadeInPage 0.8s ease-out forwards;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 4rem);
}

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

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

header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 20%, #818cf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 0.5px;
}

footer {
    text-align: center;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-bottom: 1rem;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 16px;
    margin-bottom: 2.5rem;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.tab-btn i {
    font-size: 1.1rem;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: #fff;
    background: var(--primary-color);
    box-shadow: 0 4px 20px var(--primary-glow);
}

/* Content Transitions */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Inputs */
.input-group label {
    display: block;
    margin-bottom: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

textarea {
    width: 100%;
    min-height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    color: var(--text-main);
    font-size: 1.1rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

textarea:focus,
input:focus,
select:focus {
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Controls */
input,
select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    outline: none;
    transition: all 0.3s;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), #4f46e5);
    color: white;
    border: none;
    padding: 1.2rem 2.5rem;
    border-radius: 14px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 2rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(-1px);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Manual Specifics */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary-color);
    margin: 2.5rem 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--glass-border), transparent);
}

.row-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.dynamic-inputs {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}

.constraint-row {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.015);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.constraint-row:hover {
    border-color: var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
}

.del-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-error);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    border: none;
    cursor: pointer;
}

.del-btn:hover {
    background: var(--accent-error);
    color: white;
}

input[type="number"],
input[type="text"],
select {
    padding: 0.8rem;
    border-radius: 10px;
    text-align: center;
}

input[type="number"] {
    width: 90px;
}

input[type="text"] {
    width: 220px;
    text-align: left;
}

.config-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
}

.field label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Result Card */
.result-card h2 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.result-item {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
}

.result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--glass-border);
}

.result-item:first-child::before {
    background: var(--accent-success);
}

.result-item:nth-child(2)::before {
    background: var(--primary-color);
}

.result-item .label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

.result-item .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.vector-display {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.var-pill {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.3s;
}

.var-pill:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Explanation */
.explanation-box {
    background: linear-gradient(to right, rgba(234, 179, 8, 0.05), transparent);
    border-left: 4px solid #eab308;
    padding: 1.5rem;
    border-radius: 0 12px 12px 0;
    margin-top: 2rem;
}

/* Graph Visualization */
.graph-container {
    margin-top: 2rem;
    height: 500px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.graph-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.graph-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

#bnb-tree {
    flex: 1;
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.graph-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Loader */
.loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    animation: rotation 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    margin: 3rem auto;
}

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

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

.error-msg {
    color: var(--accent-error);
    background: rgba(239, 68, 68, 0.1);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--accent-error);
    margin-top: 2rem;
}

.hidden {
    display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .glass-card {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .logo {
        font-size: 2rem;
    }

    .config-row {
        justify-content: center;
        gap: 1.5rem;
    }

    .input-group label,
    .section-title {
        font-size: 0.8rem;
    }

    textarea {
        min-height: 120px;
        font-size: 1rem;
    }

    .constraint-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
        background: rgba(255, 255, 255, 0.03);
    }

    .lhs-inputs,
    .dynamic-inputs {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 0.8rem;
        width: 100%;
        justify-content: stretch;
    }

    .del-btn {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }

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

    .primary-btn {
        padding: 1rem;
        font-size: 1rem;
    }

    /* Adjust inputs for mobile */
    input[type="text"] {
        width: 100%;
        font-size: 16px;
        /* Prevent zoom */
    }

    input[type="number"] {
        width: 100%;
        max-width: none;
        font-size: 16px;
        /* Prevent zoom */
    }

    .row-control {
        justify-content: center;
    }

    .graph-container {
        height: 400px;
        margin-top: 1.5rem;
    }

    .graph-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}