/* ══════════════════════════════════════════════════════════════════
   BimovisProteinViewer — UI Stylesheet
   ══════════════════════════════════════════════════════════════════ */

/* ── Theme tokens (scoped so they don't leak into WordPress) ─────── */
#protein-viewer-container {
    --bv-bg:           #0d1520;
    --bv-surface:      #162032;
    --bv-surface2:     #1e2d42;
    --bv-border:       #283a52;
    --bv-text:         #e2e8f0;
    --bv-text-muted:   #7f96b2;
    --bv-text-light:   #b8cade;
    --bv-accent:       #3b82f6;
    --bv-accent-hover: #2563eb;
    --bv-success:      #10b981;
    --bv-danger:       #f87171;
    --bv-chain-color:  #60a5fa;
    --bv-ligand-color: #a78bfa;
    --bv-solvent-color:#22d3ee;
    --bv-radius:       10px;
    --bv-radius-sm:    6px;
    --bv-transition:   0.16s ease;

    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px 48px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--bv-text);
    line-height: 1.5;
    box-sizing: border-box;
}
#protein-viewer-container *, #protein-viewer-container *::before, #protein-viewer-container *::after {
    box-sizing: inherit;
}

/* ── Viewer header ───────────────────────────────────────────────── */
.viewer-header {
    padding: 24px 0 18px;
    text-align: center;
}
.viewer-header h2 {
    margin: 0 0 5px;
    font-size: 22px;
    font-weight: 700;
    color: var(--bv-text);
    letter-spacing: -0.015em;
}
.viewer-header p {
    margin: 0;
    font-size: 13px;
    color: var(--bv-text-muted);
}

/* ── PDB form ────────────────────────────────────────────────────── */
#pdb-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bv-surface);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    padding: 14px 18px;
    margin-bottom: 14px;
}
#pdb-form label {
    font-size: 13px;
    color: var(--bv-text-muted);
    font-weight: 500;
}
#pdb-form input[type="text"] {
    background: var(--bv-bg);
    color: var(--bv-text);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    padding: 7px 12px;
    font-family: monospace;
    font-size: 14px;
    width: 100px;
    transition: border-color var(--bv-transition);
}
#pdb-form input[type="text"]:focus {
    outline: none;
    border-color: var(--bv-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
#pdb-form input[type="checkbox"] {
    accent-color: var(--bv-accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}
#pdb-form button[type="submit"] {
    background: var(--bv-accent);
    color: #fff;
    border: none;
    border-radius: var(--bv-radius-sm);
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--bv-transition);
    letter-spacing: 0.01em;
}
#pdb-form button[type="submit"]:hover { background: var(--bv-accent-hover); }

/* ── NGL viewer canvas ───────────────────────────────────────────── */
#ngl-viewer {
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    overflow: hidden;
    background: #000;
    margin-bottom: 14px;
}

/* ── Preset bar ──────────────────────────────────────────────────── */
.preset-container { margin: 0 0 14px; }
.preset-buttons   { display: flex; flex-wrap: wrap; gap: 8px; }

.preset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bv-surface);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    padding: 7px 14px;
    font-size: 13px;
    color: var(--bv-text-muted);
    cursor: pointer;
    transition: all var(--bv-transition);
}
.preset-btn:hover           { border-color: var(--bv-accent); color: var(--bv-text); }
.preset-btn.active          { background: rgba(59,130,246,0.12); border-color: var(--bv-accent); color: var(--bv-accent); }
.preset-icon                { font-size: 15px; }

/* ── Three-column object grid ────────────────────────────────────── */
#protein-object-container { margin: 0 0 16px; }

.object-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
@media (max-width: 700px)                      { .object-grid { grid-template-columns: 1fr; } }
@media (min-width: 701px) and (max-width: 1000px) { .object-grid { grid-template-columns: 1fr 1fr; } }

/* ── Object card ─────────────────────────────────────────────────── */
.object-card {
    background: var(--bv-surface);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    padding: 18px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 13px;
    transition: border-color var(--bv-transition), box-shadow var(--bv-transition);
}
.object-card:hover {
    border-color: rgba(59,130,246,0.35);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* Accent stripe per group */
.object-card[data-group="Chains"]          { border-top: 3px solid var(--bv-chain-color); }
.object-card[data-group="Ligands"]         { border-top: 3px solid var(--bv-ligand-color); }
.object-card[data-group="Solvents & Ions"] { border-top: 3px solid var(--bv-solvent-color); }

/* ── Card header ─────────────────────────────────────────────────── */
.object-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--bv-border);
}
.object-name {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.object-card[data-group="Chains"]          .object-name { color: var(--bv-chain-color); }
.object-card[data-group="Ligands"]         .object-name { color: var(--bv-ligand-color); }
.object-card[data-group="Solvents & Ions"] .object-name { color: var(--bv-solvent-color); }

.vis-btn-group {
    display: flex;
    gap: 5px;
}

.visibility-btn {
    background: transparent;
    border: 1px solid var(--bv-border);
    border-radius: 20px;
    color: var(--bv-text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all var(--bv-transition);
}
.visibility-btn:hover        { border-color: var(--bv-accent); color: var(--bv-accent); }
.visibility-btn.hidden       { border-color: var(--bv-danger); color: var(--bv-danger); }

/* ── Card control rows ───────────────────────────────────────────── */
.object-selector,
.repr-selector,
.color-selector,
.material-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.object-selector > label,
.repr-selector   > label,
.color-selector  > label,
.material-selector > label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--bv-text-muted);
}

