/* ============================================
   FLOOR EDITOR — ELECTRIC NOIR
   ============================================ */

/* Space Grotesk — local fonts */
@font-face {
    font-family: 'Space Grotesk';
    src: url('fonts/sg-latin-ext.woff2') format('woff2');
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Space Grotesk';
    src: url('fonts/sg-400.woff2') format('woff2');
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

:root {
    --bg-base:      #050508;
    --bg-surface:   #0a0a10;
    --bg-card:      #101018;
    --bg-card-hover:#16161f;
    --cyan:         #00e5ff;
    --cyan-light:   #67efff;
    --cyan-glow:    rgba(0,229,255,0.12);
    --cyan-deep:    #00b8d4;
    --text:         #e8edf2;
    --text-dim:     rgba(232,237,242,0.45);
    --font-display: 'Space Grotesk', sans-serif;
    --font-body:    'Space Grotesk', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
    --radius-sm:    8px;
    --radius-md:    14px;
    --radius-lg:    20px;

    --ease-out:       cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out:    cubic-bezier(0.77, 0, 0.175, 1);
    --ease-spring:    cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast:   0.15s;
    --duration-normal: 0.25s;
    --duration-slow:   0.35s;
    --stagger-delay:   40ms;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    min-height: 100vh;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Noise overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

.hidden { display: none !important; }

/* BUTTONS */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out),
                background-color var(--duration-normal) var(--ease-out),
                border-color var(--duration-normal) var(--ease-out);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.04em;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--cyan-deep));
    color: #050508;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    box-shadow: 0 4px 20px rgba(0,229,255,0.3);
}
.btn-primary:hover { box-shadow: 0 8px 32px rgba(0,229,255,0.45); }
.btn-secondary {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
}
.btn-secondary:hover { background: rgba(255,255,255,0.08); }
.btn-success {
    background: linear-gradient(135deg, #2dd4a0, #16a085);
    color: #050508;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(45,212,160,0.25);
}
.btn-danger {
    background: rgba(224,82,82,0.1);
    border: 1px solid rgba(224,82,82,0.2);
    color: #f08080;
}

/* HEADER */
.editor-header {
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    background: rgba(6,6,6,0.92);
    backdrop-filter: blur(24px);
    position: relative;
}
.editor-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,229,255,0.12), transparent);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-logo {
    width: 42px; height: 42px;
    background: linear-gradient(145deg, var(--cyan), var(--cyan-deep));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(0,229,255,0.2);
}
.header-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #fff 30%, var(--cyan-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.header-subtitle { margin: 0; font-size: 12px; color: var(--text-dim); letter-spacing: 0.3px; }
.header-actions { display: flex; gap: 10px; }

/* EDITOR CONTAINER */
.editor-container { display: flex; height: calc(100vh - 71px); }

/* TOOLBAR */
.toolbar {
    width: 260px;
    background: rgba(10,10,10,0.6);
    border-right: 1px solid rgba(255,255,255,0.04);
    padding: 24px;
    overflow-y: auto;
}
.toolbar h3 {
    font-family: var(--font-display);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 16px;
}
.toolbar h3:not(:first-child) { margin-top: 32px; }

/* TOOL BUTTONS */
.tool-buttons { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.tool-btn {
    width: 100%;
    padding: 11px 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-md);
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color var(--duration-normal) var(--ease-out),
                border-color var(--duration-normal) var(--ease-out),
                color var(--duration-normal) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}
.tool-btn:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12); color: var(--text); }
.tool-btn:active { transform: scale(0.98); }
.tool-btn.active { background: var(--cyan-glow); border-color: rgba(0,229,255,0.3); color: var(--cyan-light); }

/* TOOL OPTIONS */
.tool-options {
    margin-top: 12px;
    padding: 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
}
.tool-options label {
    font-family: var(--font-body);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    display: block;
    margin-bottom: 10px;
}
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
    width: 24px; height: 24px;
    border-radius: 7px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 12px rgba(255,255,255,0.15); }

/* TABLE TYPES */
.table-types { display: flex; flex-direction: column; gap: 8px; }
.type-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color var(--duration-normal) var(--ease-out),
                border-color var(--duration-normal) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}
.type-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
.type-item:active { transform: scale(0.98); }
.type-item.selected { border-color: rgba(0,229,255,0.4); background: var(--cyan-glow); }

