/* ═══════════════════════════════════════════
   Flashing Drawing Tool – Styles
   ═══════════════════════════════════════════ */

/* Reset within plugin */
.fdt-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
.fdt-wrapper { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 1200px; margin: 0 auto; color: #333; }

/* ─── Config Panel ─── */
.fdt-config-panel { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 24px; }
.fdt-title { font-size: 22px; font-weight: 600; margin-bottom: 20px; }
.fdt-field { margin-bottom: 16px; }
.fdt-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.fdt-req { color: #e53935; }
.fdt-select { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; background: #fff; }

/* Colour grid */
.fdt-colour-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.fdt-colour-swatch {
    width: 44px; height: 44px; border-radius: 6px; border: 2px solid #ddd;
    cursor: pointer; position: relative; transition: border-color .15s;
}
.fdt-colour-swatch:hover { border-color: #888; }
.fdt-colour-swatch.selected { border-color: #e53935; }
.fdt-colour-swatch.selected::after {
    content: '';
    position: absolute;
    inset: 7px;
    border: 2px solid #fff;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.25);
    pointer-events: none;
}

/* Lines rows */
.fdt-lines-header { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 8px; font-weight: 600; font-size: 13px; padding-bottom: 6px; border-bottom: 1px solid #eee; margin-bottom: 8px; }
.fdt-line-row { display: grid; grid-template-columns: 80px 1fr 1fr auto; gap: 8px; margin-bottom: 6px; align-items: center; }
.fdt-line-row input, .fdt-line-row select { padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.fdt-line-row .fdt-remove-line { background: none; border: none; color: #e53935; cursor: pointer; font-size: 18px; padding: 4px; }
.fdt-add-line { display: inline-flex; align-items: center; gap: 4px; color: #2e7d32; font-size: 14px; font-weight: 500; text-decoration: none; margin-top: 8px; }
.fdt-add-line:hover { text-decoration: underline; }

/* Buttons */
.fdt-btn { padding: 12px 24px; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s; }
.fdt-btn-primary { background: #00897B; color: #fff; width: 100%; margin-top: 12px; }
.fdt-btn-primary:hover { background: #00796B; }
.fdt-btn-secondary { background: #f5f5f5; color: #333; border: 1px solid #ccc; }
.fdt-btn-secondary:hover { background: #e8e8e8; }
.fdt-btn-danger { background: #e53935; color: #fff; }

/* ─── Canvas Panel ─── */
.fdt-canvas-panel { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-height: 640px; }

.fdt-topbar {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: #eceff1; border-bottom: 1px solid #d0d5d8;
}
.fdt-mode-btn {
    width: 40px; height: 36px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: 800; color: #fff;
}
.fdt-mode-2d { background: #90a4ae; }
.fdt-mode-3d { background: #1e88e5; font-size: 12px; width: 44px; }
.fdt-mode-2d.is-active { background: #29b6f6; box-shadow: inset 0 0 0 2px #4fc3f7; }
.fdt-mode-3d.is-active { background: #1565c0; box-shadow: inset 0 0 0 2px #90caf9; }
.fdt-mouse-legends { display: flex; align-items: center; gap: 14px; margin-left: 12px; }
.fdt-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #444; }
.fdt-mouse-svg { display: block; flex-shrink: 0; }
.fdt-cart-btn { background: #43a047 !important; color: #fff !important; border-color: #2e7d32 !important; }
.fdt-sync-btn { background: #26a69a !important; color: #fff !important; border-color: #00897b !important; }
.fdt-settings-btn { background: #e53935 !important; color: #fff !important; border-color: #c62828 !important; margin-left: auto; }
.fdt-desc-top { flex: 1; min-width: 120px; height: 36px; border: 1px solid #cfd8dc; border-radius: 6px; padding: 0 10px; font-size: 14px; }
.fdt-undo-btn { background: #29b6f6 !important; color: #fff !important; border-color: #0288d1 !important; }

.fdt-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #f8f8f8; border-bottom: 1px solid #e0e0e0; gap: 8px; flex-wrap: wrap; }
.fdt-toolbar-left, .fdt-toolbar-center, .fdt-toolbar-right { display: flex; align-items: center; gap: 6px; }
.fdt-tool-btn {
    width: 36px; height: 36px; border: 1px solid #ccc; border-radius: 6px;
    background: #fff; cursor: pointer; display: flex; align-items: center;
    justify-content: center; font-size: 16px; transition: background .15s;
}
.fdt-tool-btn:hover { background: #eee; }
.fdt-tool-btn.fdt-active { background: #e3f2fd; border-color: #42a5f5; }
.fdt-tool-btn.fdt-scale-btn {
    background: #fff;
    border-color: #e53935;
    color: #e53935;
}
.fdt-tool-btn.fdt-scale-btn:hover,
.fdt-tool-btn.fdt-scale-btn.fdt-active {
    background: #ffebee;
    border-color: #c62828;
    color: #c62828;
}
.fdt-tool-btn.fdt-scale-btn svg { display: block; }
.fdt-tool-btn.fdt-check-btn {
    background: #fff;
    border-color: #9e9e9e;
    color: #424242;
    font-size: 18px;
    font-weight: 700;
}
.fdt-tool-btn.fdt-check-btn:hover {
    background: #e8f5e9;
    border-color: #66bb6a;
    color: #2e7d32;
}
.fdt-colour-side-label { font-size: 13px; font-weight: 500; }
.fdt-colour-side-btn {
    position: relative; width: 44px; height: 28px; border: none; background: transparent; cursor: pointer;
}
.fdt-cs-a, .fdt-cs-b {
    position: absolute; width: 22px; height: 22px; border: 1px solid #333; border-radius: 2px;
}
.fdt-cs-a { left: 0; top: 0; background: #66bb6a; }
.fdt-cs-b { left: 14px; top: 4px; background: #ec407a; }
.fdt-canvas-panel.fdt-side-bottom .fdt-cs-a { background: #ec407a; }
.fdt-canvas-panel.fdt-side-bottom .fdt-cs-b { background: #66bb6a; }

.fdt-menu-wrap { position: relative; }
.fdt-dropdown {
    position: absolute; top: 40px; left: 0; z-index: 120; background: #fff;
    border: 1px solid #ddd; border-radius: 8px; min-width: 180px;
    box-shadow: 0 6px 18px rgba(0,0,0,.12); padding: 4px;
}
.fdt-dropdown button {
    display: block; width: 100%; text-align: left; background: none; border: none;
    padding: 8px 10px; cursor: pointer; border-radius: 6px; font-size: 13px;
}
.fdt-dropdown button:hover { background: #f5f5f5; }
.fdt-settings-panel {
    display: flex; gap: 16px; padding: 8px 12px; background: #fff8e1; border-bottom: 1px solid #ffe082; font-size: 13px;
}
.fdt-settings-panel[hidden] { display: none !important; }
.fdt-dropdown[hidden] { display: none !important; }
.fdt-settings-panel label { display: flex; align-items: center; gap: 8px; }
.fdt-toast {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 140;
    max-width: min(520px, calc(100% - 24px));
    background: #263238;
    color: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    pointer-events: none;
}
.fdt-toast[hidden] { display: none !important; }
.fdt-toast.is-error { background: #c62828; }
.fdt-toast.is-success { background: #2e7d32; }

.fdt-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.fdt-modal[hidden] { display: none !important; }
.fdt-modal-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 16px 40px rgba(0,0,0,.25);
}
.fdt-modal-title { font-size: 18px; margin-bottom: 8px; }
.fdt-modal-text { font-size: 14px; color: #555; margin-bottom: 14px; white-space: pre-line; }
.fdt-modal-field-wrap { margin-bottom: 16px; }
.fdt-modal-field-wrap label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.fdt-modal-field-wrap input {
    width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 15px;
}
.fdt-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fdt-modal-actions .fdt-btn { width: auto; margin: 0; min-width: 90px; }

/* Canvas */
.fdt-canvas-container { position: relative; flex: 1; min-height: 500px; background: #fafafa; overflow: hidden; }
.fdt-canvas-container canvas { display: block; width: 100%; height: 100%; }

/* Point menu (+ Line / Folding popup) */
.fdt-point-menu, .fdt-folding-menu {
    position: absolute; z-index: 100; background: #fff;
    border: 1px solid #ddd; border-radius: 8px; padding: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15); display: flex; gap: 4px;
}
.fdt-point-menu button, .fdt-folding-menu button {
    padding: 6px 14px; border: 1px solid #ccc; border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 13px; font-weight: 500;
}
.fdt-point-menu .fdt-pm-line { background: #e3f2fd; border-color: #42a5f5; color: #1565c0; }
.fdt-point-menu .fdt-pm-fold { background: #e8f5e9; border-color: #66bb6a; color: #2e7d32; }
.fdt-point-menu .fdt-pm-close { background: #f5f5f5; }

/* Folding dropdown */
.fdt-folding-menu { flex-direction: column; min-width: 180px; }
.fdt-folding-menu .fdt-fold-title { font-weight: 600; font-size: 13px; padding: 4px 8px; border-bottom: 1px solid #eee; margin-bottom: 4px; }
.fdt-folding-menu select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px; margin-bottom: 6px; }
.fdt-folding-menu .fdt-fold-actions { display: flex; gap: 4px; }
.fdt-folding-menu .fdt-fold-swap { background: #e8f5e9; border-color: #66bb6a; }
.fdt-folding-menu .fdt-fold-ok { background: #e3f2fd; border-color: #42a5f5; }
.fdt-folding-menu .fdt-fold-cancel { background: #f5f5f5; }

/* Bottom bar */
.fdt-bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid #e0e0e0; background: #f8f8f8; flex-wrap: wrap; gap: 8px; }
.fdt-bottom-actions { display: flex; gap: 8px; }
.fdt-meta-status { font-size: 12px; color: #555; white-space: nowrap; }
.fdt-help-bubble {
    flex: 1; font-size: 13px; color: #1b5e20; background: #e8f5e9;
    border: 1px solid #81c784; border-radius: 8px; padding: 8px 12px;
}

/* Editable labels on canvas (overlays) */
.fdt-canvas-label {
    position: absolute; background: #fff; border: 1px solid #aaa; border-radius: 4px;
    padding: 2px 6px; font-size: 12px; font-weight: 600; cursor: pointer;
    user-select: none; white-space: nowrap; z-index: 50;
}
.fdt-canvas-label.fdt-length-label { color: #333; }
.fdt-canvas-label.fdt-angle-label { color: #2e7d32; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .fdt-config-panel { padding: 16px; }
    .fdt-lines-header { grid-template-columns: 60px 1fr 1fr; font-size: 12px; }
    .fdt-line-row { grid-template-columns: 60px 1fr 1fr auto; }
    .fdt-toolbar { padding: 6px 8px; }
    .fdt-canvas-container { min-height: 350px; }
    .fdt-desc-top { display: none; }
    .fdt-mouse-legends { display: none; }
}