/* ── Custom styled <select> ──────────────────────────────────────── */
.object-dropdown,
.repr-select,
.color-select,
.material-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--bv-surface2);
    /* SVG chevron encoded inline */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpolyline points='1,1 5,5 9,1' fill='none' stroke='%237f96b2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    color: var(--bv-text);
    font-size: 13px;
    padding: 8px 30px 8px 11px;
    cursor: pointer;
    width: 100%;
    transition: border-color var(--bv-transition), box-shadow var(--bv-transition);
    outline: none;
}
.object-dropdown:hover,
.repr-select:hover,
.color-select:hover,
.material-select:hover {
    border-color: #4b6080;
}
.object-dropdown:focus,
.repr-select:focus,
.color-select:focus,
.material-select:focus {
    border-color: var(--bv-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}
/* Dropdown options inherit dark background where supported */
.object-dropdown option,
.repr-select option,
.color-select option,
.material-select option {
    background: var(--bv-surface2);
    color: var(--bv-text);
}

/* ── Custom color picker ─────────────────────────────────────────── */
.custom-color-picker {
    width: 40px;
    height: 30px;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    background: transparent;
    cursor: pointer;
    padding: 2px;
    margin-top: 2px;
}

/* ── Render controls panel ───────────────────────────────────────── */
.render-controls {
    background: var(--bv-surface);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    padding: 20px 22px;
    margin-top: 4px;
}
.render-controls h3 {
    margin: 0 0 5px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bv-text-muted);
}
.render-controls p {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--bv-text-muted);
    line-height: 1.6;
}

/* Quality row */
.quality-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.quality-row label {
    font-size: 13px;
    color: var(--bv-text-muted);
    white-space: nowrap;
    min-width: 100px;
}
.quality-row input[type="range"] {
    flex: 1;
    accent-color: var(--bv-accent);
    cursor: pointer;
}
#quality-label {
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--bv-text);
    font-weight: 600;
}
.quality-hint {
    font-size: 12px;
    color: #4b6080;
    white-space: nowrap;
}

/* ── Preview button ──────────────────────────────────────────────── */
#preview-button {
    background: var(--bv-surface2);
    color: var(--bv-text);
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: border-color var(--bv-transition), background var(--bv-transition);
}
#preview-button:hover  { border-color: var(--bv-accent); background: rgba(59,130,246,0.08); }
#preview-button:active { transform: scale(0.98); }

/* ── Render button ───────────────────────────────────────────────── */
#render-button {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
    border-radius: var(--bv-radius-sm);
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity var(--bv-transition), transform var(--bv-transition);
}
#render-button:hover  { opacity: 0.88; }
#render-button:active { transform: scale(0.98); }

/* ── Download button ─────────────────────────────────────────────── */
#download-button {
    display: inline-block;
    margin-left: 10px;
    background: var(--bv-success);
    color: #fff;
    border: none;
    border-radius: var(--bv-radius-sm);
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: opacity var(--bv-transition);
}
#download-button:hover { opacity: 0.85; color: #fff; }

/* ── Rendered image output ───────────────────────────────────────── */
#render-output {
    margin-top: 16px;
    border-radius: var(--bv-radius);
    overflow: hidden;
    border: 1px solid var(--bv-border);
    background: var(--bv-bg);
    line-height: 0;   /* remove gap below img */
}
#rendered-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
}

/* ── Info / error messages ───────────────────────────────────────── */
.info-message {
    color: var(--bv-text-muted);
    font-size: 13px;
    padding: 6px 0;
    margin: 0;
}

/* ── Loading overlay ─────────────────────────────────────────────── */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: #e2e8f0;
    font-size: 15px;
    gap: 16px;
}
.loading-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(59,130,246,0.25);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: bv-spin 0.75s linear infinite;
}
@keyframes bv-spin { to { transform: rotate(360deg); } }

/* ── Toast notification ──────────────────────────────────────────── */
.toast-message {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: rgba(22,32,50,0.96);
    border: 1px solid var(--bv-border);
    border-radius: 999px;
    padding: 9px 22px;
    font-size: 13px;
    color: var(--bv-text);
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 10000;
    pointer-events: none;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
