/* ----------------------------------------------------------------
   Backstage — beheerdersinterface
   ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bs-bg:        #f4f4f2;
    --bs-sidebar:   #1a1a1a;
    --bs-text:      #1a1a1a;
    --bs-muted:     #666;
    --bs-border:    #d8d8d4;
    --bs-accent:    #2a6496;
    --bs-success:   #3a7a3a;
    --bs-danger:    #a83232;
    --bs-white:     #fff;
    --bs-sidebar-w: 220px;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--bs-text);
    background: var(--bs-bg);
}

a { color: var(--bs-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Basisstructuur ---- */

.backstage-wrap {
    display: flex;
    min-height: 100vh;
}

.backstage-sidebar {
    width: var(--bs-sidebar-w);
    flex-shrink: 0;
    background: var(--bs-sidebar);
    color: #ccc;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.backstage-sidebar .site-logo {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-decoration: none;
}

.backstage-sidebar .nav-main ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.backstage-sidebar .nav-main a {
    display: block;
    padding: .4rem .6rem;
    border-radius: 4px;
    color: #bbb;
    font-size: .9rem;
    text-decoration: none;
}

.backstage-sidebar .nav-main a:hover,
.backstage-sidebar .nav-main li.active a {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.backstage-content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1100px;
}

/* ---- Paginaheader ---- */

.bs-page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--bs-border);
}

.bs-page-header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

/* ---- Stats ---- */

.bs-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bs-white);
    border: 1px solid var(--bs-border);
    border-radius: 6px;
    padding: .75rem 1.25rem;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: .8rem;
    color: var(--bs-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-sub {
    font-size: .8rem;
    color: var(--bs-muted);
}

/* ---- Tabellen ---- */

.bs-recent,
.bs-list {
    margin-bottom: 2rem;
}

.bs-recent h2,
.bs-list h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bs-muted);
}

.bs-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bs-white);
    border: 1px solid var(--bs-border);
    border-radius: 6px;
    overflow: hidden;
    font-size: .875rem;
}

.bs-table th,
.bs-table td {
    padding: .5rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--bs-border);
}

.bs-table th {
    background: #f9f9f7;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bs-muted);
    font-weight: 600;
}

.bs-table tr:last-child td { border-bottom: none; }
.bs-table tr:hover td { background: #fafaf8; }
.bs-table tr.row-editing td { background: #fffff0; }

.col-key code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .8rem;
    background: #f0f0ec;
    padding: .1em .35em;
    border-radius: 3px;
}

.col-preview { color: var(--bs-muted); }
.col-preview--small { font-size: .8rem; }

.col-actions { white-space: nowrap; }
.col-actions a { font-size: .8rem; }

/* ---- Filter-tabs ---- */

.bs-filter-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.bs-filter-tabs ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.bs-filter-tabs a {
    padding: .3rem .75rem;
    border: 1px solid var(--bs-border);
    border-radius: 20px;
    font-size: .8rem;
    color: var(--bs-text);
    text-decoration: none;
    background: var(--bs-white);
}

.bs-filter-tabs a:hover { border-color: var(--bs-accent); color: var(--bs-accent); }
.bs-filter-tabs li.active a { background: var(--bs-accent); color: var(--bs-white); border-color: var(--bs-accent); }

/* ---- Toggle-knoppen in tabel ---- */

.toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 20px;
    border: 1px solid var(--bs-border);
    border-radius: 3px;
    background: var(--bs-white);
    cursor: pointer;
    font-size: .85rem;
    color: var(--bs-muted);
    text-decoration: none;
    line-height: 1;
    transition: background .15s, color .15s;
}

.toggle-btn.is-on  { background: var(--bs-success); border-color: var(--bs-success); color: #fff; }
.toggle-btn.is-off { background: var(--bs-white); color: var(--bs-border); }

/* ---- Bewerkingsformulier ---- */

.bs-edit-form {
    background: var(--bs-white);
    border: 1px solid var(--bs-border);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.bs-edit-form h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.form-field {
    margin-bottom: 1rem;
}

.form-field label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-muted);
    margin-bottom: .3rem;
}

.form-field input[type="text"],
.form-field textarea {
    width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    font-family: inherit;
    font-size: .9rem;
    background: var(--bs-white);
    color: var(--bs-text);
    resize: vertical;
}