.type-preview { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.type-preview.standing { width: 36px; height: 36px; border-radius: 50%; background: rgba(0,229,255,0.2); border: 2px solid var(--cyan); }
.type-preview.sofa { width: 50px; height: 30px; border-radius: 8px; background: rgba(226,179,64,0.2); border: 2px solid #e2b340; }
.type-preview.djbooth { width: 50px; height: 30px; border-radius: 8px; background: rgba(199,125,186,0.2); border: 2px solid #c77dba; }

/* SELECTED INFO */
.selected-info {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
    padding: 18px;
}
.no-selection { color: var(--text-dim); font-size: 14px; text-align: center; }
.selected-info .info-row {
    display: flex; justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 14px;
}
.selected-info .info-row:last-child { border-bottom: none; }
.selected-info .info-label { color: var(--text-dim); }
.selected-info .info-value { font-weight: 600; font-family: var(--font-mono); }
.selected-info .delete-btn { margin-top: 16px; width: 100%; }

/* FLOOR AREA */
.floor-area {
    flex: 1; display: flex;
    align-items: center; justify-content: center;
    padding: 20px; overflow: auto;
    background: radial-gradient(ellipse at center, rgba(0,229,255,0.02) 0%, transparent 60%);
}
.floor-plan {
    width: 960px; height: 600px;
    background: #080808;
    border-radius: var(--radius-lg);
    position: relative; overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(0,229,255,0.06),
        0 24px 80px rgba(0,0,0,0.7);
}
.floor-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(0,229,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,229,255,0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

/* TABLE ITEMS */
.table-item {
    position: absolute;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: grab;
    transition: box-shadow 0.2s, filter 0.2s;
    user-select: none;
}
.table-item:hover { transform: scale(1.03); filter: brightness(1.15); }
.table-item:active { transform: scale(0.95); }
.table-item.dragging { cursor: grabbing; z-index: 100; box-shadow: 0 12px 48px rgba(0,0,0,0.6); }
.table-item.selected { box-shadow: 0 0 0 3px var(--cyan), 0 0 24px rgba(0,229,255,0.3); }

.table-item.standing { width: 60px; height: 60px; border-radius: 50%; background: rgba(0,229,255,0.15); border: 2px solid var(--cyan); }
.table-item.sofa { width: 77px; height: 43px; border-radius: 8px; background: rgba(226,179,64,0.15); border: 2px solid #e2b340; }
.table-item.djbooth { width: 90px; height: 50px; border-radius: 8px; background: rgba(199,125,186,0.15); border: 2px solid #c77dba; }

.table-item .table-number { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #fff; }
.table-item .table-type { font-size: 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* MODAL */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(16px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: linear-gradient(160deg, rgba(18,18,18,0.98), rgba(10,10,10,0.99));
    border: 1px solid rgba(0,229,255,0.1);
    border-radius: 24px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 32px 100px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.04);
    animation: modalIn var(--duration-slow) var(--ease-spring) both;
    position: relative;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal::before {
    content: '';
    position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 40px; height: 2px;
    background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}
.modal h2 { margin: 0 0 24px; font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.input {
    width: 100%; padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,229,255,0.1);
}
select.input option { background: var(--bg-card); color: var(--text); }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* TOAST */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    padding: 12px 28px;
    background: linear-gradient(135deg, rgba(45,212,160,0.9), rgba(22,160,133,0.9));
    color: #050508;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    z-index: 1000;
    animation: fadeInUp var(--duration-slow) var(--ease-spring);
    box-shadow: 0 8px 32px rgba(45,212,160,0.2);
    font-family: var(--font-body);
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes fadeOutDown {
    from { opacity: 1; transform: translate(-50%, 0); }
    to   { opacity: 0; transform: translate(-50%, 12px); }
}
.toast.toast-exit {
    animation: fadeOutDown var(--duration-normal) var(--ease-in-out) forwards;
}

/* SCROLLBAR */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,229,255,0.4); }

/* MOBILE */
@media (max-width: 768px) {
    .editor-header { flex-direction: column; gap: 12px; padding: 12px; }
    .editor-header::after { display: none; }
    .header-actions { width: 100%; justify-content: center; flex-wrap: wrap; }
    .header-actions .btn { padding: 8px 14px; font-size: 12px; }

    .editor-container { flex-direction: column; }

    .toolbar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        padding: 12px;
        max-height: 200px;
    }
    .toolbar h3 { margin-bottom: 10px; font-size: 10px; }
    .toolbar h3:not(:first-child) { margin-top: 16px; }
    .table-types { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .type-item { padding: 8px 12px; }
    .selected-info { display: none; }

    /* Block + text-align centering (NOT flex justify-content:center, which makes
       the left overflow unreachable by scroll). This centers the map and lets
       you scroll to BOTH sides when it overflows the screen. */
    .floor-area {
        padding: 10px;
        display: block;
        text-align: center;
        overflow: auto;
    }
    .floor-plan {
        display: inline-block;
        transform: scale(0.55);
        transform-origin: top left;
        /* Match the layout footprint to the scaled visual size (960*0.55=528,
           600*0.55=330) so the inline-block is centered on its real size. */
        margin-right: -432px;
        margin-bottom: -270px;
    }

    .modal { padding: 24px; }
}

/* Touch device hover guards */
@media (hover: none) {
    .btn:hover { transform: none; }
    .btn-primary:hover { box-shadow: 0 4px 20px rgba(0,229,255,0.3); }
    .btn-secondary:hover { background: rgba(255,255,255,0.04); }
    .tool-btn:hover { background: rgba(255,255,255,0.02); border-color: rgba(255,255,255,0.06); color: var(--text-dim); }
    .color-swatch:hover { transform: none; }
    .type-item:hover { background: rgba(255,255,255,0.02); border-color: rgba(255,255,255,0.05); }
    .table-item:hover { transform: none; filter: none; }
}
