/* Van Dijk Ontwikkeling — dark navy theme */
:root {
    --base:     #0D1B2E;
    --mantle:   #0A1628;
    --crust:    #071120;
    --surface0: #142236;
    --surface1: #1C3048;
    --surface2: #284460;
    --overlay0: #4A6785;
    --overlay1: #64748B;
    --text:     #E2EAF4;
    --subtext0: #94A3B8;
    --teal:     #0BBFAA;
    --teal-dark:#0A9985;
    --green:    #22C55E;
    --red:      #F87171;
    --yellow:   #F9E2AF;
    /* kept for any references that still use old names */
    --blue:     #0BBFAA;
    --mauve:    #22C55E;
}

/* ── Light mode overrides ─────────────────────────────── */
[data-theme="light"] {
    --base:     #F7F9FC;
    --mantle:   #FFFFFF;
    --crust:    #EEF2F7;
    --surface0: #FFFFFF;
    --surface1: #F0F4F8;
    --surface2: #E2E8F0;
    --overlay0: #94A3B8;
    --overlay1: #64748B;
    --text:     #0A1628;
    --subtext0: #64748B;
    --red:      #DC2626;
    --yellow:   #B45309;
}

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

body {
    background: var(--base);
    color: var(--text);
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Toolbar ──────────────────────────────────────────── */
#toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--mantle);
    border-bottom: 1px solid var(--surface0);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 5px 14px;
    background: var(--surface0);
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.tool-btn:hover  { background: var(--surface1); }
.tool-btn.active { background: var(--teal); color: var(--mantle); font-weight: 600; }
.tool-btn.danger { color: var(--red); }
.tool-btn.danger:hover { background: var(--red); color: var(--base); }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }
@keyframes upload-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); background: var(--surface1); }
    50%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--green) 0%, transparent);  background: color-mix(in srgb, var(--green) 25%, var(--surface1)); }
    100% { box-shadow: 0 0 0 0 transparent; background: var(--surface1); }
}
.tool-btn.highlight-pulse { animation: upload-pulse 0.9s ease 2; }

.sep {
    width: 1px; height: 22px;
    background: var(--surface1);
    margin: 0 2px;
    flex-shrink: 0;
}

.project-name-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    width: 180px;
    transition: border-color 0.15s, background 0.15s;
}
.project-name-input::placeholder { color: var(--overlay0); font-weight: 400; }
.project-name-input:hover  { border-color: var(--surface2); background: var(--surface0); }
.project-name-input:focus  {
    outline: none;
    border-color: var(--teal);
    background: var(--surface0);
}

.toolbar-brand {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--teal), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: -0.2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.scale-chip {
    padding: 4px 11px;
    background: var(--surface1);
    color: var(--yellow);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.hidden { display: none !important; }

/* ── Status bar ───────────────────────────────────────── */
#statusbar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 3px 14px;
    background: var(--crust);
    border-bottom: 1px solid var(--surface0);
    font-size: 12px;
    color: var(--subtext0);
    flex-shrink: 0;
}
.sep-v {
    display: inline-block;
    width: 1px; height: 14px;
    background: var(--surface1);
    margin: 0 10px;
    vertical-align: middle;
}

.sb-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0;
}

.sb-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--overlay0);
    font-size: 11px;
}

.sb-sep {
    color: var(--surface2);
    user-select: none;
}

.sb-plus {
    color: var(--overlay0);
    font-size: 10px;
    user-select: none;
}

kbd {
    display: inline-flex;
    align-items: center;
    background: var(--surface1);
    border: 1px solid var(--surface2);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 5px;
    font-size: 10px;
    font-family: inherit;
    color: var(--subtext0);
    line-height: 16px;
    user-select: none;
}

#txt-version {
    color: var(--overlay0);
    font-size: 11px;
}

/* ── Main content ─────────────────────────────────────── */
#main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--mantle);
    border-right: 1px solid var(--surface0);
    overflow: hidden;
}

.sidebar-header {
    padding: 9px 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--overlay0);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    border-bottom: 1px solid var(--surface0);
    flex-shrink: 0;
}

#furniture-list {
    overflow-y: auto;
    flex: 1;
}

.f-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--surface0);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}
.f-item:hover   { background: rgba(255,255,255,0.04); }
.f-item.active  { background: var(--surface0); }

.f-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.f-info { flex: 1; min-width: 0; }
.f-name {
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.f-dims { font-size: 11px; color: var(--subtext0); margin-top: 1px; }

.f-btns { display: flex; gap: 3px; flex-shrink: 0; }

.icon-btn {
    background: none;
    border: none;
    color: var(--overlay0);
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
}
.icon-btn:hover       { background: var(--surface1); color: var(--text); }
.icon-btn.del:hover   { color: var(--red); }

/* ── Canvas area ──────────────────────────────────────── */
#canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--base);
}

/* Fabric.js renders two canvas elements; let them fill the container */
#canvas-wrap canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

#canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--overlay0);
    font-size: 15px;
    text-align: center;
    pointer-events: none;
    line-height: 1.6;
}

/* ── Modals ───────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-box {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 10px;
    padding: 24px 24px 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-box h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.modal-box label {
    font-size: 11px;
    color: var(--subtext0);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 4px;
}

.input-field {
    background: var(--surface1);
    border: 1px solid var(--surface2);
    color: var(--text);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.12s;
}
.input-field:focus {
    outline: none;
    border-color: var(--teal);
}
.input-field.input-error {
    border-color: var(--red);
    background: rgba(243,139,168,0.08);
}

.hint-text {
    font-size: 12px;
    color: var(--subtext0);
    margin: -2px 0 2px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.btn-primary {
    background: var(--teal);
    color: var(--mantle);
    border: none;
    padding: 7px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.2s, transform 0.2s;
}
.btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); }

.btn-secondary {
    background: var(--surface1);
    color: var(--text);
    border: none;
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.12s;
}
.btn-secondary:hover { background: var(--surface2); }

.btn-danger {
    background: var(--red);
    color: var(--base);
    border: none;
    padding: 7px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    transition: opacity 0.12s;
}
.btn-danger:hover { opacity: 0.88; }

/* ── Toast notifications ──────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 340px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: auto;
    line-height: 1.45;
}
.toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}
.toast-error {
    background: var(--surface0);
    border: 1px solid var(--red);
    color: var(--text);
}
.toast-info {
    background: var(--surface0);
    border: 1px solid var(--teal);
    color: var(--text);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--overlay0); }

/* ── Light mode specific fixes ────────────────────────── */
[data-theme="light"] #toolbar,
[data-theme="light"] #sidebar {
    border-color: var(--surface2);
}

[data-theme="light"] .f-item:hover { background: rgba(0,0,0,0.04); }

[data-theme="light"] .modal-box {
    box-shadow: 0 8px 32px rgba(10,22,40,0.15);
}

[data-theme="light"] .toast-error,
[data-theme="light"] .toast-info {
    background: var(--mantle);
    box-shadow: 0 4px 16px rgba(10,22,40,0.12);
}