.form-field input[type="text"]:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--bs-accent);
    box-shadow: 0 0 0 2px rgba(42, 100, 150, .15);
}

.field-readonly {
    margin: 0 0 1rem;
    font-size: .9rem;
}

.form-actions {
    display: flex;
    gap: .75rem;
    align-items: center;
    margin-top: 1rem;
}

.form-actions button[type="submit"] {
    padding: .45rem 1.1rem;
    background: var(--bs-accent);
    color: var(--bs-white);
    border: none;
    border-radius: 4px;
    font-size: .9rem;
    cursor: pointer;
    font-family: inherit;
}

.form-actions button[type="submit"]:hover { opacity: .85; }

.form-actions a {
    font-size: .9rem;
    color: var(--bs-muted);
}

/* ---- Knop: verwijderen ---- */

.btn-delete {
    margin-left: auto;
    padding: .35rem .9rem;
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .85rem;
    cursor: pointer;
}
.btn-delete:hover { opacity: .85; }

.btn-delete--inline {
    padding: .1rem .4rem;
    font-size: .8rem;
    margin-left: .5rem;
    background: transparent;
    color: var(--bs-muted);
    border: 1px solid var(--bs-muted);
}
.btn-delete--inline:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

/* ---- Knop: nieuwe rij ---- */

.btn-new {
    padding: .35rem .9rem;
    background: var(--bs-accent);
    color: var(--bs-white);
    border-radius: 4px;
    font-size: .85rem;
    text-decoration: none;
}

.btn-new:hover { opacity: .85; text-decoration: none; }

/* ---- Quicklinks ---- */

