/* Custom UI Elements matching 'industriële thema-stijl' */
body {
    background-color: #1a1a24;
    color: #edf2f4;
    font-family: 'Inter', sans-serif;
    background-image: radial-gradient(#2b2d42 1px, transparent 1px);
    background-size: 20px 20px;
    touch-action: manipulation;
}

/* Pipes/Industrial decorative background elements */
.bg-pipe {
    position: fixed;
    background: linear-gradient(90deg, #3a3f58, #4a5072, #3a3f58);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: -1;
}

.bg-pipe-h {
    top: 10%;
    left: 0;
    width: 100%;
    height: 30px;
}

.bg-pipe-v {
    top: 0;
    right: 10%;
    width: 40px;
    height: 100%;
}

/* Industrial Cards */
.panel {
    background: linear-gradient(145deg, #2b2d42, #212333);
    border: 2px solid #4a5072;
    border-top: 4px solid #ff6b35;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    position: relative;
}

/* Bolts for panels */
.panel::before,
.panel::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #8d99ae;
    border-radius: 50%;
    box-shadow: inset -1px -1px 3px rgba(0, 0, 0, 0.5), 1px 1px 2px rgba(255, 255, 255, 0.3);
    top: 10px;
}

.panel::before {
    left: 10px;
}

.panel::after {
    right: 10px;
}

/* Industrial Buttons */
.btn-industry {
    background: linear-gradient(to bottom, #ff8c42, #ff6b35);
    border: 1px solid #c24914;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.1s;
    cursor: pointer;
}

.btn-industry:active {
    background: #e05a28;
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
    transform: translateY(2px);
}

.btn-cold {
    background: linear-gradient(to bottom, #a0b0cc, #8d99ae);
    border-color: #5c687e;
}

.btn-outline {
    background: transparent;
    border: 2px solid #ff6b35;
    color: #ff6b35;
    cursor: pointer;
}

.btn-outline:hover {
    background: rgba(255, 107, 53, 0.1);
}

button {
    cursor: pointer;
}

/* Inputs */
.input-industry {
    background: #1a1a24;
    border: 2px solid #4a5072;
    color: #edf2f4;
    font-family: 'Roboto Mono', monospace;
    transition: border-color 0.3s;
}

.input-industry:focus {
    outline: none;
    border-color: #ff6b35;
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.3);
}

/* Gauge / Meters */
.gauge-container {
    width: 100px;
    height: 50px;
    overflow: hidden;
    position: relative;
}

.gauge-arch {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 10px solid #4a5072;
    border-top-color: #d90429;
    border-right-color: #ff6b35;
    border-bottom-color: #8cc63f;
    border-left-color: #0066cc;
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-45deg);
}

/* Scenario Styling */
.scenario-text {
    font-family: 'Roboto Mono', monospace;
    border-left: 4px solid #ff6b35;
    padding-left: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
}

/* Toasts & Modals */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: #2b2d42;
    border-left: 5px solid #8cc63f;
    color: white;
    padding: 15px 20px;
    margin-top: 10px;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 15px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    border-left-color: #d90429;
}

.toast.warning {
    border-left-color: #ff6b35;
}

.toast.info {
    border-left-color: #0066cc;
}

.modal-overlay {
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
}

.modal-content {
    background: #2b2d42;
    border: 2px solid #4a5072;
    border-top: 5px solid #ff6b35;
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.2);
    -webkit-overflow-scrolling: touch;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Grid for tools */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.tool-card {
    background: #1a1a24;
    border: 1px solid #4a5072;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-card:hover {
    border-color: #ff6b35;
    background: #212333;
}

.tool-card.selected {
    border-color: #ff6b35;
    background: rgba(255, 107, 53, 0.1);
    box-shadow: inset 0 0 10px rgba(255, 107, 53, 0.2);
}

/* ==========================================
   QUILL WYSIWYG EDITOR (DARK MODE & TAILWIND FIX)
   ========================================== */
.ql-toolbar.ql-snow {
    background-color: #edf2f4;
    border-radius: 6px 6px 0 0;
    border: none;
}

.ql-container.ql-snow {
    border: 1px solid rgba(141, 153, 174, 0.4);
    border-radius: 0 0 6px 6px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.ql-editor {
    min-height: 120px;
    color: white;
}

/* Zorg dat Tailwind de lijstjes, vetgedrukte tekst én wiskundige formules niet wist */
.html-content ul {
    list-style-type: disc !important;
    padding-left: 2rem !important;
    margin-bottom: 1rem !important;
    display: block !important;
}

.html-content ol {
    list-style-type: decimal !important;
    padding-left: 2rem !important;
    margin-bottom: 1rem !important;
    display: block !important;
}

/* DIT IS DE BELANGRIJKSTE REGEL VOOR DE BOLLETJES: */
.html-content li {
    display: list-item !important;
    margin-bottom: 0.5rem !important;
}

.html-content b,
.html-content strong {
    font-weight: bold !important;
}

.html-content i,
.html-content em {
    font-style: italic !important;
}

.html-content u {
    text-decoration: underline !important;
}

/* Laat de teksteditor (Quill) de enters zelf regelen, forceer geen extra marges meer */
.html-content p {
    display: block !important;
    margin-bottom: 0 !important;
    /* Zorgt dat zinnen niet meer uit elkaar geduwd worden */
    line-height: 1.6 !important;
}

.html-content br {
    display: inline !important;
    /* Laat normale breaks hun werk doen */
}

/* Zorg dat wiskundige formules netjes worden weergegeven in het spelscherm */
.html-content .katex {
    font-size: 1.1em;
    color: #edf2f4;
}

.html-content .katex-display {
    margin: 0.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Fix voor zwevende Quill tooltip (formule/link pop-up) */
.ql-tooltip {
    left: 10px !important;
    top: 10px !important;
    z-index: 1000 !important;
    background-color: #1a1d24 !important;
    color: white !important;
    /* Fout hersteld: # is weg */
    border: 1px solid #ff6b35 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important;
}

.ql-tooltip input[type=text] {
    background-color: #1a1a24 !important;
    color: #edf2f4 !important;
    border: 1px solid #4a5072 !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
}

.ql-tooltip a.ql-action::after {
    border-right: 1px solid #ff6b35 !important;
}

/* ==========================================
   SIMULATOR / IFRAME GLOBAL RESIZING FIX
   ========================================== */
/* Zorg dat de iframe zélf nooit rare scrollbars krijgt en 100% vult */
iframe {
    width: 100%;
    height: 100%;
    border: none;
    overflow: hidden;
}

/* 
 * DIT IS DE MAGIE VOOR BINNENIN DE SIMULATOREN:
 * We richten ons op bestanden die .container en .visual-card gebruiken (jouw simulatoren)
 * Omdat deze CSS wereldwijd wordt ingeladen, zal dit voor alle huidige én toekomstige sims gelden.
 */

/* Zorg dat de body binnen een iframe (de simulator) 100% is en flexbox gebruikt */
body iframe body {
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Forceer anti-scroll! */
}

/* De main wrapper van de simulator krimpt mee met de iframe-hoogte */
body iframe .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Laat flex krimpen! */
    gap: 6px;
}

/* Statische elementen zoals headers, sliders en tekst mogen nooit krimpen */
body iframe header,
body iframe .scenario-tabs,
body iframe .controls-grid,
body iframe .info-panel,
body iframe .metrics-grid,
body iframe .status-banner {
    flex-shrink: 0;
}

/* De container waar de SVG in zit fungeert als een dynamische accordeon */
body iframe .visual-card {
    flex: 1;
    min-height: 0;
    /* Laat krimpen! */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* De SVG-tekening schaalt exact tot de grens van de visual-card */
body iframe .visual-card svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}