/* 1. Algemene instellingen */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
    padding: 10px;
    background-color: #f0f2f5;
    margin: 0;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-y: auto; 
}

h1 {
    text-align: center;
    color: #333;
    margin: 10px 0 20px 0;
    font-size: 1.5rem;
}

/* 2. De hoofdcontainer */
.main-container {
    max-width: 100%;
    display: block; /* Stapelt alles onder elkaar op mobiel */
    padding: 10px;
}

/* 3. Gedeelde styling voor alle fieldsets */
fieldset {
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    background: white;
    margin-bottom: 12px;
    padding: 8px 12px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Zorgt dat de legend de breedte van de fieldset dicteert */
fieldset legend {
    /*width: calc(100% - 20px); /* Iets smaller dan 100% voor de randjes */
    display: flex;
    justify-content: space-between;
    align-items: center;
}



legend {
    font-size: 0.95rem;
    font-weight: 700;
    color: #444;
    padding: 0 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 100px; /* Zorgt dat de legend breed genoeg blijft */
}

/* Zorg dat de legend als handvat herkenbaar is */
dialog legend {
    user-select: none;
    cursor: move;
    padding: 0 5px;
}

/* Zorg dat het dialog-element soepel verplaatst zonder lag */
dialog {
    will-change: transform;
    margin: auto; /* Standaard browser-centrering bij openen */
}

/* 4. Formulier elementen (Compacter) */
form {
    flex: 0 0 450px;
    height: 100%;
    overflow-y: auto; /* Alleen scrollen als het formulier te lang wordt */
    padding-right: 5px;
}

label {
    display: block;
    margin-top: 4px;
    margin-bottom: 2px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #666;
    /*text-transform: uppercase;*/
    letter-spacing: 0.02em;
}

input[type="text"], 
input[type="number"], 
select {
    width: 100%;
    padding: 6px 8px;
    margin-top: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    color: #333;
    background-color: #fff;
}

input:focus, select:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

/* Verberg de placeholder zodra de gebruiker in het veld klikt */
input:focus::placeholder {
    color: transparent;
}

select {
    height: 32px;
}

/* 5. Hulpmiddelen voor lay-out */
.flex-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.flex-row label {
    flex: 1;
    min-width: 80px;
}

.unit-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Het subtiele kruisje */
.remove-icon {
    font-size: 18px;
    color: #bbb;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s ease;
    padding-left: 10px;
}

.remove-icon:hover {
    color: #d9534f;
}


.toggle-icon {
    margin-left: 10px;
    font-family: monospace;
    font-weight: bold;
    color: #0077BB;
}

/* Styling voor het dialoogvenster */
dialog {
    border: 1px solid #d1d1d1;
    border-radius: 8px;
    padding: 0;
    background: #fff;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden; /* Zorgt dat de inhoud netjes binnen de randen blijft */
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog fieldset {
    margin: 0;
    border: none; /* Binnen een dialog hoeft de fieldset zelf geen extra rand te hebben */
    box-shadow: none;
    padding: 15px;
}

/* Subtiele link voor schaalhulp in het formulier */
.dialog-link {
    font-size: 0.8rem;
    color: #007bff;
    text-decoration: none;
    margin-top: -4px;
    display: inline-block;
    cursor: pointer;
}

.dialog-link:hover {
    text-decoration: underline;
}

/* Subtiele link voor schaalhulp in het formulier */
.fieldset-link {
    font-size: 0.9rem;
	font-style: italic;
    color: #007bff;
    text-decoration: none;
    margin-top: -4px;
    display: inline-block;
    cursor: pointer;
}

.fieldset-link:hover {
    text-decoration: underline;
}


/* raaklijn icoontje */
.raaklijn-icon {
    background: none;
    border: none;
    padding: 0 6px;
    cursor: pointer;
    color: #666;
    font-size: 15px;
    font-weight: bold;
}

.raaklijn-icon:hover {
    color: #000;
}

.regressie-icon {
    background: none;
    border: none;
    padding: 0 6px;
    cursor: pointer;
    color: #666;
    font-size: 18px;
    font-weight: bold;
}

.regressie-icon:hover {
    color: #000;
}

/* opmaak van figuurinstellingen*/
.figuur-overzicht {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    margin: 5px 0 12px 0;
}


/* opmaak van functie-lijst*/
.functie-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin: 4px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: #fafafa;
}

.functie-item:hover {
    background: #eef3f8;
    border-color: #aaa;
}

.functie-titel {
    flex: 1;
}

.functie-item .remove-icon {
    color: #999;
    font-size: 1.3rem;
    padding: 0 5px;
}

.functie-item .remove-icon:hover {
    color: #c00;
}





/* Knoppen binnen de dialog dezelfde stijl geven als de rest */
button.dialog-btn {
    padding: 8px;
    background-color: #f8f9fa;
    color: #666;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

button.dialog-btn:hover {
    background-color: #e9ecef;
    border-color: #999;
    color: #333;
}

.dialog-link {
	font-style: italic;
	font-size: 0.6rem;
}



/* Knoppen subtieler maken */
button[onclick*="voegFunctieToe"],
button[onclick*="voegTekstToe"], 
button[onclick*="voegDatalijstToe"],
button[onclick*="voegRaaklijnToe"],  
button[onclick*="help.html"] {
    width: 100%;
    padding: 8px;
    background-color: #f8f9fa;
    color: #666;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px; /* Ruimte tussen de knoppen */
}
button[onclick*="exporteerInstellingen"],
button[onclick*="document.getElementById('import-file')"] {
    padding: 8px;
    background-color: #f8f9fa;
    color: #666;
    border: 1px dashed #bbb;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px; /* Ruimte tussen de knoppen */	
}

button[onclick*="voegFunctieToe"]:hover, 
button[onclick*="voegTekstToe"]:hover,
button[onclick*="voegDatalijstToe"]:hover,
button[onclick*="voegRaaklijnToe"]:hover,   
button[onclick*="help.html"]:hover,
button[onclick*="exporteerInstellingen"]:hover,
button[onclick*="document.getElementById('import-file')"]:hover {
    background-color: #e9ecef;
    border-color: #999;
    color: #333;
}

button.formsubmit {
    width: 100%;
    padding: 10px;
    background-color: #e8f5e9; /* Zacht lichtgroen */
    color: #2e7d32; /* Donkergroene tekst */
    border: 1px dashed #bbb; /* Subtiele groene rand */
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 750;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

button.formsubmit:hover {
    background-color: #d0edd3;
    border-color: #a5d6a7;
    color: #1b5e20;
}

/* Container voor knoppen die naast elkaar moeten */
.button-group {
    display: flex;
    gap: 10px;          /* De ruimte tussen de twee knoppen */
    margin-bottom: 10px; /* Zelfde marge als je andere knoppen */
}

.button-group button {
    flex: 1;            /* Dwingt beide knoppen om precies 50% (minus de gap) in te nemen */
    margin: 0;          /* Reset eventuele marges die in de weg zitten */
    width: auto;        /* Overschrijf eventuele harde breedtes */
}

/* 7. Het Iframe */
.result-container {
    flex-grow: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.result-container fieldset {
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0; /* Geen marge aan de onderkant nodig */
}

iframe {
    width: 100%;
    height: 500px; /* Geef het iframe een vaste hoogte op mobiel */
    border: none;
}

/* 8. DESKTOP LAY-OUT (Naast elkaar) */
@media (min-width: 1000px) {
    html, body {
        height: 100%;
        overflow: hidden; /* Geen scrollbalk op desktop body */
    }

    .main-container {
        height: 100vh;
        display: flex; /* Naast elkaar op desktop */
        gap: 15px;
        overflow: hidden;
    }

    form {
        flex: 0 0 450px;
        height: 100%;
        overflow-y: auto; /* Alleen het formulier-deel scrollt indien nodig */
        padding-right: 10px;
    }

    .result-container {
        flex-grow: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .result-container fieldset {
        height: calc(100% - 20px); /* Past precies binnen de viewport */
        display: flex;
        flex-direction: column;
    }

    iframe {
        flex-grow: 1;
        height: 100%;
    }
}



/* Voorkom dat de fieldset smaller wordt dan de rest van het formulier */
.functie-item fieldset,
.tekstlijst-item fieldset, 
.datalijst-item fieldset {
    width: 100%;
    box-sizing: border-box;
    min-height: 2rem; /* Houdt de legend leesbaar bij inklappen */
}

/* Zorg dat de titels en icoontjes links bij elkaar blijven */
legend > span:first-child {
    display: flex;
    gap: 8px;
    align-items: center;
}



/* Container: Precies 26px breed */
/* 6. Model switch specifiek */
.switch {
    position: relative;
    /* inline-flex dwingt de container exact zo groot te zijn als de inhoud */
    display: inline-flex !important; 
    width: 26px !important;
    min-width: 26px !important;
    max-width: 26px !important;
    height: 16px !important;
    flex: 0 0 26px !important; /* Voorkomt rekken in een flex-box */
    margin: 0 5px;
    padding: 0 !important; /* Belangrijk: verwijder eventuele padding van labels */
    cursor: pointer;
}

/* Verberg de checkbox in het model volledig */
.switch input {
    display: none !important;
}

.slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 16px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

/* De verschuiving: 26px breed - 12px rondje - 4px marges = 10px */
input:checked + .slider:before {
    transform: translateX(10px);
}


/* testje met invoerknoppen */
/* Container waarin de knoppen én het invoerveld zitten */
.input-met-snelknoppen {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 6px;
    margin-bottom: 8px;
}

/* De balk met snelknoppen */
.constanten-bar {
    display: flex !important;
    gap: 1px !important;
    z-index: 10 !important;          /* Zorgt dat de knoppen BOVENOP de rand van het veld liggen */
    margin-bottom: -1px !important;   /* Trekt de knoppen precies over de rand heen */
    margin-left: 6px !important;     /* Lichte inspringing vanaf links */
}

/* Extreem kleine snelknop styling */
button.snelknop {
    all: unset;                       /* Wist alle standaard button-styling van de browser en je eigen CSS uit */
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* Afmetingen & Typografie */
    font-family: inherit !important;
    font-size: 10px !important;        /* Heel klein lettertype */
    font-weight: 600 !important;
    line-height: 1 !important;
    height: 18px !important;           /* Vaste, hele lage hoogte */
    padding: 0 5px !important;         /* Minimale breedte-opvulling */
    
    /* Vormgeving & Randen */
    background-color: #e9ecef !important;
    color: #495057 !important;
    border: 1px solid #ced4da !important;
    border-bottom: 1px solid #ced4da !important; /* Maakt de rand gelijk aan het veld */
    border-radius: 3px 3px 0 0 !important;       /* Alleen bovenhoekjes licht afgerond */
    cursor: pointer !important;
}

/* Hover- en klik-effecten */
button.snelknop:hover {
    background-color: #dee2e6 !important;
    color: #000 !important;
    border-color: #adb5bd !important;
}

button.snelknop:active {
    background-color: #ced4da !important;
}

/* Zorg dat het invoerveld eronder direct aansluit */
.input-met-snelknoppen input[type="text"] {
    position: relative !important;
    z-index: 1 !important;
    margin-top: 0 !important;
}