.bs-quicklinks {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.bs-quicklinks a {
    padding: .45rem 1rem;
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    font-size: .9rem;
    text-decoration: none;
    color: var(--bs-text);
    background: var(--bs-white);
}

.bs-quicklinks a:hover { border-color: var(--bs-accent); color: var(--bs-accent); }

.btn-cache-clear {
    padding: .45rem 1rem;
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    font-size: .9rem;
    color: var(--bs-text);
    background: var(--bs-white);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.btn-cache-clear:hover { border-color: var(--bs-accent); color: var(--bs-accent); }

.cache-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    padding: 0 .3em;
    height: 1.4em;
    background: var(--bs-accent);
    color: #fff;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
}

.bs-alert-ok { background: #e8f5e9; border: 1px solid #b2dfb4; color: #1b5e20; padding: .65rem 1rem; border-radius: 4px; margin-top: 1rem; font-size: .9rem; }

/* ---- Sorteerbare kolommen ---- */

.bs-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.bs-table thead th.sortable:hover { color: var(--bs-accent); }

.bs-table thead th.sort-asc::after  { content: ' ▲'; font-size: .7em; color: var(--bs-accent); }
.bs-table thead th.sort-desc::after { content: ' ▼'; font-size: .7em; color: var(--bs-accent); }

/* ---- Groep-dividers (teksten) ---- */

.bs-table tr.bs-group-header td {
    background: var(--bs-sidebar);
    color: #aaa;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: .3rem .75rem;
    border-color: var(--bs-sidebar);
}

/* ---- Project-tabel specifiek ---- */

.bs-projects-table td:nth-child(5),
.bs-projects-table td:nth-child(6) { text-align: center; }

/* ---- Alerts ---- */

.bs-alert { padding: .65rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: .9rem; }
.bs-alert p { margin: 0; }
.bs-alert-error   { background: #fdecea; border: 1px solid #f5c6c2; color: #7a1f1f; }
.bs-alert-success { background: #e8f5e9; border: 1px solid #b2dfb4; color: #1b5e20; }

/* ---- Project-formulier ---- */

.bs-project-form { max-width: 960px; }

.bs-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.bs-form-grid fieldset {
    border: 1px solid var(--bs-border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    background: var(--bs-white);
    margin: 0;
}

.bs-form-grid legend {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bs-muted);
    padding: 0 .4rem;
}

.form-field-inline {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.form-field-inline label {
    display: flex !important;
    align-items: center;
    gap: .3rem;
    font-size: .875rem !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--bs-text) !important;
    font-weight: normal !important;
    margin-bottom: 0 !important;
    cursor: pointer;
}

.form-field-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}

.form-field-2col .form-field { margin-bottom: 0; }

.form-field select {
    width: 100%;
    padding: .4rem .6rem;
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    font-family: inherit;
    font-size: .9rem;
    background: var(--bs-white);
    color: var(--bs-text);
}

.form-field select:focus {
    outline: none;
    border-color: var(--bs-accent);
    box-shadow: 0 0 0 2px rgba(42,100,150,.15);
}

.bs-count-line {
    font-size: .8rem;
    color: var(--bs-muted);
    margin: -.5rem 0 1rem;
}

/* ---- Sidebar: bewerkingsmodus-links ---- */

.bs-edit-links {
    padding: .75rem 0 .5rem;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.bs-edit-links-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #666;
    margin: 0 0 .2rem;
}

.bs-edit-links a {
    font-size: .8rem;
    color: #aaa;
    text-decoration: none;
}

.bs-edit-links a:hover { color: #fff; text-decoration: none; }

/* ---- Sidebar: ingelogde gebruiker ---- */

.bs-sidebar-user {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.bs-sidebar-email {
    font-size: .78rem;
    color: #888;
    word-break: break-all;
}

.bs-logout-link {
    font-size: .78rem;
    color: #aaa;
    text-decoration: none;
}

.bs-logout-link:hover { color: #fff; text-decoration: none; }

/* ---- Login-pagina ---- */

.bs-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-bg);
}

.bs-login-card {
    background: var(--bs-white);
    border: 1px solid var(--bs-border);
    border-radius: 8px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.bs-login-card h1 {
    margin: 0 0 .25rem;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: .05em;
}

.bs-login-sub {
    margin: 0 0 1.75rem;
    font-size: .82rem;
    color: var(--bs-muted);
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1.25rem;
    background: var(--bs-white);
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    font-size: .9rem;
    color: var(--bs-text);
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    transition: box-shadow .15s, border-color .15s;
}

.btn-google:hover {
    border-color: #aaa;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    text-decoration: none;
}

/* ---- Rich-text editor (teksten) ---- */

.rte-wrap {
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    background: var(--bs-white);
}

.rte-toolbar {
    display: flex;
    align-items: center;
    gap: .2rem;
    padding: .3rem .4rem;
    border-bottom: 1px solid var(--bs-border);
    background: #f9f9f7;
    flex-wrap: wrap;
}

.rte-toolbar button {
    padding: .2rem .45rem;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    font-size: .8rem;
    cursor: pointer;
    color: var(--bs-text);
    line-height: 1.4;
    font-family: inherit;
}

.rte-toolbar button:hover { background: var(--bs-bg); border-color: var(--bs-border); }
.rte-toolbar button.active { background: var(--bs-accent); color: #fff; border-color: var(--bs-accent); }

.rte-sep {
    display: inline-block;
    width: 1px;
    height: 1rem;
    background: var(--bs-border);
    margin: 0 .2rem;
}

.rte-editor {
    min-height: 120px;
    padding: .5rem .65rem;
    font-size: .9rem;
    line-height: 1.6;
    outline: none;
    white-space: pre-wrap;
}

.rte-editor:focus { box-shadow: inset 0 0 0 2px rgba(42,100,150,.2); }

.rte-editor p  { margin: .2em 0; }
.rte-editor h3 { font-size: 1rem;  font-weight: 700; margin: .5em 0 .2em; }
.rte-editor h4 { font-size: .9rem; font-weight: 600; margin: .4em 0 .2em; }
.rte-editor strong, .rte-editor b { font-weight: 700; }
.rte-editor em,  .rte-editor i    { font-style: italic; }
.rte-editor u                     { text-decoration: underline; }

.rte-source {
    width: 100%;
    box-sizing: border-box;
    padding: .5rem .65rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: .78rem;
    line-height: 1.5;
    border: none;
    resize: vertical;
    background: #1e1e2e;
    color: #cdd6f4;
    min-height: 120px;
}

/* ---- Workspace / database editor ---- */

.ws-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: 1rem;
}

.ws-tab {
    padding: .3rem .85rem;
    border: 1px solid var(--bs-border);
    border-radius: 20px;
    font-size: .8rem;
    background: var(--bs-white);
    color: var(--bs-text);
    cursor: pointer;
}

.ws-tab.active { background: var(--bs-accent); color: #fff; border-color: var(--bs-accent); }

.ws-panel { display: none; }
.ws-panel.active { display: block; }

.ws-toolbar { margin-bottom: .6rem; }

.ws-scroll {
    overflow-x: auto;
    max-height: 75vh;
    border: 1px solid var(--bs-border);
    border-radius: 6px;
}

/* Workspace vult volledige viewport — andere backstage-pagina's onaangeraakt */
body.page-workspace {
    overflow: hidden;
    height: 100vh;
}
body.page-workspace .backstage-wrap {
    height: 100vh;
    overflow: hidden;
    align-items: stretch;
}
body.page-workspace .backstage-content {
    max-width: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.25rem 1.5rem;
}
body.page-workspace .backstage-content main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
body.page-workspace .ws-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
body.page-workspace .ws-scroll {
    flex: 1;
    max-height: none;
    overflow: auto;
}

.ws-table {
    border-collapse: collapse;
    font-size: .8rem;
    width: max-content;
    min-width: 100%;
}

.ws-table thead th {
    position: sticky;
    top: 0;
    background: #f2f2f0;
    border: 1px solid var(--bs-border);
    padding: .35rem .6rem;
    text-align: left;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-muted);
    z-index: 3;
    cursor: pointer;
    white-space: nowrap;
}

.ws-table td {
    border: 1px solid var(--bs-border);
    padding: .25rem .5rem;
    vertical-align: top;
    max-width: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}

.ws-table td[contenteditable]:focus { outline: 2px solid var(--bs-accent); outline-offset: -2px; background: #fffff0; }

.ws-id { background: #f5f5f3; color: var(--bs-muted); font-size: .75rem; }
.ws-bool { text-align: center; }
.ws-del-th, .ws-del { width: 28px; text-align: center; }
.ws-del-btn { border: none; background: transparent; cursor: pointer; color: var(--bs-muted); font-size: .9rem; padding: 0 .25rem; }
.ws-del-btn:hover { color: var(--bs-danger); }

.ws-sticky-1 { position: sticky; left: 0; z-index: 2; background: #fff; box-shadow: 2px 0 3px -1px rgba(0,0,0,.08); }
.ws-sticky-2 { position: sticky; left: 48px; z-index: 2; background: #e8f4fb; box-shadow: 2px 0 3px -1px rgba(0,0,0,.08); }

@keyframes ws-flash { from { background-color: #fff9c4; } to { background-color: inherit; } }
.ws-flash { animation: ws-flash .8s ease-out; }

/* ----------------------------------------------------------------
   Instellingen (settings.php)
   ---------------------------------------------------------------- */

.bs-settings-site {
    background: var(--bs-white);
    border: 1px solid var(--bs-border);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.bs-settings-site h2 {
    margin: 0 0 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--bs-border);
    padding-bottom: .6rem;
}

.bs-settings-page {
    margin-bottom: 1.5rem;
}

.bs-settings-page:last-child { margin-bottom: 0; }

.bs-settings-page h3 {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bs-muted);
    margin: 0 0 .75rem;
}

.bs-settings-field {
    margin-bottom: 1rem;
}

.bs-settings-field-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-muted);
    margin: 0 0 .35rem;
}

.bs-settings-lang-row {
    margin-bottom: .4rem;
}

.bs-settings-lang-row label {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}

.lang-tag {
    display: inline-block;
    min-width: 2rem;
    font-size: .7rem;
    font-weight: 700;
    text-align: center;
    padding: .15rem .3rem;
    border-radius: 3px;
    background: var(--bs-bg);
    border: 1px solid var(--bs-border);
    color: var(--bs-muted);
    margin-top: .4rem;
    flex-shrink: 0;
}

.lang-tag.from-db {
    background: #e8f4fb;
    border-color: #9ecde8;
    color: var(--bs-accent);
}

.bs-settings-lang-row input[type="text"],
.bs-settings-lang-row textarea {
    flex: 1;
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    padding: .35rem .6rem;
    font-size: .875rem;
    font-family: inherit;
    line-height: 1.4;
    color: var(--bs-text);
    background: var(--bs-white);
    resize: vertical;
}

.bs-settings-lang-row input[type="text"]:focus,
.bs-settings-lang-row textarea:focus {
    outline: none;
    border-color: var(--bs-accent);
    box-shadow: 0 0 0 2px rgba(42,100,150,.12);
}

.bs-settings-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bs-border);
}
