/* ── Grid Designer ─────────────────────────────── */

.gd-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    overflow: hidden;
    background: #f1f5f9;
}

/* ── Toolbar ──────────────────────────────────── */
.gd-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.gd-toolbar-left { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.gd-toolbar-center { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.gd-toolbar-right { display: flex; align-items: center; gap: 8px; }

.gd-tb-btn {
    padding: 5px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.gd-tb-btn:hover { background: #f8fafc; border-color: #94a3b8; }
.gd-tb-btn:disabled { opacity: 0.4; cursor: default; }
.gd-tb-btn:disabled:hover { background: #fff; border-color: #d1d5db; }
.gd-tb-btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.gd-tb-btn.primary:hover { background: #1d4ed8; }
.gd-tb-btn.danger { color: #dc2626; border-color: #fca5a5; }
.gd-tb-btn.danger:hover { background: #fef2f2; }
.gd-tb-sep { width: 1px; height: 24px; background: #e2e8f0; margin: 0 4px; }
.gd-tb-label { font-size: 13px; color: #64748b; white-space: nowrap; }

/* ── Main Layout ──────────────────────────────── */
.gd-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Toolbox ──────────────────────────────────── */
.gd-toolbox {
    width: 180px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 12px 0;
}
.gd-toolbox h4 {
    margin: 0 0 8px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}
.gd-tool-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: #374151;
    cursor: grab;
    transition: background 0.15s;
    user-select: none;
}
.gd-tool-item:hover { background: #f1f5f9; }
.gd-tool-item:active { cursor: grabbing; }
.gd-tool-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f1f5f9;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    flex-shrink: 0;
}
.gd-toolbox-sep {
    height: 1px;
    background: #e2e8f0;
    margin: 6px 12px;
}

/* ── Surface Wrapper ──────────────────────────── */
.gd-surface-wrap {
    flex: 1;
    overflow: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Breadcrumb ───────────────────────────────── */
.gd-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    align-self: flex-start;
}
.gd-breadcrumb-item {
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}
.gd-breadcrumb-item:hover { text-decoration: underline; }
.gd-breadcrumb-sep { color: #94a3b8; }
.gd-breadcrumb-current { color: #0f172a; font-weight: 600; }

/* ── Grid Surface ─────────────────────────────── */
.gd-grid {
    display: grid;
    gap: 0;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

/* ── Cell ─────────────────────────────────────── */
.gd-cell {
    min-height: 56px;
    border: 1px solid #e2e8f0;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    background: #fff;
}
.gd-cell:hover { background: #f8fafc; }
.gd-cell.selected {
    background: #eff6ff;
    border-color: #2563eb;
    z-index: 1;
    box-shadow: inset 0 0 0 1px #2563eb;
}
.gd-cell.multi-selected {
    background: #dbeafe;
    border-color: #3b82f6;
    z-index: 1;
    box-shadow: inset 0 0 0 1px #3b82f6;
}
.gd-cell.drag-over {
    background: #dbeafe;
    border-color: #3b82f6;
    border-style: dashed;
}
.gd-cell.panel-cell {
    background: #f0fdf4;
    border-color: #86efac;
}
.gd-cell.panel-cell.selected {
    background: #dcfce7;
    border-color: #22c55e;
    box-shadow: inset 0 0 0 1px #22c55e;
}

.gd-cell-empty {
    font-size: 12px;
    color: #cbd5e1;
    pointer-events: none;
    text-align: center;
}

/* ── Cell Control Preview ─────────────────────── */
.gd-cell-control {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}
.gd-cell-control-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #94a3b8;
}
.gd-cell-control-label {
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gd-cell-control-preview {
    height: 28px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 12px;
    color: #94a3b8;
}
.gd-cell-control-preview.header-preview {
    border: none;
    background: none;
    height: auto;
    padding: 0;
    font-weight: 700;
    color: #0f172a;
}
.gd-cell-control-preview.separator-preview {
    border: none;
    background: none;
    height: 2px;
    padding: 0;
    border-top: 2px solid #e2e8f0;
}
.gd-cell-control-preview.checkbox-preview {
    border: none;
    background: none;
    padding: 0;
    gap: 6px;
    font-size: 13px;
    color: #374151;
}
.gd-cell-control-preview.button-preview {
    background: #2563eb;
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    justify-content: center;
    border-radius: 6px;
}
.gd-cell-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.gd-cell-panel-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #16a34a;
}
.gd-cell-panel-grid {
    display: grid;
    gap: 2px;
    width: 100%;
}
.gd-cell-panel-minicell {
    height: 12px;
    border: 1px solid #bbf7d0;
    border-radius: 2px;
    background: #f0fdf4;
}
.gd-cell-panel-hint {
    font-size: 11px;
    color: #16a34a;
    font-style: italic;
}

/* ── Row Handles ──────────────────────────────── */
.gd-row-numbers {
    position: absolute;
    left: -28px;
    top: 0;
    width: 24px;
    display: flex;
    flex-direction: column;
}

/* ── Property Editor ──────────────────────────── */
.gd-properties {
    width: 260px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 16px;
}
.gd-properties h4 {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}
.gd-prop-group {
    margin-bottom: 16px;
}
.gd-prop-field {
    margin-bottom: 10px;
}
.gd-prop-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 4px;
}
.gd-prop-field input[type="text"],
.gd-prop-field input[type="number"],
.gd-prop-field select,
.gd-prop-field textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #0f172a;
    background: #fff;
    box-sizing: border-box;
}
.gd-prop-field input:focus,
.gd-prop-field select:focus,
.gd-prop-field textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.gd-prop-field textarea { resize: vertical; min-height: 60px; }
.gd-prop-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}
.gd-prop-check input[type="checkbox"] { margin: 0; }

.gd-prop-options-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gd-prop-option-row {
    display: flex;
    gap: 4px;
}
.gd-prop-option-row input {
    flex: 1;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
}
.gd-prop-option-remove {
    padding: 2px 6px;
    border: none;
    background: none;
    color: #dc2626;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
}
.gd-prop-option-remove:hover { background: #fef2f2; }
.gd-prop-option-add {
    padding: 4px 8px;
    border: 1px dashed #d1d5db;
    border-radius: 4px;
    background: none;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    margin-top: 2px;
}
.gd-prop-option-add:hover { background: #f8fafc; }

.gd-prop-cell-info {
    padding: 8px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 12px;
}

.gd-prop-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.gd-prop-clear-btn {
    margin-top: 16px;
    padding: 6px 12px;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    background: #fff;
    color: #dc2626;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
}
.gd-prop-clear-btn:hover { background: #fef2f2; }
