/* Titration visualization styles */

.visualization-panel {
    /* Use subtle translucent background to blend with page gradient */
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-top: var(--space-4);
}

.control-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    background: rgba(255, 255, 255, 0.95); /* Light background for visibility */
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-group label {
    font-size: 0.9em;
    color: #374151; /* Dark text for light background */
}

.input-group input {
    background: #ffffff; /* White background */
    border: 1px solid #d1d5db; /* Light border */
    color: #111827; /* Dark text */
    padding: var(--space-2);
    border-radius: var(--radius-xs);
    width: 100%;
}

.update-btn {
    background: #7f5dff;
    color: #ffffff;
    border: none;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-self: flex-end;
    transition: all var(--trans-fast);
}

.update-btn:hover {
    background: #5a38d1;
}

.plot-container {
    min-height: clamp(400px, 60vh, 700px);
    background: var(--color-surface-alt);
    border-radius: var(--radius-md);
    padding: clamp(1rem, 2vw, 1.5rem);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    margin: 1rem 0;
}

/* New layout for titration: left controls, center plot */
.titration-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.25rem;
    align-items: start;
    margin-top: 0.5rem;
}

.titration-left {
    position: relative;
}

.titration-left .visualization-panel {
    display: block;
}

.titration-center {
    display: flex;
    justify-content: center;
}

.titration-center .global-plot-card {
    width: 100%;
    max-width: 900px;
}

/* Make the controls sticky so plot remains visible */
.titration-left .control-inputs {
    position: sticky;
    top: 72px; /* beneath header */
}

.visualization-panel {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    margin-top: 0;
}

.control-inputs {
    background: var(--color-surface-alt);
    border-radius: var(--radius-md);
    padding: clamp(0.5rem, 1vw, 0.75rem);
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
}

.input-group {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 360px;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text-dim);
}

.input-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}

.reagents-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    width: 100%;
    margin: 0;
}

.button-group .primary-btn {
    min-width: 120px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .plot-container {
        min-height: clamp(300px, 50vh, 500px);
    }

    /* On small screens stack the layout */
    .titration-layout {
        grid-template-columns: 1fr;
    }

    .control-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .plot-container {
        min-height: 300px;
        padding: 0.75rem;
    }

    .control-inputs {
        padding: 0.75rem;
        gap: 0.75rem;
    }
}

.plot-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(127, 93, 255, 0.05), rgba(148, 72, 201, 0.05));
    pointer-events: none;
    border-radius: inherit;
}

#titration-container {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-md);
    margin: var(--space-2) 0;
    border: 1px solid var(--color-border);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .control-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group {
        width: 100%;
    }

    .input-group input {
        width: 100%;
    }
}
.calculation-details,
.stoichiometry-info {
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--color-text-dim);
}

/* Compact Calculation Details box shown above the plot */
.calculation-details {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.04);
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 420px;
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.calculation-details .calc-summary { display:flex; flex-direction:column; gap:4px; }
.calculation-details .calc-row { display:flex; gap:8px; justify-content:space-between; }
.calculation-details .calc-label { color: var(--color-text-dim); min-width: 120px; }
.calculation-details .calc-value { font-weight:600; color: var(--color-text); }
